bot

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const QUANTITY = 1

QUANTITY - Кол-во лотов инструментов, которыми торгует бот

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	StrategyConfig OrderBookStrategyConfig
	Client         *investgo.Client
	// contains filtered or unexported fields
}

func NewBot

func NewBot(ctx context.Context, c *investgo.Client, config OrderBookStrategyConfig) (*Bot, error)

NewBot - Создание экземпляра бота на стакане

func (*Bot) HandleOrderBooks

func (b *Bot) HandleOrderBooks(ctx context.Context, orderBooks chan OrderBook) (float64, error)

HandleOrderBooks - нужно вызвать асинхронно, будет писать в канал id инструментов, которые нужно купить или продать

func (*Bot) Run

func (b *Bot) Run() error

Run - Запуск бота

func (*Bot) Stop

func (b *Bot) Stop()

Stop - Принудительное завершение работы бота, если SellOut = true, то бот выходит из всех активных позиций, которые он открыл

type Executor

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

Executor - Вызывается ботом и исполняет торговые поручения

func NewExecutor

func NewExecutor(ctx context.Context, c *investgo.Client, ids map[string]Instrument, minProfit float64) *Executor

NewExecutor - Создание экземпляра исполнителя

func (*Executor) Buy

func (e *Executor) Buy(id string) error

Buy - Метод покупки инструмента с идентификатором id

func (*Executor) Sell

func (e *Executor) Sell(id string) (float64, error)

Sell - Метод покупки инструмента с идентификатором id

func (*Executor) SellOut

func (e *Executor) SellOut() (float64, error)

SellOut - Метод выхода из всех ценно-бумажных позиций

func (*Executor) Stop

func (e *Executor) Stop()

Stop - Завершение работы

type Instrument

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

type LastPrices

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

LastPrices - Последние цены инструментов

func NewLastPrices

func NewLastPrices() *LastPrices

func (*LastPrices) Get

func (l *LastPrices) Get(id string) (float64, bool)

Get - получение последней цены

func (*LastPrices) Update

func (l *LastPrices) Update(id string, price float64)

Update - обновление последних цен

type Order

type Order struct {
	Price    float64 `json:"Price"`
	Quantity int64   `json:"Quantity"`
}

type OrderBook

type OrderBook struct {
	Figi          string  `json:"Figi"`
	InstrumentUid string  `json:"InstrumentUid"`
	Depth         int32   `json:"Depth"`
	IsConsistent  bool    `json:"IsConsistent"`
	TimeUnix      int64   `json:"TimeUnix"`
	LimitUp       float64 `json:"LimitUp"`
	LimitDown     float64 `json:"LimitDown"`
	Bids          []Order `json:"Bids"`
	Asks          []Order `json:"Asks"`
}

type OrderBookStrategyConfig

type OrderBookStrategyConfig struct {
	// Instruments - слайс идентификаторов инструментов
	Instruments []string
	// Currency - ISO-код валюты инструментов
	Currency string
	// RequiredMoneyBalance - Минимальный баланс денежных средств в Currency для начала торгов.
	// Для песочницы пополнится автоматически.
	RequiredMoneyBalance float64
	// Depth - Глубина стакана
	Depth int32
	//  Если кол-во бид/аск больше чем BuyRatio - покупаем
	BuyRatio float64
	//  Если кол-во аск/бид больше чем SellRatio - продаем
	SellRatio float64
	// MinProfit - Минимальный процент выгоды, с которым можно совершать сделки
	MinProfit float64
	// SellOut - Если true, то по достижению дедлайна бот выходит из всех активных позиций
	SellOut bool
}

OrderBookStrategyConfig - Конфигурация стратегии на стакане

type Positions

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

Positions - Данные о позициях счета

func NewPositions

func NewPositions() *Positions

func (*Positions) Get

func (p *Positions) Get() *pb.PositionData

Get - получение позиций

func (*Positions) Update

func (p *Positions) Update(data *pb.PositionData)

Update - Обновление позиций

Jump to

Keyboard shortcuts

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