public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.OpenOrder: handleOpenOrder((OpenOrderMessage)message); break; case MessageType.OpenOrderEnd: break; case MessageType.OrderStatus: handleOrderStatus((OrderStatusMessage)message); break; case MessageType.ExecutionData: HandleExecutionMessage((ExecutionMessage)message); break; case MessageType.CommissionsReport: HandleCommissionMessage((CommissionMessage)message); break; case MessageType.SoftDollarTiers: HandleSoftDollarTiers(message); break; } }
public void UpdateUI(IBMessage message) { if (message is ContractDetailsMessage) { Contract contract = ((ContractDetailsMessage)message).ContractDetails.Summary; if (contract.Right.Equals("C")) { int mktDataRequest = currentMktDataCallRequest++; ibClient.ClientSocket.reqMktData(mktDataRequest, contract, "", useSnapshot); UpdateContractDetails(callGrid, (mktDataRequest - OPTIONS_DATA_CALL_BASE), contract); } else { int mktDataRequest = currentMktDataPutRequest++; ibClient.ClientSocket.reqMktData(mktDataRequest, contract, "", useSnapshot); UpdateContractDetails(putGrid, (mktDataRequest - OPTIONS_DATA_PUT_BASE), contract); } } else if (message is MarketDataMessage) { MarketDataMessage mktDataMsg = (MarketDataMessage)message; if (mktDataMsg.RequestId < OPTIONS_DATA_PUT_BASE) { UpdateOptionGridTick(callGrid, (mktDataMsg.RequestId - OPTIONS_DATA_CALL_BASE), mktDataMsg); } else { UpdateOptionGridTick(putGrid, (mktDataMsg.RequestId - OPTIONS_DATA_PUT_BASE), mktDataMsg); } } }
protected void PopulateGrid(IBMessage message) { HistoricalDataMessage bar = (HistoricalDataMessage)message; RealTimeBarMessage rtBar = (RealTimeBarMessage)message; DateTime start = new DateTime(1970, 1, 1, 0, 0, 0); DateTime dt = start.AddMilliseconds(rtBar.Timestamp * 1000).ToLocalTime(); String strDT = String.Format("{0:yyyyMMdd HH:mm:ss}", dt); gridView.Rows.Add(1); //gridView[0, gridView.Rows.Count - 1].Value = bar.Date; gridView[0, gridView.Rows.Count - 1].Value = strDT; gridView[1, gridView.Rows.Count - 1].Value = bar.Close; gridView[2, gridView.Rows.Count - 1].Value = bar.Open; gridView[3, gridView.Rows.Count - 1].Value = bar.High; gridView[4, gridView.Rows.Count - 1].Value = bar.Low; gridView[5, gridView.Rows.Count - 1].Value = rtBar.LongVolume; /* * gridView[0, gridView.Rows.Count - 1].Value = bar.Date; * gridView[1, gridView.Rows.Count - 1].Value = bar.Open; * gridView[2, gridView.Rows.Count - 1].Value = bar.High; * gridView[3, gridView.Rows.Count - 1].Value = bar.Low; * gridView[4, gridView.Rows.Count - 1].Value = bar.Close; * gridView[5, gridView.Rows.Count - 1].Value = bar.Volume; * gridView[6, gridView.Rows.Count - 1].Value = bar.Wap; * */ }
public override void UpdateUI(IBMessage message) { MarketDataMessage dataMessage = (MarketDataMessage)message; ListView grid = (ListView)uiControl; if (message is TickPriceMessage) { TickPriceMessage priceMessage = (TickPriceMessage)message; switch (dataMessage.Field) { case 1: marketDataList[GetIndex(dataMessage.RequestId)].Bid = priceMessage.Price; break; case 2: marketDataList[GetIndex(dataMessage.RequestId)].Ask = priceMessage.Price; break; case 9: marketDataList[GetIndex(dataMessage.RequestId)].Close = priceMessage.Price; break; default: break; } grid.Items.Refresh(); } }
private void HandleSoftDollarTiers(IBMessage softDollarTiersMessage) { //orderDialog.HandleIncomingMessage(softDollarTiersMessage); var z = (ContractDetailsMessage)softDollarTiersMessage; //MessageBox.Show("private void HandleSoftDollarTiers(IBMessage softDollarTiersMessage): " + z.ContractDetails.Summary.Symbol + " successfully found at: " + z.ContractDetails.Summary.PrimaryExch + " exchange"); }
public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.AccountSummary: HandleAccountSummary((AccountSummaryMessage)message); break; case MessageType.AccountSummaryEnd: HandleAccountSummaryEnd(); break; case MessageType.AccountValue: HandleAccountValue((AccountValueMessage)message); break; case MessageType.PortfolioValue: HandlePortfolioValue((UpdatePortfolioMessage)message); break; case MessageType.AccountDownloadEnd: break; case MessageType.Position: HandlePosition((PositionMessage)message); break; case MessageType.PositionEnd: break; } }
public void UpdateUI(IBMessage message) { if (message is ContractDetailsMessage) { Contract contract = ((ContractDetailsMessage)message).ContractDetails.Summary; if (contract.Right != null) { if (contract.Right.Equals("C")) { int mktDataRequest = currentMktDataCallRequest++; ibClient.ClientSocket.reqMktData(mktDataRequest, contract, "", useSnapshot, new List <TagValue>()); UpdateContractDetails(callGrid, (mktDataRequest - OPTIONS_DATA_CALL_BASE), contract); } else { int mktDataRequest = currentMktDataPutRequest++; ibClient.ClientSocket.reqMktData(mktDataRequest, contract, "", useSnapshot, new List <TagValue>()); UpdateContractDetails(putGrid, (mktDataRequest - OPTIONS_DATA_PUT_BASE), contract); } } } else if (message is MarketDataMessage) { MarketDataMessage mktDataMsg = (MarketDataMessage)message; if (mktDataMsg.RequestId < OPTIONS_DATA_PUT_BASE) { UpdateOptionGridTick(callGrid, (mktDataMsg.RequestId - OPTIONS_DATA_CALL_BASE), mktDataMsg); } else { UpdateOptionGridTick(putGrid, (mktDataMsg.RequestId - OPTIONS_DATA_PUT_BASE), mktDataMsg); } } else if (message is SecurityDefinitionOptionParameterMessage) { SecurityDefinitionOptionParameterMessage secDefOptParamMsg = (SecurityDefinitionOptionParameterMessage)message; var key = new SecDefOptParamKey(secDefOptParamMsg.Exchange, secDefOptParamMsg.UnderlyingConId, secDefOptParamMsg.TradingClass, secDefOptParamMsg.Multiplier); if (!secDefOptParamGroups.ContainsKey(key)) { optionParamsListView.Groups.Add(secDefOptParamGroups[key] = new ListViewGroup(key + "")); } var strikes = secDefOptParamMsg.Strikes.ToArray(); var expriations = secDefOptParamMsg.Expirations.ToArray(); var n = Math.Max(strikes.Length, expriations.Length); for (int i = 0; i < n; i++) { var item = new ListViewItem(new[] { i < expriations.Length ? expriations[i] : "", i < strikes.Length ? strikes[i] + "" : "" }) { Group = secDefOptParamGroups[key] }; optionParamsListView.Items.Add(item); } } }
public void test_isRTBarMergeNeed() { DateTime afterSetTime = new DateTime(2015, 11, 21, 9, 15, 55, DateTimeKind.Local); DateTime afterSetTime2 = new DateTime(2015, 11, 21, 9, 16, 0, DateTimeKind.Local); DateTime beforeSetTime = new DateTime(2015, 11, 21, 9, 10, 55, DateTimeKind.Local); DateTime beforeSetTime2 = new DateTime(2015, 11, 21, 9, 11, 0, DateTimeKind.Local); IBMessage afterSetTimeMessage = createTimeMessage(afterSetTime); IBMessage beforeSetTimeMessage = createTimeMessage(beforeSetTime); IBMessage afterSetTimeMessage2 = createTimeMessage(afterSetTime2); IBMessage beforeSetTimeMessage2 = createTimeMessage(beforeSetTime2); String strTickerStartTimeOfDay = "09:15:00"; //[Test : method return true, message time equal to RtbDataStartTime] IAppMDManager appMDManager = getAppRTBSynchronizer_for_isRTBarMergeNeed(afterSetTime); AppRTBSynchronizer synchronizer = new AppRTBSynchronizer(appMDManager); //IAppRTBSynchronizer synchronizer = appMDManager.getAppRTBSynchronizer(); Assert.AreEqual(true, synchronizer.isRTBarMergeNeed(strTickerStartTimeOfDay)); //[Test : method return true, message time later than RtbDataStartTime] appMDManager = getAppRTBSynchronizer_for_isRTBarMergeNeed(afterSetTime); synchronizer = new AppRTBSynchronizer(appMDManager); Assert.AreEqual(true, synchronizer.isRTBarMergeNeed(strTickerStartTimeOfDay)); //[Test : method return false, RtbDataStartTime before the strTickerStartTimeOfDay] appMDManager = getAppRTBSynchronizer_for_isRTBarMergeNeed(beforeSetTime); synchronizer = new AppRTBSynchronizer(appMDManager); Assert.AreEqual(false, synchronizer.isRTBarMergeNeed(strTickerStartTimeOfDay)); //[Test : method return false, RtbDataStartTime before the strTickerStartTimeOfDay] appMDManager = getAppRTBSynchronizer_for_isRTBarMergeNeed(beforeSetTime); synchronizer = new AppRTBSynchronizer(appMDManager); Assert.AreEqual(false, synchronizer.isRTBarMergeNeed(strTickerStartTimeOfDay)); }
public void test_isThisMessageStartOfMinute() { IBMessage message = createStartOfMinuteMessage(); Assert.AreEqual(true, MarketDataUtil.isThisMessageStartOfMinute(message)); message = createEndOfMinuteMessage(); Assert.AreEqual(false, MarketDataUtil.isThisMessageStartOfMinute(message)); }
public void test_buildAndUpdateSynMinuteBar_negative() { DateTime time1 = new DateTime(2015, 10, 21, 10, 0, 5, DateTimeKind.Local); IBMessage message1 = createMessage_for_isRTBarProcessStart_Open(time1); //[Test: invalid initial action test, currentTempRTBar is null, currentCompleteRTBar is null and the time is not in 0 second.] AppMDManager appMDManager = createManager_buildAndUpdateSynMinuteBar_begin(); appMDManager.buildAndUpdateSynMinuteBar(message1); Assert.IsNull(appMDManager.currentTempRTBar); Assert.IsNull(appMDManager.currentCompleteRTBar); }
public void HandleMessage(IBMessage message) //This is the "UI entry point" and as such will handle the UI update by another thread { if (this.InvokeRequired) { MessageHandlerDelegate callback = new MessageHandlerDelegate(HandleMessage); this.Invoke(callback, new object[] { message }); } else { UpdateUI(message); } }
public void HandleMessage(IBMessage message) { if (this.InvokeRequired) { MessageHandlerDelegate callback = new MessageHandlerDelegate(HandleMessage); this.Invoke(callback, new object[] { message }); } else { UpdateUI(message); } }
public override void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.HistoricalData: historicalData.Add((HistoricalDataMessage)message); break; case MessageType.HistoricalDataEnd: PaintChart(); break; } }
public static Boolean isThisMessageStartOfMinute(IBMessage message) { RealTimeBarMessage rtBar = (RealTimeBarMessage)message; DateTime start = new DateTime(1970, 1, 1, 0, 0, 0); DateTime current = start.AddMilliseconds(rtBar.Timestamp * 1000).ToLocalTime(); if (current.Second == 0) { return(true); } return(false); }
public Boolean updateTimeBarSeries(IBMessage message) { Boolean isAdded = false; if ((!isDataMerged && getNeedMergeFlag()) || !getNeedMergeFlag()) { return(isAdded); } Series <DateTime, MarketDataElement> TimeBarSeries = appMDManager.getTimeBarSeries(); if (TimeBarSeries == null) { return(isAdded); } HistoricalDataMessage histMessage = (HistoricalDataMessage)message; double h = Convert.ToDouble(histMessage.High); double l = Convert.ToDouble(histMessage.Low); double o = Convert.ToDouble(histMessage.Open); double c = Convert.ToDouble(histMessage.Close); double vol = Convert.ToDouble(histMessage.Volume); DateTime time = DateTime.ParseExact(histMessage.Date.Trim(), "yyyyMMdd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal); MarketDataElement currentHsiData = MarketDataUtil.createHLOC(time, "HLOC", "HSI", "FUT"); currentHsiData.volume = vol; currentHsiData.time = time; if (TimeBarSeries == null) { TimeBarSeries = new SeriesBuilder <DateTime, MarketDataElement>() { { time, currentHsiData } }.Series; isAdded = true; } else { MarketDataElement element = TimeBarSeries.GetAt(TimeBarSeries.KeyCount - 1); if (!TimeBarSeries.ContainsKey(time)) { TimeBarSeries = TimeBarSeries.Merge(new SeriesBuilder <DateTime, MarketDataElement>() { { time, currentHsiData } }.Series); isAdded = true; } } return(isAdded); }
public override void UpdateUI(IBMessage message) { ScannerMessage scannMessage = (ScannerMessage)message; DataGridView grid = (DataGridView)uiControl; rowCounter++; grid.Rows.Add(); grid[RANK_IDX, rowCounter].Value = scannMessage.Rank; grid[CONTRACT_IDX, rowCounter].Value = Utils.ContractToString(scannMessage.ContractDetails.Summary); grid[DISTANCE_IDX, rowCounter].Value = scannMessage.Distance; grid[BENCHMARK_IDX, rowCounter].Value = scannMessage.Benchmark; grid[PROJECTION_IDX, rowCounter].Value = scannMessage.Projection; grid[LEGS_IDX, rowCounter].Value = scannMessage.LegsStr; }
protected void PopulateGrid(IBMessage message) { HistoricalDataMessage bar = (HistoricalDataMessage)message; gridView.Rows.Add(1); gridView[0, gridView.Rows.Count - 1].Value = bar.Date; gridView[1, gridView.Rows.Count - 1].Value = bar.Open; gridView[2, gridView.Rows.Count - 1].Value = bar.High; gridView[3, gridView.Rows.Count - 1].Value = bar.Low; gridView[4, gridView.Rows.Count - 1].Value = bar.Close; gridView[5, gridView.Rows.Count - 1].Value = bar.Volume; gridView[6, gridView.Rows.Count - 1].Value = bar.Wap; }
public void UpdateHistoricalData(IBMessage message) { switch (message.Type) { case MessageType.HistoricalData: HistoricalDataMessage hdMsg = (HistoricalDataMessage)message; if (!HistoricalData.ContainsKey(hdMsg.RequestId)) { HistoricalData.Add(hdMsg.RequestId, new List <HistoricalDataMessage>()); } HistoricalData[hdMsg.RequestId].Add(hdMsg); break; case MessageType.HistoricalDataEnd: HistoricalDataEndMessage endMsg = (HistoricalDataEndMessage)message; int requestId = endMsg.RequestId; if (!HistoricalData.ContainsKey(requestId)) { throw new Exception("Received end message with no historical data"); } HistoricalData[endMsg.RequestId].Sort(HistoricalDataComparer); if (HistoricalReqIdToContractDesc.ContainsKey(requestId)) { string contractDesc = HistoricalReqIdToContractDesc[requestId]; if (ContractDescToWPR.ContainsKey(contractDesc)) { WPRCalculator calc = ContractDescToWPR[contractDesc]; if (HistoricalData.ContainsKey(requestId) && (HistoricalData[requestId].Count > 0)) { List <HistoricalDataMessage> historicalData = HistoricalData[requestId]; HistoricalDataMessage last = historicalData.Last(); calc.OneDayHigh = last.High; calc.OneDayLow = last.Low; calc.Close = last.Close; double fiveDayHigh = -1; double fiveDayLow = double.MaxValue; foreach (var item in historicalData) { fiveDayHigh = Math.Max(fiveDayHigh, item.High); fiveDayLow = Math.Min(fiveDayLow, item.Low); } calc.FiveDayHigh = fiveDayHigh; calc.FiveDayLow = (fiveDayLow == double.MaxValue) ? -1 : fiveDayLow; } } } break; } }
public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.ContractData: if (isComboLegRequest) comboContractResults.UpdateUI((ContractDetailsMessage)message); else HandleContractMessage((ContractDetailsMessage)message); break; case MessageType.ContractDataEnd: HandleContractDataEndMessage((ContractDetailsEndMessage)message); break; case MessageType.FundamentalData: HandleFundamentalsData((FundamentalsMessage)message); break; } }
public Boolean updatePreMergeHistBarSeries(IBMessage message) { Boolean isAdded = false; if (isDataMerged) { return(isAdded); } HistoricalDataMessage histMessage = (HistoricalDataMessage)message; double h = Convert.ToDouble(histMessage.High); double l = Convert.ToDouble(histMessage.Low); double o = Convert.ToDouble(histMessage.Open); double c = Convert.ToDouble(histMessage.Close); double vol = Convert.ToDouble(histMessage.Volume); DateTime time = DateTime.ParseExact(histMessage.Date.Trim(), "yyyyMMdd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal); MarketDataElement currentHistData = MarketDataUtil.createHLOC(time, "HLOC", "HSI", "FUT"); MarketDataUtil.setHLOC(currentHistData, h, l, o, c); currentHistData.volume = vol; currentHistData.time = time; if (preMergeHistBarSeries == null) { preMergeHistBarSeries = new SeriesBuilder <DateTime, MarketDataElement>() { { time, currentHistData } }.Series; isAdded = true; } else { if (!preMergeHistBarSeries.ContainsKey(time)) { preMergeHistBarSeries = preMergeHistBarSeries.Merge(new SeriesBuilder <DateTime, MarketDataElement>() { { time, currentHistData } }.Series); isAdded = true; } } return(isAdded); }
public override void UpdateUI(IBMessage message) { DataGridView grid = (DataGridView)uiControl; if (grid.Rows.Count == 0) grid.Rows.Add(numRows * 2); DeepBookMessage entry = (DeepBookMessage)message; if (entry.Side == 1) { grid[BID_MAKER_IDX, GetBidIndex(entry.Position)].Value = entry.MarketMaker; grid[BID_SIZE_IDX, GetBidIndex(entry.Position)].Value = entry.Size; grid[BID_PRICE_IDX, GetBidIndex(entry.Position)].Value = entry.Price; } else { grid[ASK_MAKER_IDX, GetAskIndex(entry.Position)].Value = entry.MarketMaker; grid[ASK_SIZE_IDX, GetAskIndex(entry.Position)].Value = entry.Size; grid[ASK_PRICE_IDX, GetAskIndex(entry.Position)].Value = entry.Price; } }
public override void UpdateUI(IBMessage message) { barCounter++; Chart rtBarsChart = (Chart)uiControl; RealTimeBarMessage rtBar = (RealTimeBarMessage)message; DateTime start = new DateTime(1970, 1, 1, 0, 0, 0); DateTime dt = start.AddMilliseconds(rtBar.Timestamp * 1000).ToLocalTime(); // adding date and high rtBarsChart.Series[0].Points.AddXY(dt, rtBar.High); // adding low rtBarsChart.Series[0].Points[barCounter].YValues[1] = rtBar.Low; //adding open rtBarsChart.Series[0].Points[barCounter].YValues[2] = rtBar.Open; // adding close rtBarsChart.Series[0].Points[barCounter].YValues[3] = rtBar.Close; PopulateGrid(message); }
public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.OpenOrder: handleOpenOrder((OpenOrderMessage)message); break; case MessageType.OpenOrderEnd: break; case MessageType.OrderStatus: handleOrderStatus((OrderStatusMessage)message); break; case MessageType.ExecutionData: HandleExecutionMessage((ExecutionMessage)message); break; case MessageType.CommissionsReport: HandleCommissionMessage((CommissionMessage)message); break; } }
//2015-10-27 private Boolean isHistDataRequested(IBMessage message) { IAppMDManager appMDMManager = appStrategyManager.getAppMDManager(); switch (message.Type) { case MessageType.HistoricalData: HistoricalDataMessage hMessage = (HistoricalDataMessage)message; if (appMDMManager.isHistDataAdHocRequested(hMessage.RequestId)) { return(true); } break; case MessageType.HistoricalDataEnd: return(false); break; } return(false); }
public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.PositionMulti: HandlePositionMulti((PositionMultiMessage)message); break; case MessageType.PositionMultiEnd: HandlePositionMultiEnd((PositionMultiEndMessage)message); break; case MessageType.AccountUpdateMulti: HandleAccountUpdateMulti((AccountUpdateMultiMessage)message); break; case MessageType.AccountUpdateMultiEnd: HandleAccountUpdateMultiEnd((AccountUpdateMultiEndMessage)message); break; } }
//used to update the historical data grid protected void PopulateHistGrid(IBMessage message) { HistoricalDataMessage bar = (HistoricalDataMessage)message; // DateTime start = new DateTime(1970, 1, 1, 0, 0, 0); //DateTime dt = start.AddMilliseconds(bar.Timestamp * 1000).ToLocalTime(); //String strDT = String.Format("{0:yyyy-MM-dd HH:mm:ss}", dt); gridView.Rows.Add(1); //gridView[0, gridView.Rows.Count - 1].Value = bar.Date; //gridView[0, gridView.Rows.Count - 1].Value = strDT; //gridView[0, gridView.Rows.Count - 1].Value = bar.RequestId; gridView[1, gridView.Rows.Count - 1].Value = bar.Date; gridView[2, gridView.Rows.Count - 1].Value = bar.Close; gridView[3, gridView.Rows.Count - 1].Value = bar.Open; gridView[4, gridView.Rows.Count - 1].Value = bar.High; gridView[5, gridView.Rows.Count - 1].Value = bar.Low; gridView[6, gridView.Rows.Count - 1].Value = bar.Volume; }
public void test_isRTBarProcessStart() { //[Test: return ture, RTBDataStartTime is invalid Time and the message time is in 0 second.] DateTime validTime = new DateTime(2015, 11, 21, 9, 50, 0, DateTimeKind.Local); AppMDManager appMDManager = new AppMDManager(null); appMDManager.setRtbDataStartTime(AppConstant.INVALID_TIME); IBMessage validStartMessage = createMessage_for_isRTBarProcessStart(validTime); Assert.IsTrue(appMDManager.isRTBarProcessStart(validStartMessage)); Assert.AreEqual(validTime, appMDManager.getRtbDataStartTime()); //[Test: return false, RTBDataStartTime is invalid Time and the message time is not in 0 second.] DateTime invalidTime = new DateTime(2015, 11, 21, 9, 50, 5, DateTimeKind.Local); appMDManager = new AppMDManager(null); appMDManager.setRtbDataStartTime(AppConstant.INVALID_TIME); IBMessage invalidStartMessage = createMessage_for_isRTBarProcessStart(invalidTime); Assert.IsFalse(appMDManager.isRTBarProcessStart(invalidStartMessage)); Assert.AreEqual(AppConstant.INVALID_TIME, appMDManager.getRtbDataStartTime()); }
public override void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.HistoricalData: var watch = Stopwatch.StartNew(); RTBSynchronizer.updatePreMergeHistBarSeries(message); Series <DateTime, MarketDataElement> series = appMDManager.getTimeBarSeries(); HistoricalDataMessage histMsg = (HistoricalDataMessage)message; DateTime time = DateTime.ParseExact(histMsg.Date.Trim(), "yyyyMMdd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal); if (series != null && series.ContainsKey(time)) { PopulateHistGrid(message); } appForm.showMessage("test 1 : " + watch.ElapsedMilliseconds + " millsecond"); break; case MessageType.HistoricalDataEnd: PaintChart(); break; } }
public override void UpdateUI(IBMessage message) { DataGridView grid = (DataGridView)uiControl; if (grid.Rows.Count == 0) { grid.Rows.Add(numRows * 2); } DeepBookMessage entry = (DeepBookMessage)message; if (entry.Side == 1) { grid[BID_MAKER_IDX, GetBidIndex(entry.Position)].Value = entry.MarketMaker; grid[BID_SIZE_IDX, GetBidIndex(entry.Position)].Value = entry.Size; grid[BID_PRICE_IDX, GetBidIndex(entry.Position)].Value = entry.Price; } else { grid[ASK_MAKER_IDX, GetAskIndex(entry.Position)].Value = entry.MarketMaker; grid[ASK_SIZE_IDX, GetAskIndex(entry.Position)].Value = entry.Size; grid[ASK_PRICE_IDX, GetAskIndex(entry.Position)].Value = entry.Price; } }
public override void UpdateUI(IBMessage message) { barCounter++; RealTimeBarMessage rtBar = (RealTimeBarMessage)message; /* * DateTime start = new DateTime(1970, 1, 1, 0, 0, 0); * * DateTime dt = start.AddMilliseconds(rtBar.Timestamp * 1000).ToLocalTime(); * * //***for new MD logiic*** * DateTime searchEndToMin = marketDataHelper.getTimeToMin(dt); * //DateTime searchEndToMin = marketDataHelper.getTimeToMin(dt.AddSeconds(5)); * DateTime searchStart = marketDataHelper.getGapStartTime(searchEndToMin); * Boolean fullMinute = false; * double second = dt.Second; * if (dt.Second == 0) * fullMinute=true; */ //appForm.strategyManager.handleRealTimeBarMessage(message); MDManager.handleRealTimeBarMessage(message); PopulateGrid(message); }
public void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.ContractData: if (isComboLegRequest) { comboContractResults.UpdateUI((ContractDetailsMessage)message); } else { HandleContractMessage((ContractDetailsMessage)message); } break; case MessageType.ContractDataEnd: HandleContractDataEndMessage((ContractDetailsEndMessage)message); break; case MessageType.FundamentalData: HandleFundamentalsData((FundamentalsMessage)message); break; } }
public abstract void UpdateUI(IBMessage message);
public override void UpdateUI(IBMessage message) { switch (message.Type) { case MessageType.HistoricalData: historicalData.Add((HistoricalDataMessage)message); break; case MessageType.HistoricalDataEnd: cal_market(); // fire the event DataProcessed(this, new EventArgs()); //PaintChart(); break; } }
protected void PopulateGrid(IBMessage message) { HistoricalDataMessage bar = (HistoricalDataMessage)message; gridView.Rows.Add(1); gridView[0, gridView.Rows.Count -1].Value = bar.Date; gridView[1, gridView.Rows.Count - 1].Value = bar.Open; gridView[2, gridView.Rows.Count - 1].Value = bar.High; gridView[3, gridView.Rows.Count - 1].Value = bar.Low; gridView[4, gridView.Rows.Count - 1].Value = bar.Close; gridView[5, gridView.Rows.Count - 1].Value = bar.Volume; gridView[6, gridView.Rows.Count - 1].Value = bar.Wap; }
private void UpdateUI(IBMessage message) { ShowMessageOnPanel("(UpdateUI) Message type: " + message.Type.ToString()); switch (message.Type) { case MessageType.ConnectionStatus: { ConnectionStatusMessage statusMessage = (ConnectionStatusMessage)message; if (statusMessage.IsConnected) { status_CT.Text = "Connected! Your client Id: " + ibClient.ClientId; connectButton.Text = "Disconnect"; } else { status_CT.Text = "Disconnected..."; connectButton.Text = "Connect"; } break; } case MessageType.Error: { ErrorMessage error = (ErrorMessage)message; ShowMessageOnPanel("Request " + error.RequestId + ", Code: " + error.ErrorCode + " - " + error.Message); HandleErrorMessage(error); break; } case MessageType.TickOptionComputation: case MessageType.TickPrice: case MessageType.TickSize: { HandleTickMessage((MarketDataMessage)message); break; } case MessageType.MarketDepth: case MessageType.MarketDepthL2: { deepBookManager.UpdateUI(message); break; } case MessageType.HistoricalData: case MessageType.HistoricalDataEnd: { historicalDataManager.UpdateUI(message); break; } case MessageType.RealTimeBars: { realTimeBarManager.UpdateUI(message); break; } case MessageType.ScannerData: case MessageType.ScannerParameters: { scannerManager.UpdateUI(message); break; } case MessageType.OpenOrder: case MessageType.OpenOrderEnd: case MessageType.OrderStatus: case MessageType.ExecutionData: case MessageType.CommissionsReport: { orderManager.UpdateUI(message); break; } case MessageType.ManagedAccounts: { orderManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts; accountManager.ManagedAccounts = ((ManagedAccountsMessage)message).ManagedAccounts; exerciseAccount.Items.AddRange(((ManagedAccountsMessage)message).ManagedAccounts.ToArray()); break; } case MessageType.AccountSummaryEnd: { accSummaryRequest.Text = "Request"; accountManager.UpdateUI(message); break; } case MessageType.AccountDownloadEnd: { break; } case MessageType.AccountUpdateTime: { accUpdatesLastUpdateValue.Text = ((UpdateAccountTimeMessage)message).Timestamp; break; } case MessageType.PortfolioValue: { accountManager.UpdateUI(message); if (exerciseAccount.SelectedItem != null) { optionsManager.HandlePosition((UpdatePortfolioMessage)message); } break; } case MessageType.AccountSummary: case MessageType.AccountValue: case MessageType.Position: case MessageType.PositionEnd: { accountManager.UpdateUI(message); break; } case MessageType.ContractDataEnd: { searchContractDetails.Enabled = true; contractManager.UpdateUI(message); foreach (var socket in allSockets.ToList()) // Loop through all connections/connected clients and send each of them a message { socket.Send(searchJsonResponse.Test()); } // Send json object // After it is sent .clear it! //MessageBox.Show(searchJsonResponse.Test()); searchJsonResponse.Clear(); // Collection empty break; } case MessageType.ContractData: { HandleContractDataMessage((ContractDetailsMessage)message); //MessageBox.Show("contract_start"); foreach (var socket in allSockets.ToList()) // Loop through all connections/connected clients and send each of them a message { //var castedMessage = (ContractDetailsMessage)message; //ShowMessageOnPanel("SYMBOL: " + castedMessage.ContractDetails.Summary.Symbol + " successfully found at: " + castedMessage.ContractDetails.Summary.PrimaryExch + " exchange"); //socket.Send("SYMBOL: " + castedMessage.ContractDetails.Summary.Symbol + " successfully found at: " + castedMessage.ContractDetails.Summary.Exchange + " exchange"); } // Add new object to json array var z = (ContractDetailsMessage)message; // Type cast var x = z.ContractDetails.Summary; searchJsonResponse.Add(x.Exchange, x.LocalSymbol, x.SecType, x.Currency, x.Exchange, x.PrimaryExch, x.ConId); //Log.Insert(DateTime.Now, "Form1.cs", string.Format("ContractData: {0} {1} {2} {3} {4} {5} {6}", x.Exchange, x.LocalSymbol, x.SecType, x.Currency, x.Exchange, x.PrimaryExch, x.ConId), "white"); break; } case MessageType.FundamentalData: { fundamentalsQueryButton.Enabled = true; contractManager.UpdateUI(message); break; } case MessageType.ReceiveFA: { advisorManager.UpdateUI((AdvisorDataMessage)message); break; } case MessageType.PositionMulti: case MessageType.AccountUpdateMulti: case MessageType.PositionMultiEnd: case MessageType.AccountUpdateMultiEnd: { acctPosMultiManager.UpdateUI(message); break; } case MessageType.SecurityDefinitionOptionParameter: case MessageType.SecurityDefinitionOptionParameterEnd: { optionsManager.UpdateUI(message); break; } case MessageType.SoftDollarTiers: { orderManager.UpdateUI(message); break; } default: { HandleMessage(new ErrorMessage(-1, -1, message.ToString())); break; } } } // private void UpdateUI
public override void UpdateUI(IBMessage message) { MarketDataMessage dataMessage = (MarketDataMessage)message; checkToAddRow(dataMessage.RequestId); DataGridView grid = (DataGridView)uiControl; if (grid.Rows.Count >= dataMessage.RequestId - TICK_ID_BASE) { if (message is TickPriceMessage) { TickPriceMessage priceMessage = (TickPriceMessage)message; switch (dataMessage.Field) { case 1: { //BID grid[BID_PRICE_INDEX, GetIndex(dataMessage.RequestId)].Value = priceMessage.Price; break; } case 2: { //ASK grid[ASK_PRICE_INDEX, GetIndex(dataMessage.RequestId)].Value = priceMessage.Price; break; } case 9: { //CLOSE grid[CLOSE_PRICE_INDEX, GetIndex(dataMessage.RequestId)].Value = priceMessage.Price; break; } } } else if (dataMessage is TickSizeMessage) { TickSizeMessage sizeMessage = (TickSizeMessage)message; switch (dataMessage.Field) { case 0: { //BID SIZE grid[BID_SIZE_INDEX, GetIndex(dataMessage.RequestId)].Value = sizeMessage.Size; break; } case 3: { //ASK SIZE grid[ASK_SIZE_INDEX, GetIndex(dataMessage.RequestId)].Value = sizeMessage.Size; break; } case 5: { //LAST SIZE grid[LAST_SIZE_INDEX, GetIndex(dataMessage.RequestId)].Value = sizeMessage.Size; break; } case 8: { //VOLUME grid[VOLUME_SIZE_INDEX, GetIndex(dataMessage.RequestId)].Value = sizeMessage.Size; break; } } } } }