moexoptcalc

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

README

moexoptcalc

Go client for the public MOEX ISS Options Calculator API. It returns the official greeks, implied volatility, theoretical prices, and portfolio/margin metrics that MOEX publishes for FORTS options — the same numbers used for margin calculations. The models are generated from MOEX's OpenAPI spec by oapi-codegen as plain Go structs and wrapped by a hand-written transport over the shared restkit core. The Options Calculator API is public — no authentication is required.

API docs: https://iss.moex.com/iss/apps/option-calc/v1/docs

Features

  • 13 typed methods covering the full option-calc surface: assets, futures, options, option series, option board, volatility graph, portfolio calculation/graph, and initial margin.
  • Plain-struct models (direct field access; optional fields are pointers).
  • Date-only (Date) and Moscow-zoned date-time (DateTime) types with correct JSON (un)marshaling — time/tzdata is embedded so zones resolve on any host.
  • Three typed errors matched with errors.As (*ConfigError, *RequestError, *ResponseError); no sentinel values.
  • Built-in OpenTelemetry: every call emits standard http.client.* spans and metrics through the global OTel providers (opt-in, free until enabled).
  • Immutable Client, safe for concurrent use.

Install

go get github.com/acidsailor/moexoptcalc

Requires Go 1.26+.

Quickstart

package main

import (
	"context"
	"log"

	"github.com/acidsailor/moexoptcalc"
)

func main() {
	c, err := moexoptcalc.NewClient(moexoptcalc.EndpointProduction)
	if err != nil {
		log.Fatal(err)
	}

	opt, err := c.GetOption(context.Background(), moexoptcalc.GetOptionRequest{
		AssetCode: "Si",
		Secid:     "SI84500BE6B",
	})
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("delta=%v gamma=%v vega=%v theta=%v rho=%v iv=%v theor=%v",
		opt.Delta, opt.Gamma, opt.Vega, opt.Theta, opt.Rho,
		opt.Volatility, opt.Theorprice)
}
Methods

All live on *moexoptcalc.Client:

Method HTTP Path
ListAssets GET /assets
GetAsset GET /assets/{asset_code}
ListFutures GET /assets/{asset_code}/futures
ListOptions GET /assets/{asset_code}/options
GetOption GET /assets/{asset_code}/options/{secid}
ListOptionSeries GET /assets/{asset_code}/optionseries
GetOptionSeries GET /assets/{asset_code}/optionseries/{optionseries_code}
ListSeriesOptions GET /assets/{asset_code}/optionseries/{optionseries_code}/options
GetOptionBoard GET /assets/{asset_code}/optionseries/{optionseries_code}/optionboard
GetVolatilityGraph GET /assets/{asset_code}/optionseries/{optionseries_code}/volatility_graph
CalculatePortfolio POST /portfolio/
CalculatePortfolioGraph POST /portfolio/graph/{indicator}
CalculateInitialMargin POST /portfolio/initial_margin

Configuration

moexoptcalc.NewClient(endpoint, ...ClientOption) takes the target endpoint — use moexoptcalc.EndpointProduction for the public MOEX ISS host. The Options Calculator API has no separate test environment and needs no credentials, so there are no environment variables to set.

By default New uses an *http.Client with a 30s timeout and the stdlib default transport. Override it with WithHTTPClient (for a custom timeout, transport, or proxy):

c, err := moexoptcalc.NewClient(moexoptcalc.EndpointProduction,
	moexoptcalc.WithHTTPClient(&http.Client{Timeout: 60 * time.Second}))

A nil *http.Client is ignored, falling back to the default.

Observability

New wraps the HTTP transport with otelhttp, so calls emit spans and the standard HTTP-client metrics (http.client.request.duration, http.client.request.body.size) through the global OTel providers. Opt in by registering providers via otel.SetTracerProvider / otel.SetMeterProvider before calling New; until then the no-op defaults make it free.

Errors

No sentinel errors — the typed error is the category. The three types are re-exported from restkit and matched with errors.As; wrapped causes survive an unwrap:

Type Returned when
*moexoptcalc.ConfigError New got an empty endpoint.
*moexoptcalc.RequestError a call failed to marshal, build, hook, send, read, or unmarshal (incl. a cancelled context). The Op field names the stage.
*moexoptcalc.ResponseError a non-2xx response. Exposes StatusCode and raw Body; not a *RequestError.
var respErr *moexoptcalc.ResponseError
if errors.As(err, &respErr) {
	_ = respErr.StatusCode // e.g. 404, 422
	_ = respErr.Body       // e.g. `{"detail":"..."}`
}
if errors.Is(err, context.Canceled) { /* call was cancelled */ }

Regeneration

models.gen.go is generated from MOEX's OpenAPI spec by oapi-codegen; the pipeline runs entirely via Docker (no local codegen toolchain). Do not edit models.gen.go by hand.

task spec     # download spec/spec-upstream.json from iss.moex.com (committed)
task overlay  # Speakeasy: apply spec/overlay.yml -> spec/spec.json (oapi-codegen input)
task deref    # Redocly bundle --dereferenced -> spec/spec-deref.json (MCP input)
task gen      # overlay + oapi-codegen -> models.gen.go (fails on any warning)
task check    # lint + vet + test

