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 AccountInformation(FXSession session) { this.session = session; mHandler = AccountInformationReceived; session.AttachHandler(mHandler); }