Sha256: 4ab84cb7111c8b20139e7042843c3056ff91c4281b8b796c1c236dc110d716c6
Contents?: true
Size: 838 Bytes
Versions: 2
Compression:
Stored size: 838 Bytes
Contents
# frozen_string_literal: true module CossBot class Basic attr_reader :exchange attr_accessor :interval, :lot_size, :profit, :pair, :trade_limit def initialize(public_key:, private_key:) @exchange = CossApiRubyWrapper::Exchange.new(public_key: public_key, private_key: private_key) end 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 private def validate_params! return if !trade_limit.nil? && pair.to_s =~ /\A\w+_\w+\Z/ && profit.to_f.positive? && lot_size.to_f.positive? && interval.to_i > 1 raise ArgumentError, 'Some params are invalid' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coss_bot-0.1.2 | lib/coss_bot/basic.rb |
coss_bot-0.1.1 | lib/coss_bot/basic.rb |