moex

package
v0.0.0-...-618a704 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURL = "https://iss.moex.com"

DefaultURL содержит корневой URL сервиса ISS по умолчанию

Variables

View Source
var (
	// EOF обозначает конец выгрузки
	EOF = errors.New("end of data")
)
View Source
var ErrWrongPropertyType = errors.New("wrong property type")

Functions

This section is empty.

Types

type Amortization

type Amortization struct {
	ISIN             string           `json:"isin"`
	Name             string           `json:"name"`
	IssueValue       float64          `json:"issuevalue"`
	AmortDate        NullableDate     `json:"amortdate"`
	InitialFaceValue float64          `json:"initialfacevalue"`
	FaceValue        float64          `json:"facevalue"`
	FaceUnit         string           `json:"faceunit"`
	Value            float64          `json:"value"`
	ValuePercent     float64          `json:"valueprc"`
	ValueRub         float64          `json:"value_rub"`
	Type             AmortizationType `json:"data_source"`
}

Amortization описывает амортизацию/погашение облигации

type AmortizationListIterator

type AmortizationListIterator interface {
	// Next загружает следующую страницу данных
	// Если данных больше нет, то возвращается ошибка EOF
	Next() ([]*Amortization, error)
}

AmortizationListIterator определяет итератор для списка амортизаций

type AmortizationListQuery

type AmortizationListQuery struct {
	// Дата, больше либо равно
	From *time.Time

	// Дата, меньше либо равно
	Till *time.Time

	// Статус торгуемой ценной бумаги
	TradingStatus TradingStatus

	// Сколько записей выводить
	Limit int

	// Сколько записей пропускать
	Start int
}

AmortizationListQuery определяет параметры запроса списка амортизаций

type AmortizationType

type AmortizationType string

AmortizationType описывает тип амортизации

const (
	// AmortizationTypeA обозначает тип амортизации - собственно амортизацию
	AmortizationTypeA AmortizationType = "amortization"

	// AmortizationTypeM обозначает тип амортизации - погашение
	AmortizationTypeM AmortizationType = "maturity"
)

type Coupon

type Coupon struct {
	ISIN             string       `json:"isin"`
	Name             string       `json:"name"`
	IssueValue       *float64     `json:"issuevalue"`
	CouponDate       NullableDate `json:"coupondate"`
	RecordDate       NullableDate `json:"recorddate"`
	StartDate        NullableDate `json:"startdate"`
	InitialFaceValue *float64     `json:"initialfacevalue"`
	FaceValue        *float64     `json:"facevalue"`
	FaceUnit         string       `json:"faceunit"`
	Value            *float64     `json:"value"`
	ValuePercent     *float64     `json:"valueprc"`
	ValueRub         *float64     `json:"value_rub"`
}

Coupon описывает купон облигации

type CouponListIterator

type CouponListIterator interface {
	// Next загружает следующую страницу данных
	// Если данных больше нет, то возвращается ошибка EOF
	Next() ([]*Coupon, error)
}

CouponListIterator определяет итератор для списка купонов

type CouponListQuery

type CouponListQuery struct {
	// Дата, больше либо равно
	From *time.Time

	// Дата, меньше либо равно
	Till *time.Time

	// Статус торгуемой ценной бумаги
	TradingStatus TradingStatus

	// Сколько записей выводить
	Limit int

	// Сколько записей пропускать
	Start int
}

CouponListQuery определяет параметры запроса списка купонов

type Date

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

Date представляет дату в JSON формате

func NewDate

func NewDate(str string) (Date, error)

NewDate разбирает значение типа Date из строки

func (Date) Format

func (d Date) Format(layout string) string

Format возвращает строковое представление для значения

func (Date) String

func (d Date) String() string

String возвращает строковое представление для значения

func (Date) Time

func (d Date) Time() time.Time

Time возвращает дату и время

func (*Date) UnmarshalJSON

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

UnmarshalJSON выполняет десериализацию из JSON

type DateTime

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

