Esempio n. 1
0
    public static void Main()
    {
        //  InstrumentFactory myFactory = new ConsoleInstrumentFactory(); //GetInstrumentFactory();
        // TwoFactorOption myOption = myFactory.CreateOption();

        int    type = 1; // Call/put
        double w1   = 1.0;
        double w2   = -1.0;
        double K    = 5.0;

        BasketStrategy myPayoff = new BasketStrategy(K, type, w1, w2);

        Range <double> r1 = new Range <double>(0.0, 200.0);
        int            N1 = 20;

        Range <double> r2 = new Range <double>(0.0, 200.0);
        int            N2 = 20;

        // Calling extension methods
        NumericMatrix <double> matrix = myPayoff.PayoffMatrix(r1, r2, N1, N2);

        Console.WriteLine("Starting Excel, please wait..");

        myPayoff.DisplayInExcel(r1, r2, N1, N2);
    }
Esempio n. 2
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            var option = this.SelectedOption;

            // создаем окно для отображения стакана
            var wnd = new QuotesWindow {
                Title = option.Name
            };

            wnd.Init(option);

            // создаем котирование на покупку 20-ти контрактов
            var quoting = new VolatilityQuotingStrategy(
                new Range <decimal>(this.VolatilityMin.Text.To <decimal>(), this.VolatilityMax.Text.To <decimal>()),
                OrderDirections.Buy, 20)
            {
                // указываем, что котирование работает с объемом в 1 контракт
                Volume    = 1,
                Security  = option,
                Portfolio = this.Portfolio.SelectedPortfolio,
                Trader    = _trader,
            };

            var basket = new BasketStrategy(BasketStrategyFinishModes.All);

            basket.ChildStrategies.Add(quoting);

            // запускаем котирование
            basket.Start();

            // создаем дельта-хеджирование, передав в него опционные стратегии для отслеживания их позиции
            var hedge = new DeltaHedgeStrategy(basket)
            {
                Security  = option.GetUnderlyingAsset(),
                Portfolio = this.Portfolio.SelectedPortfolio,
                Trader    = _trader,
            };

            // запускаем дельта-хеджирование
            hedge.Start();

            // показываем окно
            wnd.ShowModal(this);

            hedge.Stop();
            basket.Stop();
        }