domain

package
v0.0.0-...-74f9a32 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HistoricCandleToSliceClose

func HistoricCandleToSliceClose(candles []*HistoricCandle) []decimal.Decimal

Types

type AccessLevel

type AccessLevel int32

AccessLevel Уровень доступа к счёту.

const (
	AccessLevelUnspecified AccessLevel = 0 // Уровень доступа не определён.
	AccessLevelFullAccess  AccessLevel = 1 // Полный доступ к счёту.
	AccessLevelReadOnly    AccessLevel = 2 // Доступ с уровнем прав "только чтение".
	AccessLevelNoAccess    AccessLevel = 3 // Доступ отсутствует.
)

type Account

type Account struct {
	// Идентификатор счёта.
	Id string
	// Тип счёта.
	Type AccountType
	// Название счёта.
	Name string
	// Статус счёта.
	Status AccountStatus
	// Дата открытия счёта в часовом поясе UTC.
	OpenedDate time.Time
	// Дата закрытия счёта в часовом поясе UTC.
	ClosedDate time.Time
	// Уровень доступа к текущему счёту (определяется токеном).
	AccessLevel AccessLevel
}

type AccountStatus

type AccountStatus int32

AccountStatus Статус счёта.

const (
	AccountStatusUnspecified AccountStatus = 0 // Статус счёта не определён.
	AccountStatusNew         AccountStatus = 1 // Новый, в процессе открытия.
	AccountStatusOpen        AccountStatus = 2 // Открытый и активный счёт.
	AccountStatusClosed      AccountStatus = 3 // Закрытый счёт.
)

type AccountType

type AccountType int32

AccountType Тип счёта.

const (
	AccountTypeUnspecified AccountType = 0 // Тип аккаунта не определён.
	AccountTypeTinkoff     AccountType = 1 // Брокерский счёт Тинькофф.
	AccountTypeTinkoffIis  AccountType = 2 // ИИС счёт.
	AccountTypeInvestBox   AccountType = 3 // Инвесткопилка.
)

type CandleInterval

type CandleInterval int
const (
	CandleIntervalUnspecified CandleInterval = iota
	CandleInterval1Min
	CandleInterval5Min
	CandleInterval15Min
	CandleInterval1Hour
	CandleInterval1Day
)

func (*CandleInterval) ToDuration

func (c *CandleInterval) ToDuration() time.Duration

type HistoricCandle

type HistoricCandle struct {
	Open       decimal.Decimal
	High       decimal.Decimal
	Low        decimal.Decimal
	Close      decimal.Decimal
	Volume     int64
	Time       time.Time
	IsComplete bool
}

type LastPrice

type LastPrice struct {
	// Идентификатор инструмента.
	Figi string
	// Последняя цена за 1 инструмент. Для получения стоимости лота требуется умножить на лотность инструмента.
	Price decimal.Decimal
	// Время получения последней цены в часовом поясе UTC по времени биржи.
	Time time.Time
}

LastPrice Информация о цене.

type MoneyValue

type MoneyValue struct {
	Currency string
	Value    decimal.Decimal
}

type OrderDirection

type OrderDirection int32
const (
	OrderDirectionUnspecified OrderDirection = 0 // Значение не указано
	OrderDirectionBuy         OrderDirection = 1 // Покупка
	OrderDirectionSell        OrderDirection = 2 // Продажа
)

type OrderExecutionReportStatus

type OrderExecutionReportStatus int32

OrderExecutionReportStatus Текущий статус заявки (поручения)

const (
	OrderExecutionReportStatusUnspecified   OrderExecutionReportStatus = 0
	OrderExecutionReportStatusFill          OrderExecutionReportStatus = 1 // Исполнена
	OrderExecutionReportStatusRejected      OrderExecutionReportStatus = 2 // Отклонена
	OrderExecutionReportStatusCancelled     OrderExecutionReportStatus = 3 // Отменена пользователем
	OrderExecutionReportStatusNew           OrderExecutionReportStatus = 4 // Новая
	OrderExecutionReportStatusPartiallyfill OrderExecutionReportStatus = 5 // Частично исполнена
)

func (OrderExecutionReportStatus) InProcess

func (o OrderExecutionReportStatus) InProcess() bool

type OrderStage

type OrderStage struct {
	Price    *MoneyValue // Цена за 1 инструмент. Для получения стоимости лота требуется умножить на лотность инструмента..
	Quantity int64       // Количество лотов.
	TradeId  string      // Идентификатор торговой операции.
}

