Module: Live::OrderUpdatePersistenceSupport
- Defined in:
- app/services/live/order_update_persistence_support.rb
Overview
Persistence helper routines for order update payloads.
Class Method Summary collapse
- .decimal(value) ⇒ Object
- .identity_attributes(order_data) ⇒ Object
- .local_order_attributes(order_data) ⇒ Object
- .parse_timestamp(timestamp) ⇒ Object
- .price_attributes(order_data) ⇒ Object
- .quantity_attributes(order_data) ⇒ Object
- .timestamp_attributes(order_data) ⇒ Object
Class Method Details
.decimal(value) ⇒ Object
54 55 56 57 58 |
# File 'app/services/live/order_update_persistence_support.rb', line 54 def decimal(value) return BigDecimal(0) if value.nil? BigDecimal(value.to_s) end |
.identity_attributes(order_data) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/services/live/order_update_persistence_support.rb', line 17 def identity_attributes(order_data) { exch_order_no: order_data[:ExchOrderNo].to_s, status: order_data[:Status], product: order_data[:ProductName] || order_data[:Product], txn_type: order_data[:TxnType], order_type: order_data[:OrderType] } end |
.local_order_attributes(order_data) ⇒ Object
10 11 12 13 14 15 |
# File 'app/services/live/order_update_persistence_support.rb', line 10 def local_order_attributes(order_data) identity_attributes(order_data) .merge(quantity_attributes(order_data)) .merge(price_attributes(order_data)) .merge((order_data)) end |
.parse_timestamp(timestamp) ⇒ Object
60 61 62 63 64 65 66 |
# File 'app/services/live/order_update_persistence_support.rb', line 60 def () return nil if .nil? || == "" Time.zone.parse() rescue StandardError nil end |
.price_attributes(order_data) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/services/live/order_update_persistence_support.rb', line 38 def price_attributes(order_data) { price: decimal(order_data[:Price]), trigger_price: decimal(order_data[:TriggerPrice]), traded_price: decimal(order_data[:TradedPrice]), avg_traded_price: decimal(order_data[:AvgTradedPrice]) } end |
.quantity_attributes(order_data) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/live/order_update_persistence_support.rb', line 27 def quantity_attributes(order_data) { validity: order_data[:Validity], exchange: order_data[:Exchange], segment: order_data[:Segment], security_id: order_data[:SecurityId].to_s, quantity: order_data[:Quantity].to_i, traded_qty: order_data[:TradedQty].to_i } end |
.timestamp_attributes(order_data) ⇒ Object
47 48 49 50 51 52 |
# File 'app/services/live/order_update_persistence_support.rb', line 47 def (order_data) { last_update_at: (order_data[:LastUpdatedTime]), raw_payload: order_data } end |