Class: CossBot::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/coss_bot/basic.rb

Direct Known Subclasses

BuyLowSellHigh

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(public_key:, private_key:, logger: Logger.new(STDOUT)) ⇒ Basic

Returns a new instance of Basic.



8
9
10
11
# File 'lib/coss_bot/basic.rb', line 8

def initialize(public_key:, private_key:, logger: Logger.new(STDOUT))
  @exchange = CossApiRubyWrapper::Exchange.new(public_key: public_key, private_key: private_key)
  @logger = logger
end

Instance Attribute Details

#exchangeObject (readonly)

Returns the value of attribute exchange.



5
6
7
# File 'lib/coss_bot/basic.rb', line 5

def exchange
  @exchange
end

#intervalObject

Returns the value of attribute interval.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def interval
  @interval
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def logger
  @logger
end

#lot_sizeObject

Returns the value of attribute lot_size.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def lot_size
  @lot_size
end

#pairObject

Returns the value of attribute pair.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def pair
  @pair
end

#profitObject

Returns the value of attribute profit.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def profit
  @profit
end

#trade_limitObject

Returns the value of attribute trade_limit.



6
7
8
# File 'lib/coss_bot/basic.rb', line 6

def trade_limit
  @trade_limit
end

Instance Method Details

#call(&block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/coss_bot/basic.rb', line 13

def call(&block)
  validate_params!
  loop do
    time = Benchmark.measure { tick(&block) }.real
    wait_time = time > interval ? 0 : interval - time
    sleep(wait_time)
  end
end