DateTime представляет дату и время в JSON формате

func (DateTime) Format

func (d DateTime) Format(layout string) string

Format возвращает строковое представление для значения

func (DateTime) String

func (d DateTime) String() string

String возвращает строковое представление для значения

func (DateTime) Time

func (d DateTime) Time() time.Time

Time возвращает дату и время

func (*DateTime) UnmarshalJSON

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

UnmarshalJSON выполняет десериализацию из JSON

type Engine

type Engine string

Engine содержит код движка

const (
	// AnyEngine обозначает любую биржу
	AnyEngine Engine = ""

	// StockEngine обозначает фондовую биржу
	StockEngine Engine = "stock"
)

type Market

type Market string

Market содержит код рынка

const (
	// AnyMarket обозначает любой рынок
	AnyMarket Market = ""

	// BondMarket обозначает рынок облигаций
	BondMarket Market = "bonds"
)

type MarketData

type MarketData struct {
	SecurityID      string
	BoardID         string
	AccruedInterest *float64
	FaceValue       *float64
	Currency        *string
	Last            *float64
	LastChange      *float64
	ClosePrice      *float64
	LegalClosePrice *float64
	Time            *DateTime
}

MarketData описывает итоги торгов по облигации

type NullableDate

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

NullableDate представляет дату в JSON формате, для которой допускается значение nil

func (NullableDate) Format

func (d NullableDate) Format(layout string) string

Format возвращает строковое представление для значения

func (NullableDate) HasValue

func (d NullableDate) HasValue() bool

HasValue возвращает true, если значение - не nil

func (NullableDate) String

func (d NullableDate) String() string

String возвращает строковое представление для значения

func (NullableDate) Time

func (d NullableDate) Time() *time.Time

Time возвращает дату и время

func (*NullableDate) UnmarshalJSON

func (d *NullableDate) UnmarshalJSON(data []byte) error

UnmarshalJSON выполняет десериализацию из JSON

type Offer

type Offer struct {
	ISIN           string       `json:"isin"`
	Name           string       `json:"name"`
	IssueValue     *float64     `json:"issuevalue"`
	OfferDate      NullableDate `json:"offerdate"`
	StartOfferDate NullableDate `json:"offerdatestart"`
	EndOfferDate   NullableDate `json:"offerdateend"`
	FaceValue      *float64     `json:"facevalue"`
	FaceUnit       string       `json:"faceunit"`
	Price          *float64     `json:"price"`
	Value          *float64     `json:"value"`
	Agent          *string      `json:"agent"`
	Type           *OfferType   `json:"offertype"`
}

Offer описывает оферту по облигации

type OfferListIterator

type OfferListIterator interface {
	// Next загружает следующую страницу данных
	// Если данных больше нет, то возвращается ошибка EOF
	Next() ([]*Offer, error)
}

OfferListIterator определяет итератор для списка оферт

type OfferListQuery

type OfferListQuery struct {
	// Дата, больше либо равно
	From *time.Time

	// Дата, меньше либо равно
	Till *time.Time

	// Статус торгуемой ценной бумаги
	TradingStatus TradingStatus

	// Сколько записей выводить
	Limit int

	// Сколько записей пропускать
	Start int
}

OfferListQuery определяет параметры запроса списка оферт

type OfferType

type OfferType string

OfferType содержит тип оферты

const (
	// GenericOffer - оферта
	GenericOffer OfferType = "Оферта"

	// CompletedGenericOffer - состоявшаяся оферта
	CompletedGenericOffer OfferType = "Оферта (состоялось)"

	// CanceledGenericOffer - отмененнная оферта
	CanceledGenericOffer OfferType = "Оферта (отменено)"

	// DefaultGenericOffer - дефолт оферты
	DefaultGenericOffer OfferType = "Оферта (дефолт)"

	// TechDefaultGenericOffer - технический дефолт оферты
	TechDefaultGenericOffer OfferType = "Оферта (технический дефолт)"

	// MaturityOffer - оферта-погашение
	MaturityOffer OfferType = "Оферта/Погашение"

	// CanceledMaturityOffer - отмененнная оферта-погашение
	CanceledMaturityOffer OfferType = "Оферта/Погашение(отменено)"
)