Scope

This module wraps only the option-calc sub-API. Out of scope: WebSocket / streaming (the API has none), authentication (the API is public), and the MOEX ISS classic REST API (quotes, candles, board snapshots).

Disclaimer

This library is provided "as is", without warranty of any kind. The author assumes no financial, legal, or other liability for any losses, damages, or consequences arising from the use of this library, including but not limited to losses incurred through trading, order placement, or interaction with the MOEX ISS Options Calculator API.

Nothing in this library, its documentation, or examples constitutes investment advice, a recommendation, or solicitation to buy or sell any financial instrument. All trading decisions are solely the responsibility of the user. Consult a licensed financial advisor before making investment decisions.

Отказ от ответственности

Библиотека предоставляется «как есть», без каких-либо гарантий. Автор не несёт финансовой, юридической или иной ответственности за любые убытки, ущерб или последствия, возникшие в результате использования этой библиотеки, включая, но не ограничиваясь, убытки от торговли, выставления ордеров или взаимодействия с API MOEX ISS Options Calculator.

Ничто в этой библиотеке, её документации или примерах не является индивидуальной инвестиционной рекомендацией, предложением или побуждением к покупке или продаже каких-либо финансовых инструментов. Все торговые решения принимаются пользователем самостоятельно и под его ответственность. Перед принятием инвестиционных решений проконсультируйтесь с лицензированным финансовым советником.

License

GNU Affero General Public License v3.0. See LICENSE.

Documentation

Overview

Package moexoptcalc is a Go client for the public MOEX ISS Options Calculator API. Models are oapi-codegen output (models.gen.go); the HTTP transport is the shared restkit core. The API is public — no auth required.

Package moexoptcalc error types alias the shared restkit types, so callers match them with errors.As without importing restkit:

var re *moexoptcalc.ResponseError
if errors.As(err, &re) { _ = re.StatusCode } // e.g. 422

var re *moexoptcalc.RequestError
if errors.As(err, &re) { _ = re.Op } // OpMarshal/OpBuild/OpHook/OpSend/OpRead/OpUnmarshal

No sentinel errors: the typed error IS the category.

Package moexoptcalc provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.

Index

Constants

View Source
const (
	OpMarshal   = restkit.OpMarshal   // encoding the request body to JSON
	OpBuild     = restkit.OpBuild     // constructing the *http.Request
	OpHook      = restkit.OpHook      // a request hook returned an error
	OpSend      = restkit.OpSend      // the HTTP round-trip
	OpRead      = restkit.OpRead      // reading the response body
	OpUnmarshal = restkit.OpUnmarshal // decoding the 2xx body into T
)

Op values name the lifecycle stage a RequestError failed at, so callers can switch on RequestError.Op without importing restkit:

var re *moexoptcalc.RequestError
if errors.As(err, &re) && re.Op == moexoptcalc.OpSend { /* round-trip failed */ }
View Source
const (
	// EndpointProduction is the public MOEX ISS server (no test environment).
	EndpointProduction = "https://iss.moex.com/iss/apps/option-calc/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFuturesAssetsAssetCodeFuturesGetParams

type AllFuturesAssetsAssetCodeFuturesGetParams struct {
	// ExpirationDate Дата погашения
	ExpirationDate *Date `form:"expiration_date,omitempty" json:"expiration_date,omitempty"`
}

AllFuturesAssetsAssetCodeFuturesGetParams defines parameters for AllFuturesAssetsAssetCodeFuturesGet.

type AllOptionSeriesAssetsAssetCodeOptionseriesGetParams

type AllOptionSeriesAssetsAssetCodeOptionseriesGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`
}

AllOptionSeriesAssetsAssetCodeOptionseriesGetParams defines parameters for AllOptionSeriesAssetsAssetCodeOptionseriesGet.

type AllOptionsAssetsAssetCodeOptionsGetParams

type AllOptionsAssetsAssetCodeOptionsGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`

	// ExpirationDate Дата исполнения
	ExpirationDate *Date `form:"expiration_date,omitempty" json:"expiration_date,omitempty"`

	// SeriesType Вид серии опционов
	SeriesType *OptionSeriesType `form:"series_type,omitempty" json:"series_type,omitempty"`

	// Strike Cтрайк
	Strike *float64 `form:"strike,omitempty" json:"strike,omitempty"`

	// OptionType Тип опциона (call, put)
	OptionType *OptionType `form:"option_type,omitempty" json:"option_type,omitempty"`
}

AllOptionsAssetsAssetCodeOptionsGetParams defines parameters for AllOptionsAssetsAssetCodeOptionsGet.

type Asset

type Asset struct {
	// AssetCode Торговый код базового актива
	AssetCode string `json:"asset_code"`

	// AssetSubtype Подтип базового актива - фьючерса
	AssetSubtype *string `json:"asset_subtype,omitempty"`

	// AssetType Тип базового актива
	AssetType string `json:"asset_type"`

	// Title Наименование базового актива
	Title string `json:"title"`
}

Asset Базовый актив

type AssetDetailAssetsAssetCodeGetParams

type AssetDetailAssetsAssetCodeGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`
}

AssetDetailAssetsAssetCodeGetParams defines parameters for AssetDetailAssetsAssetCodeGet.

type AssetSubtype

type AssetSubtype string

AssetSubtype Подтип фьючерса (базового актива)

const (
	AssetSubtypeCommodity AssetSubtype = "commodity"
	AssetSubtypeCurrency  AssetSubtype = "currency"
	AssetSubtypeIndex     AssetSubtype = "index"
	AssetSubtypeShare     AssetSubtype = "share"
)

Defines values for AssetSubtype.

type AssetType

type AssetType string

AssetType Тип базового актива

const (
	AssetTypeCommodity AssetType = "commodity"
	AssetTypeCurrency  AssetType = "currency"
	AssetTypeFutures   AssetType = "futures"
	AssetTypeIndex     AssetType = "index"
	AssetTypeShare     AssetType = "share"
)

Defines values for AssetType.

type AssetsAssetsGetParams

type AssetsAssetsGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`

	// AssetSubtype Подтип базового актива для фьючерсов
	AssetSubtype *AssetSubtype `form:"asset_subtype,omitempty" json:"asset_subtype,omitempty"`

	// Query Фильтр названия БА
	Query *string `form:"query,omitempty" json:"query,omitempty"`
}

AssetsAssetsGetParams defines parameters for AssetsAssetsGet.

type BriefAssetsAssetCodeOptionsSecidGetParams

