bullsbearsmon

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderPlacer

type OrderPlacer interface {
	SubscribeForOrderBookChanges(ctx context.Context, reqs []tinkoffinvest.OrderBookRequest) (<-chan tinkoffinvest.OrderBookChange, error) //nolint:lll
	WaitForOrderExecution(ctx context.Context, _ tinkoffinvest.AccountID, _ tinkoffinvest.OrderID) (decimal.Decimal, error)

	PlaceMarketSellOrder(ctx context.Context, request tinkoffinvest.PlaceOrderRequest) (tinkoffinvest.OrderID, error)
	PlaceMarketBuyOrder(ctx context.Context, request tinkoffinvest.PlaceOrderRequest) (tinkoffinvest.OrderID, error)
	PlaceLimitSellOrder(ctx context.Context, request tinkoffinvest.PlaceOrderRequest) (tinkoffinvest.OrderID, error)
	PlaceLimitBuyOrder(ctx context.Context, request tinkoffinvest.PlaceOrderRequest) (tinkoffinvest.OrderID, error)
}

type Strategy

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

Strategy realize the next strategy: if there are more lots in buy orders than in sell orders in ToolConfig.DominanceRatio times, then the robot buys the instrument at the market price, otherwise it sells, immediately placing an order in the opposite direction, but with a certain percentage of profit.

func New

func New(
	account tinkoffinvest.AccountID,
	ignoreInconsistent bool,
	tools []ToolConfig,
	orderPlacer OrderPlacer,
	toolsCache ToolsCache,
) (*Strategy, error)

func (*Strategy) Apply

Apply applies Strategy to the next order book change.

func (*Strategy) Name

func (s *Strategy) Name() string

func (*Strategy) Run

func (s *Strategy) Run(ctx context.Context) error

Run starts order book monitoring and calls Apply on every new change.

type ToolConfig

type ToolConfig struct {
	FIGI             tinkoffinvest.FIGI
	Depth            int
	DominanceRatio   float64
	ProfitPercentage float64
	// contains filtered or unexported fields
}

type ToolsCache

type ToolsCache interface {
	Get(ctx context.Context, figi tinkoffinvest.FIGI) (toolscache.Tool, error)
}

Directories

Path Synopsis
Package bullsbearsmonmocks is a generated GoMock package.
Package bullsbearsmonmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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