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 override bool Equals(object obj) { if (!(obj is SecDefOptParamKey)) { return(false); } SecDefOptParamKey left = obj as SecDefOptParamKey; return(left.underlyingConId == underlyingConId && left.tradingClass == tradingClass && left.multiplier == multiplier); }
public void UpdateUI(SecurityDefinitionOptionParameterMessage secDefOptParamMsg) { 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); } }