type BriefAssetsAssetCodeOptionsSecidGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`

	// DaysUntilExpiring Дней до исполнения
	DaysUntilExpiring *int `form:"days_until_expiring,omitempty" json:"days_until_expiring,omitempty"`

	// UnderlyingPrice Цена базового актива, рублей
	UnderlyingPrice *float64 `form:"underlying_price,omitempty" json:"underlying_price,omitempty"`

	// Volatility Волатильность IV, процентов
	Volatility *float64 `form:"volatility,omitempty" json:"volatility,omitempty"`
}

BriefAssetsAssetCodeOptionsSecidGetParams defines parameters for BriefAssetsAssetCodeOptionsSecidGet.

type CalculatePortfolioGraphRequest added in v0.2.0

type CalculatePortfolioGraphRequest struct {
	Indicator string `json:"indicator"` // Тип графика (path segment).
}

type CalculatedPortfolio

type CalculatedPortfolio struct {
	// InitialMargin  Рассчитанное значение гарантийного обеспечения
	InitialMargin *float64 `json:"initial_margin,omitempty"`

	// Positions Рассчитанные позиции
	Positions []CalculatedPosition `json:"positions"`

	// Total Всего
	Total CalculatedTotal `json:"total"`
}

CalculatedPortfolio Рассчитанный опционный портфель

type CalculatedPosition

type CalculatedPosition struct {
	// DaysUntilExpiring Дней до экспирации
	DaysUntilExpiring *int `json:"days_until_expiring,omitempty"`

	// Delta Дельта, пунктов
	Delta *float64 `json:"delta,omitempty"`

	// ExpirationDate Дата погашения
	ExpirationDate *Date `json:"expiration_date,omitempty"`

	// Expired Признак экспирации фьючерса/опциона
	Expired *bool `json:"expired,omitempty"`

	// Fee Комиссия, руб
	Fee *float64 `json:"fee,omitempty"`

	// Gamma Гамма, пунктов
	Gamma *float64 `json:"gamma,omitempty"`

	// Price Цена покупки
	Price *float64 `json:"price,omitempty"`

	// ProfitAndLoss Прибыль/убыток, пунктов
	ProfitAndLoss *float64 `json:"profit_and_loss,omitempty"`

	// ProfitAndLossRub Прибыль/убыток, руб
	ProfitAndLossRub *float64 `json:"profit_and_loss_rub,omitempty"`

	// Quantity Количество покупки (отрицательное число - продажа)
	Quantity int `json:"quantity"`

	// Rho Ро, пунктов
	Rho *float64 `json:"rho,omitempty"`

	// Secid Торговый код опциона
	Secid string `json:"secid"`

	// Strike Cтрайк
	Strike *float64 `json:"strike,omitempty"`

	// Theorprice Теор цена, пунктов
	Theorprice *float64 `json:"theorprice,omitempty"`

	// Theta Тета, пунктов
	Theta *float64 `json:"theta,omitempty"`

	// Type Вид торгового инструмента
	Type SimulatedPositionType `json:"type"`

	// Vega Вега, пунктов
	Vega *float64 `json:"vega,omitempty"`

	// Volatility Волатильность, процентов
	Volatility *float64 `json:"volatility,omitempty"`
}

CalculatedPosition Рассчитанные показатели

type CalculatedTotal

type CalculatedTotal struct {
	// Delta Дельта, пунктов
	Delta *float64 `json:"delta,omitempty"`

	// Fee Комиссия, руб
	Fee *float64 `json:"fee,omitempty"`

	// Gamma Гамма, пунктов
	Gamma *float64 `json:"gamma,omitempty"`

	// ProfitAndLoss Прибыль/убыток, пунктов
	ProfitAndLoss *float64 `json:"profit_and_loss,omitempty"`

	// ProfitAndLossRub Прибыль/убыток, руб
	ProfitAndLossRub *float64 `json:"profit_and_loss_rub,omitempty"`

	// Rho Ро, пунктов
	Rho *float64 `json:"rho,omitempty"`

	// Theta Тета, пунктов
	Theta *float64 `json:"theta,omitempty"`

	// Vega Вега, пунктов
	Vega *float64 `json:"vega,omitempty"`
}

CalculatedTotal Рассчитанные суммарные показатели

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the MOEX Options Calculator API client. It is immutable after construction and safe for concurrent use.

func NewClient added in v0.2.0

func NewClient(endpoint string, opts ...ClientOption) (*Client, error)

NewClient builds a Client targeting endpoint, applying any options. Use EndpointProduction for the public MOEX ISS host. Returns *ConfigError on an empty endpoint.

func (*Client) CalculateInitialMargin

func (c *Client) CalculateInitialMargin(
	ctx context.Context,
	req []InitialMarginPosition,
) (float64, error)

CalculateInitialMargin returns the initial margin. POST /portfolio/initial_margin.

func (*Client) CalculatePortfolio

func (c *Client) CalculatePortfolio(
	ctx context.Context,
	req OptionPortfolio,
) (*CalculatedPortfolio, error)

CalculatePortfolio returns portfolio greeks and P&L. POST /portfolio/.

func (*Client) CalculatePortfolioGraph

func (c *Client) CalculatePortfolioGraph(
	ctx context.Context,
	req OptionPortfolio,
	params CalculatePortfolioGraphRequest,
) (*IndicatorGraph, error)

CalculatePortfolioGraph returns a scenario graph. POST /portfolio/graph/{indicator}.

func (*Client) GetAsset

func (c *Client) GetAsset(
	ctx context.Context,
	params GetAssetRequest,
) (*Asset, error)

GetAsset returns a single underlying. GET /assets/{asset_code}.

func (*Client) GetOption

func (c *Client) GetOption(
	ctx context.Context,
	params GetOptionRequest,
) (*OptionBrief, error)

GetOption returns greeks/IV for one option. GET /assets/{asset_code}/options/{secid}.

func (*Client) GetOptionBoard

func (c *Client) GetOptionBoard(
	ctx context.Context,
	params GetOptionBoardRequest,
) (*OptionBoard, error)

GetOptionBoard returns the strike×type board. GET .../optionseries/{optionseries_code}/optionboard.

func (*Client) GetOptionSeries

func (c *Client) GetOptionSeries(
	ctx context.Context,
	params GetOptionSeriesRequest,
) (*OptionSeries, error)

GetOptionSeries returns one series. GET /assets/{asset_code}/optionseries/{optionseries_code}.

func (*Client) GetVolatilityGraph

func (c *Client) GetVolatilityGraph(
	ctx context.Context,
	params GetVolatilityGraphRequest,
) ([]VolatilityGraphPoint, error)

GetVolatilityGraph returns IV smile points. GET .../optionseries/{optionseries_code}/volatility_graph.

func (*Client) ListAssets

func (c *Client) ListAssets(
	ctx context.Context,
	params ListAssetsRequest,
) ([]Asset, error)

ListAssets returns underlying assets, optionally filtered. GET /assets.

func (*Client) ListFutures

func (c *Client) ListFutures(
	ctx context.Context,
	params ListFuturesRequest,
) ([]Futures, error)

ListFutures returns futures on an underlying. GET /assets/{asset_code}/futures.

func (*Client) ListOptionSeries

func (c *Client) ListOptionSeries(
	ctx context.Context,
	params ListOptionSeriesRequest,
) ([]OptionSeries, error)

ListOptionSeries returns series on an underlying. GET /assets/{asset_code}/optionseries.

func (*Client) ListOptions

func (c *Client) ListOptions(
	ctx context.Context,
	params ListOptionsRequest,
) ([]Option, error)

ListOptions returns options on an underlying. GET /assets/{asset_code}/options.

func (*Client) ListSeriesOptions

func (c *Client) ListSeriesOptions(
	ctx context.Context,
	params ListSeriesOptionsRequest,
) ([]Option, error)

ListSeriesOptions returns options in a series. GET .../optionseries/{optionseries_code}/options.

type ClientOption

type ClientOption func(*config)

ClientOption configures a Client at construction time. See WithHTTPClient. (Named ClientOption, not Option, since Option is the generated model for an option instrument.)

func WithHTTPClient

func WithHTTPClient(h *http.Client) ClientOption

WithHTTPClient sets the *http.Client for outgoing API calls — for a custom Timeout, Transport, proxy, etc. A nil client is ignored: NewClient falls back to restkit's default (30s Timeout, stdlib default Transport).

type ConfigError

type ConfigError = restkit.ConfigError

ConfigError is invalid New construction input.

type Date

type Date struct {
	time.Time
}

Date is a date-only value. It (un)marshals as a bare "2006-01-02" JSON string, keeping external date types out of the public params. A nil *Date means the filter is omitted.

func NewDate

func NewDate(t time.Time) Date

NewDate wraps t as a Date — the blessed way to build one in Go. The wire date is t's calendar day in t's own location, so pass a time already in the zone whose date you mean.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON renders the date as a "2006-01-02" JSON string.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a "2006-01-02" JSON string. A JSON null leaves the zero value in place (callers use *Date, so null is normally absence); any other non-date value (including an empty string) is a parse error, not a silent zero — so a required value-typed Date never decodes a bad value to 0001-01-01.

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a MOEX timestamp. The wire form is a bare "2006-01-02T15:04:05" with no zone, but MOEX times are Moscow-local, so it (un)marshals through Europe/Moscow — the resulting instant is correct (.UTC(), .Unix(), and comparisons all hold), unlike a naive UTC parse. A nil *DateTime means the field is absent.

func NewDateTime

func NewDateTime(t time.Time) DateTime

NewDateTime wraps t as a DateTime, normalizing to the Moscow zone so the instant is preserved and MarshalJSON emits the Moscow wall-clock — the same invariant UnmarshalJSON establishes. The blessed way to build one in Go.

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON renders the timestamp as a "2006-01-02T15:04:05" JSON string in the Moscow wall-clock, so a value from the wire round-trips to the exact string MOEX sent.

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a "2006-01-02T15:04:05" JSON string as Moscow-local time. A JSON null leaves the zero value in place (callers use *DateTime, so null is normally absence); any other non-timestamp value (including an empty string) is a parse error, not a silent zero.

type Futures

type Futures struct {
	// AssetCode Торговый код базового актива
	AssetCode string `json:"asset_code"`

	// AssetType Тип базового актива
	AssetType AssetType `json:"asset_type"`

	// ExpirationDate Дата погашения
	ExpirationDate Date `json:"expiration_date"`

	// FuturesCode Краткий код фьючерса
	FuturesCode string `json:"futures_code"`
}

Futures Фьючерс

type GetAssetRequest added in v0.2.0

type GetAssetRequest struct {
	AssetCode string  `json:"asset_code"`           // Торговый код БА.
	AssetType *string `json:"asset_type,omitempty"` // Тип базового актива.
}

type GetOptionBoardRequest added in v0.2.0

type GetOptionBoardRequest struct {
	AssetCode        string  `json:"asset_code"`           // Торговый код БА.
	OptionseriesCode string  `json:"optionseries_code"`    // Код серии опционов.
	AssetType        *string `json:"asset_type,omitempty"` // Тип базового актива.
	Rows             *int32  `json:"rows,omitempty"`       // Число строк матрицы.
}

type GetOptionRequest added in v0.2.0

type GetOptionRequest struct {
	AssetCode         string   `json:"asset_code"`                    // Торговый код БА.
	Secid             string   `json:"secid"`                         // Торговый код опциона.
	AssetType         *string  `json:"asset_type,omitempty"`          // Тип базового актива.
	DaysUntilExpiring *int32   `json:"days_until_expiring,omitempty"` // Переоценка: дней до экспирации.
	UnderlyingPrice   *float64 `json:"underlying_price,omitempty"`    // Переоценка: цена БА.
	Volatility        *float64 `json:"volatility,omitempty"`          // Переоценка: волатильность.
}

type GetOptionSeriesRequest added in v0.2.0

type GetOptionSeriesRequest struct {
	AssetCode        string  `json:"asset_code"`           // Торговый код БА.
	OptionseriesCode string  `json:"optionseries_code"`    // Код серии опционов.
	AssetType        *string `json:"asset_type,omitempty"` // Тип базового актива.
}

type GetVolatilityGraphRequest added in v0.2.0

type GetVolatilityGraphRequest struct {
	AssetCode        string  `json:"asset_code"`           // Торговый код БА.
	OptionseriesCode string  `json:"optionseries_code"`    // Код серии опционов.
	AssetType        *string `json:"asset_type,omitempty"` // Тип базового актива.
}

type GraphPortfolioGraphIndicatorPostJSONRequestBody

type GraphPortfolioGraphIndicatorPostJSONRequestBody = OptionPortfolio

GraphPortfolioGraphIndicatorPostJSONRequestBody defines body for GraphPortfolioGraphIndicatorPost for application/json ContentType.

type IndicatorGraph

type IndicatorGraph struct {
	// Now На текущую дату
	Now []IndicatorGraphPoint `json:"now"`

	// OnExpiration На дату исполнения
	OnExpiration []IndicatorGraphPoint `json:"on_expiration"`

	// OnWhatIf С условием "что если"
	OnWhatIf *[]IndicatorGraphPoint `json:"on_what_if,omitempty"`
}

IndicatorGraph Графики индикатора

type IndicatorGraphPoint

type IndicatorGraphPoint struct {
	// UnderlyingPrice Цена БА, пунктов
	UnderlyingPrice float64 `json:"underlying_price"`

	// Value Значение индикатора
	Value float64 `json:"value"`
}

IndicatorGraphPoint Точка на графике индикатора

type IndicatorType

type IndicatorType string

IndicatorType Вид индикатора

const (
	Delta         IndicatorType = "delta"
	Gamma         IndicatorType = "gamma"
	ProfitAndLoss IndicatorType = "profit_and_loss"
	Rho           IndicatorType = "rho"
	Theta         IndicatorType = "theta"
	Vega          IndicatorType = "vega"
)

Defines values for IndicatorType.

type InitialMarginPortfolioInitialMarginPostJSONBody

type InitialMarginPortfolioInitialMarginPostJSONBody = []InitialMarginPosition

InitialMarginPortfolioInitialMarginPostJSONBody defines parameters for InitialMarginPortfolioInitialMarginPost.

type InitialMarginPortfolioInitialMarginPostJSONRequestBody

type InitialMarginPortfolioInitialMarginPostJSONRequestBody = InitialMarginPortfolioInitialMarginPostJSONBody

InitialMarginPortfolioInitialMarginPostJSONRequestBody defines body for InitialMarginPortfolioInitialMarginPost for application/json ContentType.

type InitialMarginPosition

type InitialMarginPosition struct {
	// NettedIm Признак неттирования гарантийного обеспечения
	NettedIm *bool `json:"netted_im,omitempty"`

	// Price Цена покупки
	Price float64 `json:"price"`

	// Quantity Количество покупки (отрицательное число - продажа)
	Quantity int `json:"quantity"`

	// Secid Торговый код фьючерса или опциона
	Secid string `json:"secid"`
}

InitialMarginPosition Позиция для расчета гарантийного обеспечения

type ListAssetsRequest added in v0.2.0

type ListAssetsRequest struct {
	AssetType    *string `json:"asset_type,omitempty"`    // Тип базового актива.
	AssetSubtype *string `json:"asset_subtype,omitempty"` // Подтип базового актива для фьючерсов.
	Query        *string `json:"query,omitempty"`         // Фильтр названия БА.
}

type ListFuturesRequest added in v0.2.0

type ListFuturesRequest struct {
	AssetCode      string `json:"asset_code"`                // Торговый код базового актива (фьючерса).
	ExpirationDate *Date  `json:"expiration_date,omitempty"` // Дата погашения.
}

type ListOptionSeriesRequest added in v0.2.0

type ListOptionSeriesRequest struct {
	AssetCode string  `json:"asset_code"`           // Торговый код БА.
	AssetType *string `json:"asset_type,omitempty"` // Тип базового актива.
}

type ListOptionsRequest added in v0.2.0

type ListOptionsRequest struct {
	AssetCode      string   `json:"asset_code"`                // Торговый код БА.
	AssetType      *string  `json:"asset_type,omitempty"`      // Тип базового актива.
	ExpirationDate *Date    `json:"expiration_date,omitempty"` // Дата исполнения.
	OptionType     *string  `json:"option_type,omitempty"`     // Тип опциона (call/put).
	SeriesType     *string  `json:"series_type,omitempty"`     // Тип серии.
	Strike         *float64 `json:"strike,omitempty"`          // Страйк.
}

type ListSeriesOptionsRequest added in v0.2.0

type ListSeriesOptionsRequest struct {
	AssetCode        string  `json:"asset_code"`            // Торговый код БА.
	OptionseriesCode string  `json:"optionseries_code"`     // Код серии опционов.
	AssetType        *string `json:"asset_type,omitempty"`  // Тип базового актива.
	OptionType       *string `json:"option_type,omitempty"` // Тип опциона (call/put).
	// Strike is *int32 here (spec: integer) — deliberately unlike
	// ListOptionsRequest.Strike, which is *float64 (spec: number). Don't "fix"
	// the mismatch; the two endpoints declare different wire types.
	Strike *int32 `json:"strike,omitempty"` // Страйк.
}

type Option

type Option struct {
	// AssetCode Торговый код базового актива
	AssetCode string `json:"asset_code"`

	// AssetType Тип базового актива
	AssetType AssetType `json:"asset_type"`

	// ExpirationDate Дата исполнения
	ExpirationDate Date `json:"expiration_date"`

	// FuturesCode Код фьючерса, если применимо
	FuturesCode *string `json:"futures_code,omitempty"`

	// OptionType Тип опциона (call, put)
	OptionType OptionType `json:"option_type"`

	// Secid Торговый код опциона
	Secid string `json:"secid"`

	// SeriesType Вид серии опционов
	SeriesType OptionSeriesType `json:"series_type"`

	// Strike Cтрайк
	Strike float64 `json:"strike"`
}

Option Опцион

type OptionBoard

type OptionBoard struct {
	// Call Опционы на покупку
	Call []OptionBoardRow `json:"call"`

	// Put Опционы на продажу
	Put []OptionBoardRow `json:"put"`
}

OptionBoard Доска опционов

type OptionBoardRow

type OptionBoardRow struct {
	// Bid Спрос, пунктов, руб
	Bid *float64 `json:"bid,omitempty"`

	// Delta Дельта, пунктов
	Delta *float64 `json:"delta,omitempty"`

	// Gamma Гамма, пунктов
	Gamma *float64 `json:"gamma,omitempty"`

	// IntrinsicValue Внутренняя стоимость, пунктов
	IntrinsicValue *float64 `json:"intrinsic_value,omitempty"`

	// Last Последняя цена, пунктов
	Last *float64 `json:"last,omitempty"`

	// Numtrades Количество сделок
	Numtrades *int `json:"numtrades,omitempty"`

	// Offer Предложение, пунктов, руб
	Offer *float64 `json:"offer,omitempty"`

	// Rho Ро, пунктов
	Rho *float64 `json:"rho,omitempty"`

	// Secid Торговый код опциона
	Secid string `json:"secid"`

	// Strike Страйк, пунктов
	Strike float64 `json:"strike"`

	// Theorprice Теоретическая цена опциона, пунктов
	Theorprice *float64 `json:"theorprice,omitempty"`

	// TheorpriceRub Теоретическая цена опциона, руб
	TheorpriceRub *float64 `json:"theorprice_rub,omitempty"`

	// Theta Тета, пунктов
	Theta *float64 `json:"theta,omitempty"`

	// TimedValue ВременнАя стоимость, пунктов
	TimedValue *float64 `json:"timed_value,omitempty"`

	// Vega Вега, пунктов
	Vega *float64 `json:"vega,omitempty"`

	// Volatility Волатильность, процентов
	Volatility *float64 `json:"volatility,omitempty"`
}

OptionBoardRow Опцион с индикаторами

type OptionBrief

type OptionBrief struct {
	// DaysUntilExpiring Дней до исполнения
	DaysUntilExpiring int `json:"days_until_expiring"`

	// Delta Дельта, пунктов
	Delta *float64 `json:"delta,omitempty"`

	// ExpiringDate Дата исполнения опциона, формат YYYY-MM-DD
	ExpiringDate Date `json:"expiring_date"`

	// Fee Комиссия, руб
	Fee *float64 `json:"fee,omitempty"`

	// Gamma Гамма, пунктов
	Gamma *float64 `json:"gamma,omitempty"`

	// Lastprice Последняя цена базового актива, руб
	Lastprice float64 `json:"lastprice"`

	// Rho Ро, пунктов
	Rho *float64 `json:"rho,omitempty"`

	// Secid Торговый код опциона
	Secid string `json:"secid"`

	// Settleprice Расчетная цена БА, руб
	Settleprice float64 `json:"settleprice"`

	// Theorprice Теор цена, пунктов
	Theorprice float64 `json:"theorprice"`

	// Theta Тета, пунктов
	Theta *float64 `json:"theta,omitempty"`

	// UnderlyingAsset Базовый актив
	UnderlyingAsset string `json:"underlying_asset"`

	// UnderlyingPrice Цена БА, пунктов
	UnderlyingPrice float64 `json:"underlying_price"`

	// UnderlyingType Тип базового актива
	UnderlyingType AssetType `json:"underlying_type"`

	// Vega Вега, пунктов
	Vega *float64 `json:"vega,omitempty"`

	// Volatility Волатильность, процентов
	Volatility float64 `json:"volatility"`
}

OptionBrief Расчетные параметры для выбранного опциона

type OptionPortfolio

type OptionPortfolio struct {
	// AssetCode Торговый код базового актива
	AssetCode string `json:"asset_code"`

	// AssetType Тип базового актива
	AssetType *AssetType `json:"asset_type,omitempty"`

	// Positions Моделируемые позиции
	Positions []SimulatedPosition `json:"positions"`

	// WhatIf Условие "что если"
	WhatIf *WhatIfCondition `json:"what_if,omitempty"`
}

OptionPortfolio Опционный портфель

type OptionSeries

type OptionSeries struct {
	// AssetCode Торговый код базового актива
	AssetCode string `json:"asset_code"`

	// AssetType Тип базового актива
	AssetType AssetType `json:"asset_type"`

	// Call Суммарно для call-опционов
	Call *OptionSeriesTotals `json:"call,omitempty"`

	// CentralStrike Центральный страйк
	CentralStrike float64 `json:"central_strike"`

	// ExpirationDate Дата погашения
	ExpirationDate Date `json:"expiration_date"`

	// FuturesCode Код фьючерса, если применимо
	FuturesCode *string `json:"futures_code,omitempty"`

	// OptionseriesCode Код серии опциона
	OptionseriesCode string `json:"optionseries_code"`

	// Put Суммарно для put-опционов
	Put *OptionSeriesTotals `json:"put,omitempty"`

	// SeriesType Вид серии опционов
	SeriesType OptionSeriesType `json:"series_type"`

	// Updatetime Время обновления информации
	Updatetime *DateTime `json:"updatetime,omitempty"`
}

OptionSeries Серия опциона с сумарными показателями по входящим в серию опционам

type OptionSeriesAssetsAssetCodeOptionseriesOptionseriesCodeGetParams

type OptionSeriesAssetsAssetCodeOptionseriesOptionseriesCodeGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`
}

