private void Adjustment2_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (e.OldValue != null && e.NewValue != null) { var contract = SubbedContracts2?.FirstOrDefault(); if (contract != null) { UpdateStrategyAdjustment(contract, StrategyVM.Model.VM, (double)e.NewValue); } } }
private void volModelCB1_SelectionChanged(object sender, SelectionChangedEventArgs e) { var modelParam = volModelCB1.SelectedItem as ModelParamsVM; if (modelParam != null) { var contract = SubbedContracts2?.FirstOrDefault(); if (contract != null) { var strategy = _otcOptionHandler.StrategyVMCollection.FirstOrDefault(s => s.Exchange == contract.Exchange && s.Contract == contract.Contract); if (strategy != null && strategy.VolModel != modelParam.InstanceName) { strategy.VolModel = modelParam.InstanceName; _otcOptionHandler.UpdateStrategyModel(strategy, StrategyVM.Model.VM); } } } }
private async void contract2_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (contract2.SelectedItem != null) { var uexchange = exchange2.SelectedValue?.ToString(); var uc = contract2.SelectedItem?.ToString(); var handler = MessageHandlerContainer.DefaultInstance.Get <MarketDataHandler>(); QuoteVMCollection2.Clear(); var mktDataVM = await handler.SubMarketDataAsync(uc); if (mktDataVM != null) { QuoteVMCollection2.Add(mktDataVM); } var contract = SubbedContracts2?.FirstOrDefault(); if (contract != null) { var strategy = _otcOptionHandler.StrategyVMCollection.FirstOrDefault(s => s.Exchange == contract.Exchange && s.Contract == contract.Contract); var pricingContract = strategy.VMContractParams.FirstOrDefault(); if (pricingContract != null && pricingContract.Exchange == uexchange && pricingContract.Contract == uc) { return; } if (pricingContract == null) { pricingContract = new PricingContractParamVM(); strategy.VMContractParams.Add(pricingContract); } pricingContract.Exchange = uexchange; pricingContract.Contract = uc; _otcOptionHandler.UpdateStrategyPricingContracts(strategy, StrategyVM.Model.VM); } } }
private async void expireDateCB1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (expireDateCB1.SelectedValue != null) { var ed = expireDateCB1.SelectedValue.ToString(); var uc = underlyingContractCB1.SelectedValue.ToString(); var exchange = underlyingEX1.SelectedValue.ToString(); var optionList = (from c in _contractList where c.Exchange == exchange && c.UnderlyingContract == uc && c.ExpireDate == ed select new ContractKeyVM(c.Exchange, c.Contract)).ToList(); SubbedContracts2 = await _otcOptionHandler.SubTradingDeskDataAsync(optionList); exchange2.ItemsSource = null; underlying2.ItemsSource = null; contract2.ItemsSource = null; volModelCB1.ItemsSource = null; adjustment2.Value = null; exchange2.ItemsSource = _futurecontractList.Select(c => c.Exchange).Distinct(); volModelCB1.ItemsSource = _otcOptionHandler.GetModelParamsVMCollection("vm"); var contract = SubbedContracts2?.FirstOrDefault(); if (contract != null) { var strategy = _otcOptionHandler.StrategyVMCollection.FirstOrDefault(s => s.Exchange == contract.Exchange && s.Contract == contract.Contract); var pricingContract = strategy?.VMContractParams.FirstOrDefault(); if (pricingContract != null) { var futureexchange = pricingContract.Exchange; var futurecontract = pricingContract.Contract; var futureunderlying = _futurecontractList.FirstOrDefault(c => c.Exchange == futureexchange && c.Contract == futurecontract)?.ProductID; var volmodel = strategy.VolModel; var adjust = pricingContract.Adjust; volModelCB1.SelectedValue = volmodel; exchange2.SelectedValue = futureexchange; var exchangeTemp = exchange2.SelectedValue?.ToString(); if (exchangeTemp != null) { var productID = (from c in _futurecontractList where c.Exchange == exchange.ToString() orderby c.ProductID ascending select c.ProductID).Distinct().ToList(); //underlying2.ItemsSource = _futurecontractList.Where(c => c.Exchange == exchangeTemp).Select(c => c.ProductID).Distinct(); underlying2.ItemsSource = productID; contract2.ItemsSource = null; } underlying2.SelectedValue = futureunderlying; var productIdTemp = underlying2.SelectedValue?.ToString(); if (productIdTemp != null) { var underlyingContracts = (from c in _futurecontractList where c.ProductID == productIdTemp.ToString() select c.Contract).Distinct().ToList(); contract2.ItemsSource = underlyingContracts; } contract2.SelectedValue = futurecontract; adjustment2.Value = adjust; } } } }