public void UpdateStrategyModel(StrategyVM sVM, StrategyVM.Model model)
        {
            var strategy = new PBStrategy();

            strategy.Exchange     = sVM.Exchange;
            strategy.Contract     = sVM.Contract;
            strategy.Symbol       = sVM.StrategySym;
            strategy.BaseContract = sVM.BaseContract;

            if (model == StrategyVM.Model.PM)
            {
                strategy.PricingModel = sVM.PricingModel;
            }

            if (model == StrategyVM.Model.IVM)
            {
                strategy.IvModel = sVM.IVModel;
            }

            if (model == StrategyVM.Model.VM)
            {
                strategy.VolModel = sVM.VolModel;
            }

            MessageWrapper.SendMessage((uint)BusinessMessageID.MSG_ID_MODIFY_PRICING_CONTRACT, strategy);
        }
Example #2
0
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            Control ctrl = sender as Control;

            if (ctrl != null)
            {
                if (e.Key == Key.Enter)
                {
                    StrategyVM strategyVM = ctrl.Tag as StrategyVM;
                    if (strategyVM != null)
                    {
                        if (e.Key == Key.Enter)
                        {
                            strategyVM.UpdateStrategy();
                        }
                        else
                        {
                            ctrl.DataContext = null;
                            ctrl.DataContext = strategyVM;
                        }
                    }
                    ctrl.Background = Brushes.White;
                }
                else
                {
                    ctrl.Background = Brushes.MistyRose;
                }
            }
        }
        public void UpdateStrategy(StrategyVM sVM, bool resetCounter = false)
        {
            var strategy = new PBStrategy();

            strategy.Exchange     = sVM.Exchange;
            strategy.Contract     = sVM.Contract;
            strategy.Symbol       = sVM.StrategySym;
            strategy.Depth        = sVM.Depth;
            strategy.BidQV        = sVM.BidQV;
            strategy.AskQV        = sVM.AskQV;
            strategy.Hedging      = sVM.Hedging;
            strategy.AskEnabled   = sVM.AskEnabled;
            strategy.BidEnabled   = sVM.BidEnabled;
            strategy.MaxAutoTrade = sVM.MaxAutoTrade;
            strategy.BidNotCross  = sVM.BidNotCross;
            strategy.CloseMode    = sVM.CloseMode;
            strategy.Tif          = (int)sVM.TIF;
            strategy.VolCond      = (int)sVM.VolCondition;
            strategy.TickSizeMult = sVM.TickSize;
            if (resetCounter)
            {
                strategy.BidCounter = -1;
                strategy.AskCounter = -1;
            }


            MessageWrapper.SendMessage((uint)BusinessMessageID.MSG_ID_MODIFY_STRATEGY, strategy);
        }
Example #4
0
        private void _otcHandler_OnStrategyUpdated(StrategyVM strategyVM)
        {
            var contract = strategyVM.Contract;
            var exchange = strategyVM.Exchange;
            var pointPA  = VolatilityModelVM.TheoPutAskVolScatter.
                           FirstOrDefault(c => ((StrategyVM)c.Tag)?.Contract == contract && ((StrategyVM)c.Tag)?.Exchange == exchange);
            var pointPB = VolatilityModelVM.TheoPutBidVolScatter.
                          FirstOrDefault(c => ((StrategyVM)c.Tag)?.Contract == contract && ((StrategyVM)c.Tag)?.Exchange == exchange);
            var pointCA = VolatilityModelVM.TheoCallAskVolScatter.
                          FirstOrDefault(c => ((StrategyVM)c.Tag)?.Contract == contract && ((StrategyVM)c.Tag)?.Exchange == exchange);
            var pointCB = VolatilityModelVM.TheoCallBidVolScatter.
                          FirstOrDefault(c => ((StrategyVM)c.Tag)?.Contract == contract && ((StrategyVM)c.Tag)?.Exchange == exchange);

            if (pointPA != null)
            {
                pointPA.Value = strategyVM.AskEnabled ? 1 : 0;
            }
            if (pointPB != null)
            {
                pointPB.Value = strategyVM.BidEnabled ? 1 : 0;
            }
            if (pointCA != null)
            {
                pointCA.Value = strategyVM.AskEnabled ? 1 : 0;
            }
            if (pointCB != null)
            {
                pointCB.Value = strategyVM.BidEnabled ? 1 : 0;
            }
            volPlot.InvalidatePlot(true);
        }
        private void OnStrategyChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            FrameworkElement ctrl       = sender as FrameworkElement;
            StrategyVM       strategyVM = ctrl.DataContext as StrategyVM;

            if (strategyVM != null)
            {
                strategyVM.UpdateStrategy();
            }
        }
        private async void OTCTradingLV_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            StrategyVM strategyVM = OTCTradingLV.SelectedItem as StrategyVM;

            if (strategyVM != null)
            {
                var paramsVM = await OTCHandler?.QueryModelParamsAsync(strategyVM.PricingModel);

                StrategyParam.ItemsSource = paramsVM.Params;
            }
        }
