Class: SummaryCommand
- Inherits:
-
Object
- Object
- SummaryCommand
- Includes:
- HasHTTPClient, HasRealtimeClient
- Defined in:
- lib/bitflyer/cli/command/summary_command.rb
Instance Method Summary collapse
-
#initialize ⇒ SummaryCommand
constructor
A new instance of SummaryCommand.
-
#run ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Methods included from HasRealtimeClient
Methods included from HasHTTPClient
#http_private_client, #http_public_client
Methods included from Authorization
Constructor Details
#initialize ⇒ SummaryCommand
Returns a new instance of SummaryCommand.
12 13 14 15 16 17 18 19 20 |
# File 'lib/bitflyer/cli/command/summary_command.rb', line 12 def initialize @current_price = 0.0 realtime_client.executions_fx_btc_jpy = lambda { || .each { |m| @current_price = m['price'].to_f } } update_balance end |
Instance Method Details
#run ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bitflyer/cli/command/summary_command.rb', line 22 def run # rubocop:disable Metrics/AbcSize, Metrics/MethodLength $stdout.sync = true print "\e[?25l" Thread.new do loop do update_balance sleep 5 end end puts "\n" * 3 loop do print <<~EOS \e[4F\e[0JCurrent: #{@current_price.to_i.to_s.split_by_comma} Position: #{@position.average.to_s.split_by_comma} * #{@position.size.to_f} Spread: #{spread.to_s.split_by_comma.color_with_number(spread)} Balance: #{(@balance + profit).to_s.split_by_comma.ljust(15, ' ')} (#{profit.to_s.split_by_comma.color_with_number(profit)}) EOS sleep 0.1 end rescue Interrupt # exit ensure print "\e[?25h" end |