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.
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.
28 29 30 |
# File 'lib/jiji/service/trade_result_service.rb', line 28 def process_manager @process_manager end |
Instance Method Details
#list(process_id, scale, start_time, end_time) ⇒ Object
指定範囲のトレード結果を取得する。
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/jiji/service/trade_result_service.rb', line 6 def list( process_id, scale, start_time, end_time ) p = process_manager.get( process_id ) dao = p.agent_manager.trade_result_dao result = dao.list_positions( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil ) # 現在進行中の建て玉はoperatorから取得する op = p.agent_manager.operator 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
指定範囲の損益を取得する。
18 19 20 21 22 23 24 25 26 |
# File 'lib/jiji/service/trade_result_service.rb', line 18 def list_profit_or_loss( process_id, scale, start_time, end_time ) p = process_manager.get( process_id ) dao = p.agent_manager.trade_result_dao buff = [] dao.each( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil ) {|data| buff << data } return buff end |