Click or drag to resize

Volatility trading

For the option quoting the special VolatilityQuotingStrategy strategy is realized, which provides the volume quoting by the specified range of volatility.

Quoting by volatility

  1. The S# installation package includes the example SampleOptionQuoting, which quotes selected strike by the specified range of volatility.

  2. Creating a connection to the OpenECry and export starting:

    C#
    _trader = new OpenECryTrader(this.Path.Text);
    
    this.Portfolio.Trader = _trader;
    
    // adding all options into drop down list
    _trader.NewSecurities += securities =>
        this.GuiAsync(() => _options.AddRange(securities.Where(s => s.Type == SecurityTypes.Option)));
    
    // tracking the last asset price
    _trader.NewTrades += trades => this.GuiAsync(() =>
    {
        var option = this.SelectedOption;
        if (option != null)
        {
            var future = option.GetUnderlyingAsset();
            if (future.LastTrade != null)
                this.BaseActivePrice.Text = future.LastTrade.Price.ToString();
        }
    });
    
    _trader.Connected += () => _trader.StartExport();
    
    _trader.Connect();
  3. Set up the VolatilityQuotingStrategy strategy (filling the range of volatility, as well as the creation of the order, wherethrough the required volume and quoting direction are specified):

    // quoting 20 long option contacts
    var quoting = new VolatilityQuotingStrategy(
            new Range<decimal>(this.VolatilityMin.Text.To<decimal>(), this.VolatilityMax.Text.To<decimal>()),
            OrderDirections.Buy, 20)
    {
        // order size on order book will be always 1 contact (to hide a real size)
        Volume = 1,
        Security = option,
        Portfolio = this.Portfolio.SelectedPortfolio,
        Trader = _trader,
    };
  4. The quoting start:

    C#
    quoting.Start();
  5. For a visual presentation of the volatility the example shows how you can convert the standard order book with quotations to the order book of volatility through the use of the DerivativesHelperImpliedVolatility(MarketDepth, ISecurityProvider, IMarketDataProvider, DateTimeOffset, Decimal, Decimal) method:

    C#
    var ivDepth = _depth.ImpliedVolatility();
    
    this.GuiAsync(() =>
    {
        this.Quotes.Clear();
        this.Quotes.AddRange(ivDepth.Select(q => new IVQuote(q)));
    });
    Стакан волатильности.
  6. The quoting ending and the strategy stop:

    quoting.Stop();