private static void historicalDataRequests(EClientSocket client) { //Console.WriteLine(account.Email); /*** Requesting historical data ***/ //! [reqhistoricaldata] if (tradeConfig.Historical) { String queryTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); foreach (StockConfig sc in tradeConfig.Stocks) { client.reqHistoricalData(sc.Id, ContractSamples.GetContract(sc.Symbol), queryTime, "9 M", "1 min", "MIDPOINT", 1, 1, false, null); } //client.reqHistoricalData(1002, ContractSamples.USStock2(), queryTime, "9 M", "1 min", "MIDPOINT", 1, 1, false, null); //! [reqhistoricaldata] //Thread.Sleep(2000); /*** Canceling historical data requests ***/ //client.cancelHistoricalData(1001); } }
private static void realTimeBars(EClientSocket client) { /*** Requesting real time bars ***/ if (tradeConfig.Realtime) { #region Realtime with today's RSI String queryTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); foreach (StockConfig sc in tradeConfig.Stocks) { client.reqHistoricalData(sc.Id, ContractSamples.GetContract(sc.Symbol), queryTime, "1 D", "1 min", "MIDPOINT", 1, 1, false, null); } //client.reqHistoricalData(1001, ContractSamples.USStock(), queryTime, "1 D", "1 min", "MIDPOINT", 1, 1, false, null); Thread.Sleep(10000); //client.cancelHistoricalData(1001); foreach (StockConfig sc in tradeConfig.Stocks) { client.reqRealTimeBars(sc.Id, ContractSamples.GetContract(sc.Symbol), 5, "MIDPOINT", true, null); } //client.reqRealTimeBars(1001, ContractSamples.USStock(), 5, "MIDPOINT", true, null); #endregion } if (tradeConfig.AfterRTH) { #region After RTH trading foreach (StockConfig sc in tradeConfig.Stocks) { client.reqRealTimeBars(sc.Id, ContractSamples.GetContract(sc.Symbol), 5, "MIDPOINT", false, null); } //client.reqRealTimeBars(1001, ContractSamples.USStock(), 5, "MIDPOINT", false, null); #endregion } //client.reqRealTimeBars(1002, ContractSamples.USOptionContract2(), 5, "MIDPOINT", true, null); //! [reqrealtimebars] //Thread.Sleep(2000); /*** Canceling real time bars ***/ //! [cancelrealtimebars] //client.cancelRealTimeBars(3001); //! [cancelrealtimebars] }