class SummaryCommand
Constants
- BUFFER_SIZE
Public Class Methods
new()
click to toggle source
# File lib/bitflyer/cli/command/summary_command.rb, line 12 def initialize @current_price = 0.0 realtime_client.executions_fx_btc_jpy = ->(message) { message.each { |m| @current_price = m['price'].to_f } } update_balance end
Public Instance Methods
run()
click to toggle source
# 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
Private Instance Methods
profit()
click to toggle source
# File lib/bitflyer/cli/command/summary_command.rb, line 50 def profit return 0 if @current_price == 0 @position.profit(@current_price).to_i end
spread()
click to toggle source
# File lib/bitflyer/cli/command/summary_command.rb, line 55 def spread return 0 if @current_price == 0 return 0 if @position.average.to_i == 0 @current_price.to_i - @position.average.to_i end
update_balance()
click to toggle source
# File lib/bitflyer/cli/command/summary_command.rb, line 45 def update_balance @position = Position.new(http_private_client.positions) @balance = http_private_client.collateral['collateral'].to_i end