public void GetLongHistoricPrices(string symbol, string timeframe, int ticks) { _mktData = new Quantum(); Symbol = new Symbol(symbol); session.AttachHandler(mHandler); DateTime dateNow = DateTime.Now; TimeSpan time = Timeframe.StringToTimeSpan(timeframe); DateTime startDate = dateNow.AddMinutes(-ticks * Timeframe.TimeframeToMinutes(timeframe)); O2GRequestFactory factory = session.Session.getRequestFactory(); O2GTimeframeCollection timeframes = factory.Timeframes; O2GTimeframe tfo = timeframes[timeframe]; int counter = ticks; lock (locker) { while (counter > 0) { _completeCounter++; int subticks = (counter >= QSConstants.MAX_FXCM_API_TICKS) ? QSConstants.MAX_FXCM_API_TICKS : counter; O2GRequest request = factory.createMarketDataSnapshotRequestInstrument(symbol, tfo, subticks); factory.fillMarketDataSnapshotRequestTime(request, startDate, startDate.AddMinutes(2 * subticks * Timeframe.TimeframeToMinutes(timeframe))); session.Session.sendRequest(request); startDate = startDate.AddMinutes(subticks * Timeframe.TimeframeToMinutes(timeframe)); counter -= (counter >= QSConstants.MAX_FXCM_API_TICKS) ? QSConstants.MAX_FXCM_API_TICKS : counter; } } int timeCounter = 0; while (!Complete || timeCounter++ < 3000) //max timeout 30 seconds { Thread.Sleep(100); } }
public void Execute() { _session.InitializeSession(); Console.WriteLine("Prepping strategy data..."); PrepDataForStrategies(); Console.WriteLine("Done."); while (true) { if (!_session.LoggedIn) { _session.InitializeSession(); } try { List <Tick> ticks = new List <Tick>(); foreach (Symbol s in _symbolList) { OrderPlacementEngine.OrderObject ob = _opEngine.prepareParamsFromLoginRules(s.SymbolString); Tick t = new Tick(); } foreach (var strat in _strategies) { strat.OnTick(ticks.ToArray()); } } catch (Exception e) { Console.WriteLine(e.Message); } //Sleep specified minutes Console.WriteLine(DateTime.Now + ":Sleeping..."); Thread.Sleep(Timeframe.TimeframeToMinutes(TradeTimeframe) * 60 * 1000); } return; }