OrderStage Сделки в рамках торгового поручения.

type OrderState

type OrderState struct {
	OrderId               string
	ExecutionReportStatus OrderExecutionReportStatus // Текущий статус заявки.
	LotsRequested         int64
	LotsExecuted          int64
	InitialOrderPrice     *MoneyValue // Начальная цена заявки. Произведение количества запрошенных лотов на цену.
	ExecutedOrderPrice    *MoneyValue // Исполненная цена заявки. Произведение средней цены покупки на количество лотов.
	TotalOrderAmount      *MoneyValue // Итоговая стоимость заявки, включающая все комиссии.
	AveragePositionPrice  *MoneyValue // Средняя цена позиции по сделке.
	InitialCommission     *MoneyValue // Начальная комиссия. Комиссия, рассчитанная на момент подачи заявки.
	ExecutedCommission    *MoneyValue // Фактическая комиссия по итогам исполнения заявки.
	Figi                  string
	Direction             OrderDirection
	InitialSecurityPrice  *MoneyValue   // Начальная цена за 1 инструмент. Для получения стоимости лота требуется умножить на лотность инструмента.
	Stages                []*OrderStage // Стадии выполнения заявки.
	ServiceCommission     *MoneyValue   // Сервисная комиссия.
	Currency              string        // Валюта заявки.
	OrderType             OrderType     // Тип заявки.
	OrderDate             time.Time     // Дата и время выставления заявки в часовом поясе UTC.
}

OrderState Информация о торговом поручении.

type OrderType

type OrderType int32
const (
	OrderTypeUnspecified OrderType = 0 // Значение не указано
	OrderTypeLimit       OrderType = 1 // Лимитная
	OrderTypeMarket      OrderType = 2 // Рыночная
)

type PortfolioPosition

type PortfolioPosition struct {
	Figi                     string
	InstrumentType           string
	Quantity                 decimal.Decimal // Количество инструмента в портфеле в штуках.
	AveragePositionPrice     *MoneyValue     // Средневзвешенная цена позиции. **Возможна задержка до секунды для пересчёта**.
	ExpectedYield            decimal.Decimal // Текущая рассчитанная относительная доходность позиции, в %.
	CurrentNkd               *MoneyValue     // Текущий НКД.
	AveragePositionPricePt   decimal.Decimal // Средняя цена лота в позиции в пунктах (для фьючерсов). **Возможна задержка до секунды для пересчёта**.
	CurrentPrice             *MoneyValue     // Текущая цена за 1 инструмент. Для получения стоимости лота требуется умножить на лотность инструмента.
	AveragePositionPriceFifo *MoneyValue     // Средняя цена лота в позиции по методу FIFO. **Возможна задержка до секунды для пересчёта**.
	QuantityLots             decimal.Decimal // Количество лотов в портфеле.
}

PortfolioPosition Позиции портфеля.

type PositionsResponse

type PositionsResponse struct {
	// Массив валютных позиций портфеля.
	Money []*MoneyValue
	// Массив заблокированных валютных позиций портфеля.
	Blocked []*MoneyValue
	// Список ценно-бумажных позиций портфеля.
	Securities []*PositionsSecurities
	// Признак идущей в данный момент выгрузки лимитов.
	LimitsLoadingInProgress bool
}

PositionsResponse Список позиций по счёту.

type PositionsSecurities

type PositionsSecurities struct {
	// Figi-идентификатор бумаги.
	Figi string
	// Заблокировано.
	Blocked int64
	// Текущий незаблокированный баланс.
	Balance int64
}

PositionsSecurities Баланс позиции ценной бумаги.

type PostOrderResponse

type PostOrderResponse struct {
	OrderId               string
	ExecutionReportStatus OrderExecutionReportStatus
	LotsRequested         int64
	LotsExecuted          int64
	InitialOrderPrice     *MoneyValue
	ExecutedOrderPrice    *MoneyValue
	TotalOrderAmount      *MoneyValue
	InitialCommission     *MoneyValue
	ExecutedCommission    *MoneyValue
	AciValue              *MoneyValue
	Figi                  string
	Direction             OrderDirection
	InitialSecurityPrice  *MoneyValue
	OrderType             OrderType
	Message               string
	InitialOrderPricePt   decimal.Decimal
}

type SecurityTradingStatus