OptionSeriesAssetsAssetCodeOptionseriesOptionseriesCodeGetParams defines parameters for OptionSeriesAssetsAssetCodeOptionseriesOptionseriesCodeGet.

type OptionSeriesTotals

type OptionSeriesTotals struct {
	// Oichange Изменение числа открытых позиций
	Oichange *int `json:"oichange,omitempty"`

	// Openposition Число открытых позиций
	Openposition *int `json:"openposition,omitempty"`

	// VolumeContracts Объем контрактов
	VolumeContracts *int `json:"volume_contracts,omitempty"`

	// VolumeRub Объем в рублях
	VolumeRub *float64 `json:"volume_rub,omitempty"`
}

OptionSeriesTotals Суммарные показатели

type OptionSeriesType

type OptionSeriesType string

OptionSeriesType Тип серии опциона

const (
	M OptionSeriesType = "M"
	Q OptionSeriesType = "Q"
	W OptionSeriesType = "W"
)

Defines values for OptionSeriesType.

type OptionType

type OptionType string

OptionType Тип опциона

const (
	Call OptionType = "call"
	Put  OptionType = "put"
)

Defines values for OptionType.

type OptionboardAssetsAssetCodeOptionseriesOptionseriesCodeOptionboardGetParams

type OptionboardAssetsAssetCodeOptionseriesOptionseriesCodeOptionboardGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`

	// Rows Количество строк от центрального страйка
	Rows *int `form:"rows,omitempty" json:"rows,omitempty"`
}

OptionboardAssetsAssetCodeOptionseriesOptionseriesCodeOptionboardGetParams defines parameters for OptionboardAssetsAssetCodeOptionseriesOptionseriesCodeOptionboardGet.

type OptionsAssetsAssetCodeOptionseriesOptionseriesCodeOptionsGetParams

type OptionsAssetsAssetCodeOptionseriesOptionseriesCodeOptionsGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`

	// Strike Cтрайк
	Strike *int `form:"strike,omitempty" json:"strike,omitempty"`

	// OptionType Тип опциона (call, put)
	OptionType *OptionType `form:"option_type,omitempty" json:"option_type,omitempty"`
}