type Option

type Option func(p *provider) error

Option конфигурирует провайдера

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient задает экземпляр http.Client для Provider По умолчанию используется http.DefaultClient

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger задает логгер для Provider По умолчанию логирование отключено

func WithURL

func WithURL(rootURL string) Option

WithURL задает корневой URL сервиса ISS По умолчанию используется DefaultURL

func WithVerbose

func WithVerbose(verbose bool) Option

WithVerbose включает подробное логирование для Provider По умолчанию подробное логирование отключено

type Property

type Property struct {
	Name  PropertyID   `json:"name"`
	Value string       `json:"value"`
	Type  PropertyType `json:"type"`
}

Property содержит отдельный параметр ценной бумаги

func (Property) AsBool

func (p Property) AsBool() (bool, error)

AsBool возвращает значение для свойств типа "boolean"

func (Property) AsDate

func (p Property) AsDate() (Date, error)

AsDate возвращает значение для свойств типа "date"

func (Property) AsFloat64

func (p Property) AsFloat64() (float64, error)

AsFloat64 возвращает значение для свойств типа "number"

func (Property) AsString

func (p Property) AsString() (string, error)

AsString возвращает значение для свойств типа "string"

type PropertyID

type PropertyID string

PropertyID содержит тип параметра ценной бумаги

const (
	IssueDateProperty                   PropertyID = "ISSUEDATE"
	MaturityDateProperty                PropertyID = "MATDATE"
	InitialFaceValueProperty            PropertyID = "INITIALFACEVALUE"
	FaceUnitProperty                    PropertyID = "FACEUNIT"
	ListingLevelProperty                PropertyID = "LISTLEVEL"
	IsForQualifiedInvestorsOnlyProperty PropertyID = "ISQUALIFIEDINVESTORS"
	CouponFrequencyProperty             PropertyID = "COUPONFREQUENCY"
	IsHighRiskProperty                  PropertyID = "HIGHRISK"
)

type PropertyType

type PropertyType string

PropertyType содержит тип значения параметра ценной бумаги

const (
	StringPropertyType  PropertyType = "string"
	DatePropertyType    PropertyType = "date"
	NumberPropertyType  PropertyType = "number"
	BooleanPropertyType PropertyType = "boolean"
)

type Provider

type Provider interface {
	// ListSecurities возвращает итератор на список ценных бумаг
	ListSecurities(ctx context.Context, query SecurityListQuery) SecurityListIterator

	// ListCoupons возвращает итератор на список купонов
	ListCoupons(ctx context.Context, query CouponListQuery) CouponListIterator

	// ListAmortizations возвращает итератор на список амортизаций
	ListAmortizations(ctx context.Context, query AmortizationListQuery) AmortizationListIterator

	// ListOffers возвращает итератор на список оферт
	ListOffers(ctx context.Context, query OfferListQuery) OfferListIterator

	// GetMarketData возвращает текущие рыночные данные
	GetMarketData(ctx context.Context) ([]*MarketData, error)

	// GetSecurityDescription возвращает описание ценной бумаги
	GetSecurityDescription(ctx context.Context, isin string) (*SecurityDescription, error)
}

Provider является точкой входа в адаптер для ISS

func NewProvider

func NewProvider(options ...Option) (Provider, error)

NewProvider создает новый экземпляр интерфейса Provider

type Security

type Security struct {
	ID                 int           `json:"id"`
	SecurityID         string        `json:"secid"`
	ShortName          string        `json:"shortname"`
	RegNumber          string        `json:"regnumber"`
	Name               string        `json:"name"`
	ISIN               string        `json:"isin"`
	IsTraded           TradingStatus `json:"is_traded"`
	IssuerId           int           `json:"emitent_id"`
	IssuerName         string        `json:"emitent_title"`
	IssuerINN          *string       `json:"emitent_inn"`
	IssuerOKPO         *string       `json:"emitent_okpo"`
	Type               SecurityType  `json:"type"`
	PrimaryBoardID     string        `json:"primary_boardid"`
	MarketPriceBoardID string        `json:"marketprice_boardid"`
}

