Class: SummaryCommand
- Inherits:
-
Object
- Object
- SummaryCommand
- Includes:
- HasHTTPClient, HasRealtimeClient
- Defined in:
- lib/bitflyer/cli/command/summary_command.rb
Constant Summary collapse
- BUFFER_SIZE =
30.freeze
Instance Method Summary collapse
-
#initialize ⇒ SummaryCommand
constructor
A new instance of SummaryCommand.
- #run ⇒ Object
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 = ->() { .each { |m| @current_price = m['price'].to_f } } update_balance end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bitflyer/cli/command/summary_command.rb', line 22 def run $stdout.sync = true Thread.new do while true update_balance sleep 5 end end while true 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 end |