OptionsAssetsAssetCodeOptionseriesOptionseriesCodeOptionsGetParams defines parameters for OptionsAssetsAssetCodeOptionseriesOptionseriesCodeOptionsGet.

type PortfolioPortfolioPostJSONRequestBody

type PortfolioPortfolioPostJSONRequestBody = OptionPortfolio

PortfolioPortfolioPostJSONRequestBody defines body for PortfolioPortfolioPost for application/json ContentType.

type RequestError

type RequestError = restkit.RequestError

RequestError is a per-call failure; Op names the stage and Err wraps the cause.

type ResponseError

type ResponseError = restkit.ResponseError

ResponseError is a non-2xx MOEX API response (status + raw body).

type SimulatedPosition

type SimulatedPosition struct {
	// NettedIm Признак неттирования гарантийного обеспечения
	NettedIm *bool `json:"netted_im,omitempty"`

	// Price Цена покупки
	Price *float64 `json:"price,omitempty"`

	// Quantity Количество покупки (отрицательное число - продажа)
	Quantity int `json:"quantity"`

	// Secid Торговый код
	Secid string `json:"secid"`

	// Type Вид торгового инструмента
	Type *SimulatedPositionType `json:"type,omitempty"`

	// Volatility Волатильность, процентов
	Volatility *float64 `json:"volatility,omitempty"`
}

