public void ManyInstrumentsArbitrage() { _manyInstruments.Run(); Task.Run(() => { _manyInstruments.ThreadActivity(_log.Service, () => { _bittrex.DoArbitrage(_exchanges, data => _dbRepo.SaveBittrexArbitrageAsync(data)); _matchingEvent.WaitOne(); }, data => { _manyInstruments.Cancel(); _log.WriteError("Terminated due to error: " + data.Message); }, () => { _matchingEvent.Set(); _stopEvent2.Set(); }); }, _manyInstruments.Token); }
public void SingleInstrumentArbitrage() { InitTradingStates(); _singleInstrument.Run(); Task.Run(() => { _singleInstrument.ThreadActivity(_log.Service, () => { try { ArbitrageImpl(); ScalpingBitstamp(); } catch (Exception ex) { _log.WriteError(ex.StackTrace); throw ex; } _matchingEvent.WaitOne(); }, data => { _singleInstrument.Cancel(); _log.WriteError("Terminated due to error: " + data.Message); }, () => { _matchingEvent.Set(); _stopEvent1.Set(); }); }, _singleInstrument.Token); }
public void StartServer(int port) { var ipHostInfo = Dns.Resolve(Dns.GetHostName()); var ipAddress = ipHostInfo.AddressList[0]; _server = new TcpListener(new IPEndPoint(ipAddress, port)); _server.Start(); _cancellation.Run(); }