trader

package module
v0.0.0-...-e95496b Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 8 Imported by: 0

README

trader

Framework for building automated trading systems (ATS) in GoLang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine that runs strategies

func NewEngine

func NewEngine() *Engine

NewEngine constructor

func (*Engine) AddExchanger

func (e *Engine) AddExchanger(ex Exchanger)

AddExchanger to engine

func (*Engine) AddStrategy

func (e *Engine) AddStrategy(strategy *Strategy)

AddStrategy to engine

func (*Engine) AddSymbol

func (e *Engine) AddSymbol(symbol string, quotes chan Quote, trades chan Trade)

AddSymbol to engine - quotes and trades for this symbol

func (*Engine) LoadHistory

func (e *Engine) LoadHistory(symbol string, tf Timeframe, reader io.Reader) error

LoadHistory of instrument

func (*Engine) Run

func (e *Engine) Run()

Run engine

func (*Engine) Stop

func (e *Engine) Stop()

Stop engine

type Exchanger

type Exchanger interface {
	Orders() []Order
	Positions() []Position

	NewOrder(Order) (string, error)
	CancelOrder(string) (bool, error)
}

Exchanger interface

type History

type History struct {
	TimeSeries map[Timeframe]map[time.Time]*OHLC
}

History for symbol

type Level

type Level struct {
	Price float64
	Size  int
}

Level for price/size

type OHLC

type OHLC struct {
	Open, High, Low, Close, Volume float64
}

OHLC structure

type Order

type Order struct {
	ID     string
	Symbol string
	Price  float64
	Amount int
	Type   OrderType
}

Order abstration

type OrderType

type OrderType uint

OrderType for orders

const (
	Limit OrderType = iota
	Stop
	Market
)

Limit,Stop,Market types

type Position

type Position struct {
	Symbol string
	Price  float64
	Amount int
}

Position abstraction

type Quote

type Quote struct {
	//TODO refactor into int
	Bid, Ask float64
}

Quote type

type Signal

type Signal struct {
	Strategy                               *Strategy
	BuyOpen, BuyClose, SellOpen, SellClose []Level
}

Signal - signal of strategy

type Strategy

type Strategy struct {
	Symbol  string
	Code    string
	Title   string
	Parts   int
	Size    int
	Decimal int

	OnTick func(*Engine) (Signal, error)
	Init   func(*Engine) error
}

Strategy struct

type Timeframe

type Timeframe uint8

Timeframe type

const (
	M1 Timeframe = iota
	M5
	M15
	M30
	H1
	H4
	D1
)

Timeframes

type Trade

type Trade struct {
	Price, Amount float64
	Time          time.Time
}

Trade type

Directories

Path Synopsis
exchangers

Jump to

Keyboard shortcuts

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