public AutopilotTradingForm(SQLiteDatabase db, ITradingAPI tradingApi, IndicatorCollection indicators, Strategy strat, ExecutionStrategy execStrat, string instrument) { priceHistoryDatabase = db; new Thread(delegate() { streamer = new StreamingModul(indicators, strat, execStrat, tradingApi, instrument); //Prepare streamer List <TickData> tickdataToPrepare = priceHistoryDatabase.getPrices(Timestamp.getNow() - 24 * 60 * 60 * 1000, Timestamp.getNow(), instrument); foreach (TickData tick in tickdataToPrepare) { streamer.prepareDataWithoutTrading(tick); } ssiApi = new SSI_Downloader(AvailableInstruments.allInstruments); ssiApi.sourceDataArrived += sourceDataArrived; ssiApi.start(); webApi = new FXCMRatesDownloader(); webApi.sourceDataArrived += tickdataArrived; webApi.start(); while (true) { if (continueLiveTradingThread) { streamer.doTradingTickWithoutNewData(Timestamp.getNow()); Thread.Sleep(1000 * 10); } } }).Start(); InitializeComponent(); }
private void recordDataBtn_Click(object sender, EventArgs e) { ssiApi = new SSI_Downloader(AvailableInstruments.allInstruments); ssiApi.sourceDataArrived += sourceDataArrived; ssiApi.start(); webApi = new FXCMRatesDownloader(); webApi.sourceDataArrived += tickdataArrived; webApi.start(); updateLabelTimer.Start(); recordDataBtn.Enabled = false; }