generatesim

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcPnl

func CalcPnl(side Direction, positionSize float64, entryPrice float64, exitPrice float64, isForwardContract bool) (pnl float64)

Types

type GenerateSim

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

GenerateSim the generate/common exchange for backtest

func NewGenerateSim

func NewGenerateSim(data *dataloader.Data, cash float64, makerFeeRate float64, takerFeeRate float64, isForwardContract bool, posMode ...bool) *GenerateSim

func (*GenerateSim) AmendOrder

func (s *GenerateSim) AmendOrder(symbol string, id string, price float64, size float64, opts ...OrderOption) (result *Order, err error)

func (*GenerateSim) CancelAllOrders

func (s *GenerateSim) CancelAllOrders(symbol string, opts ...OrderOption) (err error)

func (*GenerateSim) CancelOrder

func (s *GenerateSim) CancelOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)

func (*GenerateSim) CloseLong

func (s *GenerateSim) CloseLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)

func (*GenerateSim) CloseShort

func (s *GenerateSim) CloseShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)

func (*GenerateSim) GetBalance

func (s *GenerateSim) GetBalance(symbol string) (result *Balance, err error)

func (*GenerateSim) GetContractID

func (s *GenerateSim) GetContractID() (symbol string, err error)

func (*GenerateSim) GetFee added in v1.1.10

func (s *GenerateSim) GetFee() (fee float64)

func (*GenerateSim) GetName

func (s *GenerateSim) GetName() (name string)

func (*GenerateSim) GetOpenOrders

func (s *GenerateSim) GetOpenOrders(symbol string, opts ...OrderOption) (result []*Order, err error)

func (*GenerateSim) GetOrder

func (s *GenerateSim) GetOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)

func (*GenerateSim) GetOrderBook

func (s *GenerateSim) GetOrderBook(symbol string, depth int) (result *OrderBook, err error)

func (*GenerateSim) GetOrderHistory added in v1.1.10

func (s *GenerateSim) GetOrderHistory(symbol string, opts ...OrderOption) (result []*Order, err error)

func (*GenerateSim) GetPositions

func (s *GenerateSim) GetPositions(symbol string) (result []*Position, err error)

func (*GenerateSim) GetRecords

func (s *GenerateSim) GetRecords(symbol string, period string, from int64, end int64, limit int) (records []*Record, err error)

func (*GenerateSim) GetTime

func (s *GenerateSim) GetTime() (tm int64, err error)

func (*GenerateSim) GetWinRate added in v1.1.10

func (s *GenerateSim) GetWinRate() (longWinRate, shortWinRate, totalWinRate float64)

func (*GenerateSim) OpenLong

func (s *GenerateSim) OpenLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)

func (*GenerateSim) OpenShort

func (s *GenerateSim) OpenShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)

func (*GenerateSim) PlaceOrder

func (s *GenerateSim) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64,
	size float64, opts ...PlaceOrderOption) (result *Order, err error)

func (*GenerateSim) RunEventLoopOnce

func (s *GenerateSim) RunEventLoopOnce() (err error)

func (*GenerateSim) SetBacktest added in v1.2.3

func (s *GenerateSim) SetBacktest(backtest IBacktest)

func (*GenerateSim) SetContractType

func (s *GenerateSim) SetContractType(pair string, contractType string) (err error)

func (*GenerateSim) SetData added in v1.1.10

func (s *GenerateSim) SetData(data *dataloader.Data)

func (*GenerateSim) SetExchangeLogger added in v1.1.13

func (s *GenerateSim) SetExchangeLogger(l ExchangeLogger)

func (*GenerateSim) SetLeverRate

func (s *GenerateSim) SetLeverRate(value float64) (err error)

func (*GenerateSim) SubscribeLevel2Snapshots

func (s *GenerateSim) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error

func (*GenerateSim) SubscribeOrders

func (s *GenerateSim) SubscribeOrders(market Market, callback func(orders []*Order)) error

func (*GenerateSim) SubscribePositions

func (s *GenerateSim) SubscribePositions(market Market, callback func(positions []*Position)) error

func (*GenerateSim) SubscribeTrades

func (s *GenerateSim) SubscribeTrades(market Market, callback func(trades []*Trade)) error

Jump to

Keyboard shortcuts

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