type SecurityTradingStatus int32
const (
	// SecurityTradingStatusUnspecified Торговый статус не определён
	SecurityTradingStatusUnspecified SecurityTradingStatus = 0
	// SecurityTradingStatusNotAvailableForTrading Недоступен для торгов
	SecurityTradingStatusNotAvailableForTrading SecurityTradingStatus = 1
	// SecurityTradingStatusOpeningPeriod Период открытия торгов
	SecurityTradingStatusOpeningPeriod SecurityTradingStatus = 2
	// SecurityTradingStatusClosingPeriod Период закрытия торгов
	SecurityTradingStatusClosingPeriod SecurityTradingStatus = 3
	// SecurityTradingStatusBreakInTrading Перерыв в торговле
	SecurityTradingStatusBreakInTrading SecurityTradingStatus = 4
	// SecurityTradingStatusNormalTrading Нормальная торговля
	SecurityTradingStatusNormalTrading SecurityTradingStatus = 5
	// SecurityTradingStatusClosingAuction Аукцион закрытия
	SecurityTradingStatusClosingAuction SecurityTradingStatus = 6
	// SecurityTradingStatusDarkPoolAuction Аукцион крупных пакетов
	SecurityTradingStatusDarkPoolAuction SecurityTradingStatus = 7
	// SecurityTradingStatusDiscreteAuction Дискретный аукцион
	SecurityTradingStatusDiscreteAuction SecurityTradingStatus = 8
	// SecurityTradingStatusOpeningAuctionPeriod Аукцион открытия
	SecurityTradingStatusOpeningAuctionPeriod SecurityTradingStatus = 9
	// SecurityTradingStatusTradingAtClosingAuctionPrice Период торгов по цене аукциона закрытия
	SecurityTradingStatusTradingAtClosingAuctionPrice SecurityTradingStatus = 10
	// SecurityTradingStatusSessionAssigned Сессия назначена
	SecurityTradingStatusSessionAssigned SecurityTradingStatus = 11
	// SecurityTradingStatusSessionClose Сессия закрыта
	SecurityTradingStatusSessionClose SecurityTradingStatus = 12
	// SecurityTradingStatusSessionOpen Сессия открыта
	SecurityTradingStatusSessionOpen SecurityTradingStatus = 13
	// SecurityTradingStatusDealerNormalTrading Доступна торговля в режиме внутренней ликвидности брокера
	SecurityTradingStatusDealerNormalTrading SecurityTradingStatus = 14
	// SecurityTradingStatusDealerBreakInTrading Перерыв торговли в режиме внутренней ликвидности брокера
	SecurityTradingStatusDealerBreakInTrading SecurityTradingStatus = 15
	// SecurityTradingStatusDealerNotAvailableForTrading Недоступна торговля в режиме внутренней ликвидности брокера
	SecurityTradingStatusDealerNotAvailableForTrading SecurityTradingStatus = 16
)

func (SecurityTradingStatus) AllowLimitOrder

func (s SecurityTradingStatus) AllowLimitOrder() bool

AllowLimitOrder Возможность выставлять лимитные заявки

func (SecurityTradingStatus) AllowMarketOrder

func (s SecurityTradingStatus) AllowMarketOrder() bool

AllowMarketOrder Возможность выставлять рыночные заявки

type Share

type Share struct {
	Figi   string
	Ticker string
	// Класс-код (секция торгов).
	ClassCode string
	Isin      string
	Lot       int32
	Currency  string
	Name      string
	// Торговая площадка.
	Exchange string
	// Текущий режим торгов инструмента.
	TradingStatus SecurityTradingStatus
	// Признак внебиржевой ценной бумаги.
	OtcFlag bool
	// Признак доступности для покупки.
	BuyAvailableFlag bool
	// Признак доступности для продажи.
	SellAvailableFlag bool
	// Шаг цены.
	MinPriceIncrement decimal.Decimal
	// Признак доступности торгов через API.
	ApiTradeAvailableFlag bool
	// Уникальный идентификатор инструмента.
	Uid string
}

type Strategy

type Strategy struct {
	Id          string
	StackId     string
	AccountId   string
	RunInterval time.Duration
	Enabled     bool
}

type StrategyLog

type StrategyLog struct {
	LogType StrategyLogType
	Message string
	Time    time.Time
}

type StrategyLogType

type StrategyLogType string
const (
	StrategyLogTypeAction StrategyLogType = "action"
	StrategyLogTypeStart  StrategyLogType = "start"
	StrategyLogTypeError  StrategyLogType = "error"
)

Jump to

Keyboard shortcuts

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