SimulatedPosition Моделируемая позиция

type SimulatedPositionType

type SimulatedPositionType string

SimulatedPositionType Вид тикера в моделируемой позиции

const (
	SimulatedPositionTypeCommodity SimulatedPositionType = "commodity"
	SimulatedPositionTypeCurrency  SimulatedPositionType = "currency"
	SimulatedPositionTypeFutures   SimulatedPositionType = "futures"
	SimulatedPositionTypeOption    SimulatedPositionType = "option"
	SimulatedPositionTypeShare     SimulatedPositionType = "share"
)

Defines values for SimulatedPositionType.

type VolatilityGraphAssetsAssetCodeOptionseriesOptionseriesCodeVolatilityGraphGetParams

type VolatilityGraphAssetsAssetCodeOptionseriesOptionseriesCodeVolatilityGraphGetParams struct {
	// AssetType Тип базового актива
	AssetType *AssetType `form:"asset_type,omitempty" json:"asset_type,omitempty"`
}

VolatilityGraphAssetsAssetCodeOptionseriesOptionseriesCodeVolatilityGraphGetParams defines parameters for VolatilityGraphAssetsAssetCodeOptionseriesOptionseriesCodeVolatilityGraphGet.

type VolatilityGraphPoint

type VolatilityGraphPoint struct {
	// Strike Страйк, пунктов
	Strike float64 `json:"strike"`

	// Volatility Волатильность, процентов
	Volatility float64 `json:"volatility"`
}

VolatilityGraphPoint Точка на графике волатильности

type WhatIfCondition

type WhatIfCondition struct {
	// DateOfCalculation Дата рассчета
	DateOfCalculation *Date `json:"date_of_calculation,omitempty"`

	// DeltaSigma Смещение волатильности, процентов
	DeltaSigma *float64 `json:"delta_sigma,omitempty"`
}

WhatIfCondition Условие 'что если'

Directories

Path Synopsis
Package spec embeds the dereferenced OpenAPI document from the codegen pipeline so downstream modules consume it without re-running Docker.
Package spec embeds the dereferenced OpenAPI document from the codegen pipeline so downstream modules consume it without re-running Docker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL