static void Main(string[] args) { // Establish an event handler to process CTRL-C Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler); ServicePointManager.DefaultConnectionLimit = 200; Console.WriteLine("DefaultConnectionLimit:" + ServicePointManager.DefaultConnectionLimit); BinanceClient bClient = new BinanceClient(); bClient.UpdateExchangeInfo(); if (!BinanceSpot.settings.KeysSet) { Logger.ConsoleOut("API keys are not set! Please set the keys in the Config.txt"); } while (!Terminated) { Thread.Sleep(1000); bClient.UpdatePrices(); if (BinanceSpot.CheckUsedWeight()) { bClient.TestSequence(); } Console.Write("\r Working ... Orders: {0} UsedWeight: {1}" + " ", algo.workersCount, BinanceSpot.used_weight); algo.checkState(); } Console.WriteLine("\nWaiting workers...."); algo.waitWorkers(); }
private void Run() { Random rnd = new Random(); Thread.Sleep(rnd.Next(100, 1500)); // dont push all orders at once BinanceClient bClient = new BinanceClient(); Spot.BinanceOrder order = bClient.PlaceMinBuyOrder(BinanceSpot.RandomSymbol()); if (order == null) { return; } Interlocked.Increment(ref workersCount); for (int i = 0; i < 50; i++) { if (!Terminated) { DoSleep(6000); bClient.CheckOrder(order); } } bClient.CancelOrder(order); Thread.Sleep(500); Interlocked.Decrement(ref workersCount); }
public void checkState() { if ((workersCount == 0) & BinanceSpot.settings.KeysSet & BinanceSpot.CheckUsedWeight()) { newIteration(); } }
public void TestSequence() { GetBalances(); UpdatePrices(); Spot.Symbol sym = BinanceSpot.RandomSymbol(); GetKLines(sym); GetOrderBook(sym); }
public void UpdatePrices() { var rawResult = DoRestRequest("ticker/bookTicker"); if (lastResult == HttpStatusCode.OK) { BinanceSpot.updatePrices(rawResult); } }
public void UpdateExchangeInfo() { var rawResult = DoRestRequest("exchangeInfo"); if (lastResult == HttpStatusCode.OK) { BinanceSpot.updateSymbols(rawResult); } UpdatePrices(); }