Class: SummaryCommand
- Inherits:
-
Object
- Object
- SummaryCommand
- Includes:
- HasHTTPClient, HasRealtimeClient
- Defined in:
- lib/bitflyer/cli/command/summary_command.rb
Constant Summary collapse
- BUFFER_SIZE =
30
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.
14 15 16 17 18 19 20 21 22 |
# File 'lib/bitflyer/cli/command/summary_command.rb', line 14 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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bitflyer/cli/command/summary_command.rb', line 24 def run # rubocop:disable Metrics/AbcSize, Metrics/MethodLength $stdout.sync = true Thread.new do loop do update_balance sleep 5 end end loop do print " \\e[4F\\e[0JCurrent: \#{@current_price.to_i.to_s.split_by_comma}\n Position: \#{@position.average.to_s.split_by_comma} * \#{@position.size.to_f}\n Spread: \#{spread.to_s.split_by_comma.color_with_number(spread)}\n Balance: \#{(@balance + profit).to_s.split_by_comma.ljust(15, ' ')} (\#{profit.to_s.split_by_comma.color_with_number(profit)})\n EOS\n sleep 0.1\n end\nend\n" |