public COIN(string symbol, int precision, EXCHANGE exchange, bool Autobuysell, string auth) { scl = new Scorpion_LOG(); ex = exchange; Scorpion_Write.write_success("Starting coin " + symbol + " with precision " + precision); cs.buy_sell_type = Autobuysell; Scorpion_Write.write_success("Automatic buy/sells: " + cs.buy_sell_type); if (!Autobuysell) { Scorpion_Write.write_input("Please enter your buy price preference: "); cs.buy_sell_type_buy_at = Convert.ToDouble(Console.ReadLine()); Scorpion_Write.write_input("Please enter your sell price preference: "); cs.buy_sell_type_sell_at = Convert.ToDouble(Console.ReadLine()); } cs.precision = precision; cs.symbol = symbol; cs.period = "1"; cs.unit = "HOURS"; cs.signal = 0; cs.key = auth; cs.current_balance = 0; cs.EUR_balance = 0; //start_ticker(); return; }
private void start_ticker() { const int interval = 30000; Scorpion_Write.write_success("Running coin ticker/trader " + cs.symbol + " every: " + (interval / 1000) + " seconds"); market_thread = new Timer(coin_thread_start); market_thread.Change(0, interval); return; }
private void sell() { Scorpion_Write.write("Selling " + cs.symbol); cs.sell_id = order_id(); if (cs.current_balance > 0) { Scorpion_Write.write_success("Selling " + cs.current_balance + " of " + cs.symbol + " | ID: " + cs.sell_id); string json_sell = ex.xorder(ref cs.symbol, "SELL", "MARKET", convert_comma_dot(cs.current_balance.ToString()), cs.sell_id); Scorpion_Write.write_success(json_sell); } else { Scorpion_Write.write_error("Unable to sell not enough " + cs.symbol + " to sell at " + cs.current_balance); } scl.write("Signal:" + cs.signal + " Symbol:" + cs.symbol + " Current price:" + cs.current_price + " High:" + cs.high + " Low:" + cs.low + " Tax:" + calculate_tax()); return; }
private void buy() { Scorpion_Write.write("Buying " + cs.symbol); get_min(); cs.buy_id = order_id(); Scorpion_Write.write("Got new order id: " + cs.buy_id); if (cs.EUR_balance > 0 && check_min_buy()) { //buy Scorpion_Write.write_success("Buying " + cs.EUR_balance + " " + ex.bfx_url.PREFFERED_FIAT + " | ID: " + cs.buy_id); string json_buy = ex.xorder(ref cs.symbol, "BUY", "MARKET", convert_comma_dot((cs.EUR_balance / cs.current_price).ToString()), cs.buy_id); Scorpion_Write.write_success(json_buy); } else { Scorpion_Write.write_error("Unable to buy " + cs.symbol + " not enough FIAT " + ex.bfx_url.PREFFERED_FIAT + ": " + cs.EUR_balance + ", Required minimum " + ex.bfx_url.PREFFERED_FIAT + ": " + cs.min); } scl.write("Signal:" + cs.signal + " Symbol:" + cs.symbol + " Current price:" + cs.current_price + " High:" + cs.high + " Low:" + cs.low); return; }