Security описывает ценную бумагу

type SecurityDescription

type SecurityDescription struct {
	Properties map[PropertyID]*Property
}

SecurityDescription содержит набор параметров ценной бумаги

func (SecurityDescription) CouponFrequency

func (desc SecurityDescription) CouponFrequency() (*float64, error)

CouponFrequency возвращает значение параметра CouponFrequencyProperty

func (SecurityDescription) FaceUnit

func (desc SecurityDescription) FaceUnit() (*string, error)

FaceUnit возвращает значение параметра FaceUnitProperty

func (SecurityDescription) InitialFaceValue

func (desc SecurityDescription) InitialFaceValue() (*float64, error)

InitialFaceValue возвращает значение параметра InitialFaceValueProperty

func (SecurityDescription) IsForQualifiedInvestorsOnly

func (desc SecurityDescription) IsForQualifiedInvestorsOnly() (bool, error)

IsForQualifiedInvestorsOnly возвращает значение параметра IsForQualifiedInvestorsOnlyProperty

func (SecurityDescription) IsHighRisk

func (desc SecurityDescription) IsHighRisk() (bool, error)

IsHighRisk возвращает значение параметра IsHighRiskProperty

func (SecurityDescription) IssueDate

func (desc SecurityDescription) IssueDate() (*Date, error)

IssueDate возвращает значение параметра IssueDateProperty

func (SecurityDescription) ListingLevel

func (desc SecurityDescription) ListingLevel() (*float64, error)

ListingLevel возвращает значение параметра ListingLevelProperty

func (SecurityDescription) MaturityDate

func (desc SecurityDescription) MaturityDate() (*Date, error)

MaturityDate возвращает значение параметра MaturityDateProperty

type SecurityListIterator

type SecurityListIterator interface {
	// Next загружает следующую страницу данных
	// Если данных больше нет, то возвращается ошибка EOF
	Next() ([]*Security, error)
}

SecurityListIterator определяет итератор для списка ценных бумаг

type SecurityListQuery

type SecurityListQuery struct {
	// Биржа
	Engine Engine

	// Рынок
	Market Market

	// Статус торгуемой ценной бумаги
	TradingStatus *TradingStatus

	// Сколько записей выводить
	Limit int

	// Сколько записей пропускать
	Start int
}

SecurityListQuery определяет параметры запроса списка ценных бумаг

type SecurityType

type SecurityType string

SecurityType содержит тип ценной бумаги

const (
	// SubfederalBond - субфедеральные облигации
	SubfederalBond SecurityType = "subfederal_bond"

	// OFZBond - ОФЗ
	OFZBond SecurityType = "ofz_bond"

	// ExchangeBond - биржевые облигации
	ExchangeBond SecurityType = "exchange_bond"

	// CBBond - облигации ЦБ
	CBBond SecurityType = "cb_bond"

	// MunicipalBond - мунициальные облигации
	MunicipalBond SecurityType = "municipal_bond"

	// CorporateBond - корпоративные облигации
	CorporateBond SecurityType = "corporate_bond"

	// IFIBond - облигации ИФИ
	IFIBond SecurityType = "ifi_bond"

	// EuroBond - еврооблигации
	EuroBond SecurityType = "euro_bond"
)

type TradingStatus

type TradingStatus int

TradingStatus содержит статус торгуемой ценной бумаги

const (
	// IsTraded обозначает торгуемые ценные бумаги
	IsTraded TradingStatus = 1

	// IsNotTraded обозначает неторгуемые ценные бумаги
	IsNotTraded TradingStatus = 0
)

Jump to

Keyboard shortcuts

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