deribitsim

package
v1.1.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PositionSizeLimit = 1000000 // Position size limit
)

Variables

This section is empty.

Functions

func CalcInitialMargin

func CalcInitialMargin(sizeCurrency float64) float64

少于此保证金,则爆仓

func CalcMaintMargin

func CalcMaintMargin(sizeCurrency float64) float64

少于此保证金,则强制挂平仓单

func CalcPnl

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

计算收益 pnl: 收益(BTC/ETH) pnlUsd: 收益(USD)

Types

type DeribitSim

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

DeribitSim the deribit exchange for backtest

func NewDeribitSim

func NewDeribitSim(data *data.Data, cash float64, makerFeeRate float64, takerFeeRate float64) *DeribitSim

func (*DeribitSim) AmendOrder

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

func (*DeribitSim) CancelAllOrders

func (b *DeribitSim) CancelAllOrders(symbol string, opts ...OrderOption) (err error)

func (*DeribitSim) CancelOrder

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

func (*DeribitSim) CloseLong added in v1.1.3

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

func (*DeribitSim) CloseShort added in v1.1.3

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

func (*DeribitSim) GetBalance

func (b *DeribitSim) GetBalance(currency string) (result Balance, err error)

func (*DeribitSim) GetContractID

func (b *DeribitSim) GetContractID() (symbol string, err error)

func (*DeribitSim) GetName

func (b *DeribitSim) GetName() (name string)

func (*DeribitSim) GetOpenOrders

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

func (*DeribitSim) GetOrder

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

func (*DeribitSim) GetOrderBook

func (b *DeribitSim) GetOrderBook(symbol string, depth int) (result OrderBook, err error)

func (*DeribitSim) GetPositions

func (b *DeribitSim) GetPositions(symbol string) (result []Position, err error)

func (*DeribitSim) GetRecords

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

func (*DeribitSim) GetTime added in v1.1.6

func (b *DeribitSim) GetTime() (tm int64, err error)

func (*DeribitSim) OpenLong added in v1.1.3

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

func (*DeribitSim) OpenShort added in v1.1.3

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

func (*DeribitSim) PlaceOrder

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

func (*DeribitSim) RunEventLoopOnce

func (b *DeribitSim) RunEventLoopOnce() (err error)

func (*DeribitSim) SetContractType

func (b *DeribitSim) SetContractType(pair string, contractType string) (err error)

func (*DeribitSim) SetLeverRate

func (b *DeribitSim) SetLeverRate(value float64) (err error)

func (*DeribitSim) SubscribeLevel2Snapshots

func (b *DeribitSim) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error

func (*DeribitSim) SubscribeOrders

func (b *DeribitSim) SubscribeOrders(market Market, callback func(orders []Order)) error

func (*DeribitSim) SubscribePositions

func (b *DeribitSim) SubscribePositions(market Market, callback func(positions []Position)) error

func (*DeribitSim) SubscribeTrades

func (b *DeribitSim) SubscribeTrades(market Market, callback func(trades []Trade)) error

type MarginInfo

type MarginInfo struct {
	Leverage              float64
	MaintMargin           float64
	LiquidationPriceLong  float64
	LiquidationPriceShort float64
}

func CalcMarginInfo

func CalcMarginInfo(balance float64, entryPrice float64, positionSize float64) (result MarginInfo)

计算保证金参数

Jump to

Keyboard shortcuts

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