Class: JIJI::Service::TradeResultService
- Inherits:
-
Object
- Object
- JIJI::Service::TradeResultService
- Defined in:
- lib/jiji/service/trade_result_service.rb
Instance Attribute Summary collapse
-
#process_manager ⇒ Object
Returns the value of attribute process_manager.
-
#registry ⇒ Object
Returns the value of attribute registry.
Instance Method Summary collapse
-
#list(process_id, scale, start_time, end_time) ⇒ Object
指定範囲のトレード結果を取得する。.
-
#list_profit_or_loss(process_id, scale, start_time, end_time) ⇒ Object
指定範囲の損益を取得する。.
Instance Attribute Details
#process_manager ⇒ Object
Returns the value of attribute process_manager.
26 27 28 |
# File 'lib/jiji/service/trade_result_service.rb', line 26 def process_manager @process_manager end |
#registry ⇒ Object
Returns the value of attribute registry.
27 28 29 |
# File 'lib/jiji/service/trade_result_service.rb', line 27 def registry @registry end |
Instance Method Details
#list(process_id, scale, start_time, end_time) ⇒ Object
指定範囲のトレード結果を取得する。
6 7 8 9 10 11 12 13 14 |
# File 'lib/jiji/service/trade_result_service.rb', line 6 def list( process_id, scale, start_time, end_time ) dao = registry.trade_result_dao(process_id) result = dao.list_positions( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil ) # 現在進行中の建て玉はoperatorから取得する op = (process_id == "rmt") ? registry.rmt_process.agent_manager.operator : nil return result.map {|e| op && op.positions.key?(e[0]) ? op.positions[e[0]].values : e[1] } end |
#list_profit_or_loss(process_id, scale, start_time, end_time) ⇒ Object
指定範囲の損益を取得する。
17 18 19 20 21 22 23 24 |
# File 'lib/jiji/service/trade_result_service.rb', line 17 def list_profit_or_loss( process_id, scale, start_time, end_time ) dao = registry.trade_result_dao(process_id) buff = [] dao.each( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil ) {|data| buff << data } return buff end |