Example #7
0
        private void ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var updownctrl = sender as IntegerUpDown;

            if (updownctrl != null && e.OldValue != null && e.NewValue != null)
            {
                StrategyVM strategyVM = updownctrl.Tag as StrategyVM;
                if (strategyVM != null)
                {
                    strategyVM.UpdateStrategy();
                }
            }
        }
        public void UpdateStrategyPricingContracts(StrategyVM sVM, StrategyVM.Model model)
        {
            var strategy = new PBStrategy();

            strategy.Exchange = sVM.Exchange;
            strategy.Contract = sVM.Contract;
            strategy.Symbol   = sVM.StrategySym;

            if (model == StrategyVM.Model.PM)
            {
                foreach (var pc in sVM.PricingContractParams)
                {
                    strategy.PricingContracts.Add(new PBPricingContract()
                    {
                        Exchange = pc.Exchange, Contract = pc.Contract, Adjust = pc.Adjust, Weight = pc.Weight
                    });
                }
            }

            if (model == StrategyVM.Model.IVM)
            {
                foreach (var pc in sVM.IVMContractParams)
                {
                    strategy.IvmContracts.Add(new PBPricingContract()
                    {
                        Exchange = pc.Exchange, Contract = pc.Contract, Adjust = pc.Adjust, Weight = pc.Weight
                    });
                }
            }

            if (model == StrategyVM.Model.VM)
            {
                foreach (var pc in sVM.VMContractParams)
                {
                    strategy.VolContracts.Add(new PBPricingContract()
                    {
                        Exchange = pc.Exchange, Contract = pc.Contract, Adjust = pc.Adjust, Weight = pc.Weight
                    });
                }
            }

            MessageWrapper.SendMessage((uint)BusinessMessageID.MSG_ID_MODIFY_PRICING_CONTRACT, strategy);
        }
        protected void OnQueryStrategySuccessAction(PBStrategyList PB)
        {
            foreach (var strategy in PB.Strategy)
            {
                var strategyVM = StrategyVMCollection.FindContract(strategy.Exchange, strategy.Contract);
                if (strategyVM == null)
                {
                    strategyVM = new StrategyVM(this);
                    StrategyVMCollection.Add(strategyVM);
                }

                strategyVM.Exchange     = strategy.Exchange;
                strategyVM.Contract     = strategy.Contract;
                strategyVM.Hedging      = strategy.Hedging;
                strategyVM.Underlying   = strategy.Underlying;
                strategyVM.StrategySym  = strategy.Symbol;
                strategyVM.Depth        = strategy.Depth;
                strategyVM.AskEnabled   = strategy.AskEnabled;
                strategyVM.BidEnabled   = strategy.BidEnabled;
                strategyVM.BidQV        = strategy.BidQV;
                strategyVM.AskQV        = strategy.AskQV;
                strategyVM.IVModel      = strategy.IvModel;
                strategyVM.VolModel     = strategy.VolModel;
                strategyVM.PricingModel = strategy.PricingModel;
                strategyVM.BaseContract = strategy.BaseContract;
                strategyVM.Portfolio    = strategy.Portfolio;
                strategyVM.MaxAutoTrade = strategy.MaxAutoTrade;
                strategyVM.BidNotCross  = strategy.BidNotCross;
                strategyVM.AskCounter   = strategy.AskCounter;
                strategyVM.BidCounter   = strategy.BidCounter;
                strategyVM.CloseMode    = strategy.CloseMode;
                strategyVM.TickSize     = strategy.TickSizeMult;
                strategyVM.OrderCounter = strategy.LimitOrderCounter;
                strategyVM.PricingContractParams.Clear();

                foreach (var wtContract in strategy.PricingContracts)
                {
                    strategyVM.PricingContractParams.Add(
                        new PricingContractParamVM()
                    {
                        Exchange = wtContract.Exchange,
                        Contract = wtContract.Contract,
                        Adjust   = wtContract.Adjust,
                        Weight   = wtContract.Weight
                    });
                }

                strategyVM.IVMContractParams.Clear();
                foreach (var wtContract in strategy.IvmContracts)
                {
                    strategyVM.IVMContractParams.Add(
                        new PricingContractParamVM()
                    {
                        Exchange = wtContract.Exchange,
                        Contract = wtContract.Contract,
                        Adjust   = wtContract.Adjust,
                        Weight   = wtContract.Weight
                    });
                }

                strategyVM.VMContractParams.Clear();
                foreach (var wtContract in strategy.VolContracts)
                {
                    strategyVM.VMContractParams.Add(
                        new PricingContractParamVM()
                    {
                        Exchange = wtContract.Exchange,
                        Contract = wtContract.Contract,
                        Adjust   = wtContract.Adjust,
                        Weight   = wtContract.Weight
                    });
                }
            }
        }