public static void BacktestBinanceTrades() { var msg1 = new ConsoleMessenger(); /*var symbols = new string[] { "NEOBTC", "NEOETH", "TRXBTC", "TRXETH", "XMRBTC", "XMRETH", "XRPBTC", "XRPETH", * "ZECBTC", "ZECETH", "ZRXBTC", "ZRXETH" , "ASTBTC", "ASTETH", "LTCBNB", "LTCBTC", "LTCETH", "LTCUSDT" * };*/ var symbols = new string[] { "ADABTC", "ADAETH", "ADXBNB", "ADXBTC", "ADXETH", "AEBNB", "AEBTC", "AEETH", "AIONBNB", "AIONBTC", "AIONETH", "AMBBNB", "AMBBTC", "AMBETH", "APPCBNB", "APPCBTC", "APPCETH", "ARKBTC", "ARKETH", "ARNBTC", "ARNETH", "ASTBTC", "ASTETH", "BATBNB", "BATBTC", "BATETH", "BCCBNB", "BCCBTC", "BCCETH", "BCCUSDT", "BCDBTC", "BCDETH", "BCPTBNB", "BCPTBTC", "BCPTETH", "BLZBNB", "BLZBTC", "BLZETH", "BNBBTC", "BNBETH", "BNBUSDT", "BNTBTC", "BNTETH", "BQXBTC", "BQXETH", "BRDBNB", "BRDBTC", "BRDETH", "BTCUSDT", "BTGBTC", "BTGETH", "BTSBNB", "BTSBTC", "BTSETH", "CDTBTC", "CDTETH", "CHATBTC", "CHATETH", "CMTBNB", "CMTBTC", "CMTETH", "CNDBNB", "CNDBTC", "CNDETH", "CTRBTC", "CTRETH", "DASHBTC", "DASHETH", "DGDBTC", "DGDETH", "DLTBNB", "DLTBTC", "DLTETH", "DNTBTC", "DNTETH", "EDOBTC", "EDOETH", "ELFBTC", "ELFETH", "ENGBTC", "ENGETH", "ENJBTC", "ENJETH", "EOSBTC", "EOSETH", "ETCBTC", "ETCETH", "ETHBTC", "ETHUSDT", "EVXBTC", "EVXETH", "FUELBTC", "FUELETH", "FUNBTC", "FUNETH", "GASBTC", "GTOBNB", "GTOBTC", "GTOETH", "GVTBTC", "GVTETH", "GXSBTC", "GXSETH", "HSRBTC", "HSRETH", "ICNBTC", "ICNETH", "ICXBNB", "ICXBTC", "ICXETH", "INSBTC", "INSETH", "IOSTBTC", "IOSTETH", "IOTABNB", "IOTABTC", "IOTAETH", "KMDBTC", "KMDETH", "KNCBTC", "KNCETH", "LENDBTC", "LENDETH", "LINKBTC", "LINKETH", "LRCBTC", "LRCETH", "LSKBNB", "LSKBTC", "LSKETH", "LTCBNB", "LTCBTC", "LTCETH", "LTCUSDT", "LUNBTC", "LUNETH", "MANABTC", "MANAETH", "MCOBNB", "MCOBTC", "MCOETH", "MDABTC", "MDAETH", "MODBTC", "MODETH", "MTHBTC", "MTHETH", "MTLBTC", "MTLETH", "NANOBNB", "NANOBTC", "NANOETH", "NAVBNB", "NAVBTC", "NAVETH", "NEBLBNB", "NEBLBTC", "NEBLETH", "NEOBNB", "NEOBTC", "NEOETH", "NEOUSDT", "NULSBNB", "NULSBTC", "NULSETH", "OAXBTC", "OAXETH", "OMGBTC", "OMGETH", "OSTBNB", "OSTBTC", "OSTETH", "PIVXBNB", "PIVXBTC", "PIVXETH", "POEBTC", "POEETH", "POWRBNB", "POWRBTC", "POWRETH", "PPTBTC", "PPTETH", "QSPBNB", "QSPBTC", "QSPETH", "QTUMBTC", "QTUMETH", "RCNBNB", "RCNBTC", "RCNETH", "RDNBNB", "RDNBTC", "RDNETH", "REQBTC", "REQETH", "RLCBNB", "RLCBTC", "RLCETH", "SALTBTC", "SALTETH", "SNGLSBTC", "SNGLSETH", "SNMBTC", "SNMETH", "SNTBTC", "SNTETH", "STEEMBNB", "STEEMBTC", "STEEMETH", "STORJBTC", "STORJETH", "STRATBTC", "STRATETH", "SUBBTC", "SUBETH", "TNBBTC", "TNBETH", "TNTBTC", "TNTETH", "TRIGBNB", "TRIGBTC", "TRIGETH", "TRXBTC", "TRXETH", "VENBNB", "VENBTC", "VENETH", "VIABNB", "VIABTC", "VIAETH", "VIBBTC", "VIBEBTC", "VIBEETH", "VIBETH", "WABIBNB", "WABIBTC", "WABIETH", "WAVESBNB", "WAVESBTC", "WAVESETH", "WINGSBTC", "WINGSETH", "WTCBNB", "WTCBTC", "WTCETH", "XLMBNB", "XLMBTC", "XLMETH", "XMRBTC", "XMRETH", "XRPBTC", "XRPETH", "XVGBTC", "XVGETH", "XZCBNB", "XZCBTC", "XZCETH", "YOYOBNB", "YOYOBTC", "YOYOETH", "ZECBTC", "ZECETH", "ZRXBTC", "ZRXETH" }; foreach (string s in symbols) { var b1 = new BinanceTradeMACD(binance, s, msg1); b1.StartTrade(0.1M, 1, tradeLive: false, backTestOnly: true); var b5 = new BinanceTradeMACD(binance, s, msg1); b5.StartTrade(0.1M, 5, tradeLive: false, backTestOnly: true); var b15 = new BinanceTradeMACD(binance, s, msg1); b15.StartTrade(0.1M, 15, tradeLive: false, backTestOnly: true); var b30 = new BinanceTradeMACD(binance, s, msg1); b30.StartTrade(0.1M, 30, tradeLive: false, backTestOnly: true); var b60 = new BinanceTradeMACD(binance, s, msg1); b60.StartTrade(0.1M, 60, tradeLive: false, backTestOnly: true); } }
public static void TestBinanceTrades() { // Create Prowl messaging client var msg1 = new Tools.Messaging.Prowl.ProwlClient(Crypto.ApiKeys["PROWL"].ApiKey, "BINANCE", "MACD"); var assetInfo = binance.GetAssetInfo(); //assetInfo.Select(xkv => xkv).OrderBy(xkv => xkv.Key).ToList().ForEach(xai => cout(xai.Value.ToDisplay())); // Dictionary of symbols/intervals to trade var li = new string[, ] { { "BCCBTC", "15" }, { "BCCETH", "1" }, { "BCCETH", "5" }, { "BCCETH", "15" }, { "BCCUSDT", "1" }, { "BCCUSDT", "5" }, { "BCCUSDT", "15" }, { "BNBUSDT", "5" }, { "BTCUSDT", "5" }, { "DASHETH", "1" }, { "DASHETH", "15" }, { "DGDETH", "1" }, { "DGDETH", "30" }, { "ETHUSDT", "1" }, { "ETHUSDT", "5" }, { "ETHUSDT", "15" }, { "LTCETH", "60" }, { "LTCUSDT", "1" }, { "LTCUSDT", "5" }, { "LTCUSDT", "15" }, { "LTCUSDT", "30" }, { "LTCUSDT", "60" }, { "NEOETH", "60" }, { "NEOUSDT", "15" }, { "XMRETH", "5" }, { "XMRETH", "60" }, { "ZECETH", "1" }, { "ZECETH", "30" }, { "ZECETH", "60" } }; // Iterate through each symbol/interval and create a new Trade (and start the trade) var trd = new Dictionary <string, BinanceTradeMACD>(); for (int i = 0; i < li.GetLength(0); ++i) { cout("==============================================================================================="); string symbol = li[i, 0]; int barInterval = int.Parse(li[i, 1]); cout("Initiating BINANCE MACD '{0}' trade, {1} minutes", symbol, barInterval); var id = string.Format("{0}:{1}", symbol, barInterval); trd[id] = new BinanceTradeMACD(binance, symbol, msg1); trd[id].Debug = true; decimal stepSize = assetInfo[symbol].stepSize; trd[id].StartTrade(stepSize, barInterval, tradeLive: false, backTestOnly: false); cout("==============================================================================================="); } return; /*var b60neo = new BinanceTradeMACD(binance, "NEOETH", msg1); * b60neo.StartTrade(0.2M, 60, tradeLive: true, backTestOnly: false); * var b15xmr = new BinanceTradeMACD(binance, "XMRETH", msg1); * b15xmr.StartTrade(0.15M, 15, tradeLive: true, backTestOnly: false); * var b60xmr = new BinanceTradeMACD(binance, "XMRETH", msg1); * b60xmr.StartTrade(0.15M, 60, tradeLive: true, backTestOnly: false); * var b30zec = new BinanceTradeMACD(binance, "ZECETH", msg1); * b30zec.StartTrade(0.11M, 30, tradeLive: true, backTestOnly: false); * var b60zec = new BinanceTradeMACD(binance, "ZECETH", msg1); * b60zec.StartTrade(0.11M, 60, tradeLive: true, backTestOnly: false); * var b30ltc = new BinanceTradeMACD(binance, "LTCETH", msg1); * b30ltc.StartTrade(0.2M, 30, tradeLive: true, backTestOnly: false); * var b60ltc = new BinanceTradeMACD(binance, "LTCETH", msg1); * b60ltc.StartTrade(0.2M, 60, tradeLive: true, backTestOnly: false);*/ /*ApiCredentials creds = m_security.ApiKeys["BINANCE"]; * var apiClient = new CryptoAPIs.Exchange.Clients.Binance.ApiClient(creds.ApiKey, creds.ApiSecret); * var bn = new CryptoAPIs.Exchange.Clients.Binance.BinanceClient(apiClient); * var ai = bn.GetAccountInfo().Result; * Console.WriteLine("{0} {1} {2} {3}", ai.BuyerCommission, ai.SellerCommission, ai.MakerCommission, ai.TakerCommission); * * var bookTicker = bn.GetOrderBookTicker().Result; * foreach (var obt in bookTicker) * { * if (obt.Symbol.Contains("NEO") || obt.Symbol.Contains("XMR")) * Console.WriteLine(obt.Symbol); * } * * var kl = bn.GetCandleSticks("NEOETH", Exchange.Clients.Binance.TimeInterval.Hours_1).Result; * foreach (var k in kl) * { * Console.WriteLine("{0} {1} {2} {3} {4}", k.CloseTime.ToDateTimeString(), k.Open, k.High, k.Low, k.Close); * } * //bn.ListenKlineEndpoint("NEOETH", Exchange.BinanceX.TimeInterval.Minutes_1, HandleKline); * * Thread.Sleep(120000); * return;*/ }