lib/wash_trade.rb in SimBot-0.1.13 vs lib/wash_trade.rb in SimBot-0.1.14

- old
+ new

@@ -1,42 +1,44 @@ - module Deamons # Simple process to add wash trades to a market in order to simulate trade matching for QA and dev class WashTrade require 'utils' + def initialize(api, market, freq) @g_count = 1 @range = 1.015 @api = api @market = market @freq = freq Process.fork do Process.daemon(true) pid = Process.pid - redirect("#{pid}.outfile","#{pid}.errfile") + redirect("#{pid}.outfile", "#{pid}.errfile") write_pid_file(pid, "#{pid}.pid") start end puts "SimBot started on #{market} @ freq #{freq}" end def start count = 0 + puts "--------#{@market} -------" loop do vol = rand(0.2...3) - price = move_price + price = aug_price @api.post_order(@market, price, vol, 'sell') delay = (1.00 / @freq) sleep(delay) @api.post_order(@market, price, vol, 'buy') puts "order ##{count} placed" count += 1 + rescue ::StandardError => e + STDERR.puts e + next end - rescue ::StandardError => e - puts e end - def move_price + def aug_price if @g_count > 60 @range = rand(1.003...1.010) @g_count = 0 end @g_count += 1 \ No newline at end of file