Exemple #1
0
        private void OptionsClick(object sender, RoutedEventArgs e)
        {
            var security = SelectedSecurity;

            var id = _optionSecurities.TryGetValue2(security);

            if (id == null)
            {
                var wnd = new OptionWindow();

                if (!wnd.ShowModal(this))
                {
                    return;
                }

                Trader.SubscribeOptionCalc(security, wnd.Volatility, wnd.OptionPrice, wnd.AssetPrice);
                Options.IsChecked = true;
            }
            else
            {
                Trader.UnSubscribeOptionCalc(id.Value);
                _optionSecurities.Remove(security);
                Options.IsChecked = false;
            }
        }
        private void OptionsClick(object sender, RoutedEventArgs e)
        {
            foreach (var security in SecurityPicker.SelectedSecurities)
            {
                if (security.Type == SecurityTypes.Option)
                {
                    var id = _optionSecurities.TryGetValue2(security);

                    if (id == null)
                    {
                        var wnd = new OptionWindow();

                        if (!wnd.ShowModal(this))
                        {
                            return;
                        }

                        id = Trader.SubscribeOptionCalc(security, wnd.Volatility, wnd.OptionPrice, wnd.AssetPrice);
                        _optionSecurities.Add(security, id.Value);
                        Options.IsChecked = true;
                    }
                    else
                    {
                        Trader.UnSubscribeOptionCalc(id.Value);
                        _optionSecurities.Remove(security);
                        Options.IsChecked = false;
                    }
                }
                else
                {
                    if (!_optionsInitialized)
                    {
                        Trader.NewOptionParameters += TraderOnNewOptionParameters;
                        _optionsInitialized         = true;
                    }

                    Trader.RequestOptionParameters(security);
                }
            }
        }