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' require_relative 'Deamons/geth' require_relative 'Deamons/ngrok' require_relative 'Deamons/bitcoind' require_relative 'Deamons/bitcoind-abc' require_relative 'Deamons/litecoind' module SimBot # CLI for controlling the SimBot class CLI < Thor require 'utils' desc 'wash', 'Start simulation bot.' 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: 'btcbch', required: false, desc: 'OVEX market for SimBot to interact with' method_option :freq, type: :numeric, default: 1, desc: 'Frequency for trades to be added' method_option :vol, type: :numeric, default: 0.5, desc: 'Volume 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], options[:vol]) end desc 'wash', 'Start simulation bot.' method_option :jwt, type: :string, required: true, desc: 'Your OVEX api key' def test peatio = Peatio::Client.new(options[:jwt],'www.ovex.io') peatio.orders('btczar')[bids] 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 'geth', 'Start a geth daemon light node in the background' def eth Deamons::Geth.new end desc 'btc', 'Start a bitcoin testnet daemon full node in the background' def btc Deamons::Bitcoind.new end desc 'bch', 'Start a bitcoin-abc (cash) testnet daemon full node in the background' def bch Deamons::BitcoinCashd.new end desc 'ltc', 'Start a litecoin testnet daemon full node in the background' def ltc Deamons::Litecoind.new end desc 'ngrok', 'Start a geth damon light node in the background' def ngrok Deamons::Ngrok.new 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)}" Utils.new_sheet('template.xls') 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