require "SimBot/version" require 'thor' require 'rubygems' require 'websocket-client-simple' require_relative 'mailer' require_relative 'ApiController/peatio' require_relative 'Deamons/wash_trade' require_relative 'Deamons/simple_mm' module SimBot # CLI for controlling the SimBot class CLI < Thor require 'utils' desc 'wash', 'Start simulation bot parsing in base-url and auth token.' method_option :email, type: :string, default: 'admin@ovex.io', required: true, desc: 'Your OVEX email address' method_option :password, type: :string, default: 'Pass123', required: true, desc: 'Your OVEX password' method_option :peatio_base_url, type: :string, default: 'https://api.review.ovex.io/api/v2', desc: 'Peatio API base URL' method_option :barong_base_url, type: :string, default: 'https://auth.review.ovex.io/api/v1', desc: 'Barong API base URL' method_option :app_id, type: :string, default: 'ceca08fbc83c2fb4eb53bb026489', desc: 'Peatio applicaiton id from Barong' method_option :market, type: :string, default: 'bchbtc', required: false, desc: 'OVEX market for SimBot to interact with' method_option :freq, type: :numeric, default: 1, desc: 'Frequency for trades to be added' def wash api = ApiController::Peatio.new(options[:peatio_base_url], options[:barong_base_url], options[:app_id], options[:email], options[:password]) Deamons::WashTrade.new(api, options[:market], options[:freq]) end desc 'mm', 'Starts a market maker' method_option :email, type: :string, default: 'admin@ovex.io', required: true, desc: 'Your OVEX email address' method_option :password, type: :string, default: 'Pass123', required: true, desc: 'Your OVEX password' method_option :peatio_base_url, type: :string, default: 'https://api.review.ovex.io/api/v2', desc: 'Peatio API base URL' method_option :barong_base_url, type: :string, default: 'https://auth.review.ovex.io/api/v1', desc: 'Barong API base URL' method_option :app_id, type: :string, default: 'ceca08fbc83c2fb4eb53bb026489', desc: 'Peatio applicaiton id from Barong' method_option :market, type: :string, default: 'bchbtc', required: false, desc: 'OVEX market for SimBot to interact with' def mm api = ApiController::Peatio.new(options[:peatio_base_url], options[:barong_base_url], options[:app_id], options[:email], options[:password]) Deamons::SimpleMm.new(api, options[:market]) end desc 'list', 'Return list of running processes' def list puts Dir['*.pid'] end desc 'stop pid', 'stop a running process with the given pid' def stop(pid) Utils.kill_process(pid) end desc 'test_ws', 'connect to web socket and test it is working correctly' def test_ws # Create websocket connection. ws = WebSocket::Client::Simple.connect("ws://ws.api.review.ovex.io:80") puts("here") # Called on messaged from websocket server. ws.on(:message) do |msg| puts msg.data end # Called if connection to server has been opened. ws.on(:open) do # Authenticate. msg = "{ \"jwt\": \"Bearer ngrgiuerubrgeiru\"}" ws.send msg end end desc 'quote market', 'get the quote for the given market e.g. btc/eth' def quote(market) puts "#{market}: #{Utils.quote(market)}" end desc 'cmc_data outfile', 'export coin market cap data to spread sheet' def cmc_data(outfile) data = Utils.cmc_data Utils.write_to_spreadsheet(data, outfile) end desc 'send_emails data_file template_file', 'Sends emails based on the data in the provided data_file' method_option :email, type: :string, default: 'jon@ovex.io', required: true, desc: 'Your email address' method_option :password, type: :string, required: true, desc: 'Your password' def send_emails(data_file, template_file) Utils.send_mail(data_file, template_file, options[:email], options[:password]) end end end