Class: CounterTradeCommand
- Inherits:
-
Object
- Object
- CounterTradeCommand
- Includes:
- HasHTTPClient
- Defined in:
- lib/bitflyer/cli/command/counter_trade_command.rb
Instance Method Summary collapse
-
#run ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods included from HasHTTPClient
#http_private_client, #http_public_client
Methods included from Authorization
Instance Method Details
#run ⇒ Object
rubocop:disable Metrics/MethodLength
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bitflyer/cli/command/counter_trade_command.rb', line 8 def run # rubocop:disable Metrics/MethodLength position = Position.new(http_private_client.positions) size = position.size.abs.to_f type = position.size.positive? ? 'SELL' : 'BUY' response = http_private_client.send_child_order( product_code: 'FX_BTC_JPY', child_order_type: 'MARKET', side: type, size: size ) if response['child_order_acceptance_id'].nil? puts "An error has occurred#{response}" else puts "Clear position #{type} / #{size}" end end |