deribitsim

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 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 DiribitSim

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

DiribitSim the deribit broker for backtest

func New

func New(data *data.Data, cash float64, makerFeeRate float64, takerFeeRate float64) *DiribitSim

func (*DiribitSim) AmendOrder

func (b *DiribitSim) AmendOrder(symbol string, id string, price float64, size float64) (result Order, err error)

func (*DiribitSim) CancelAllOrders

func (b *DiribitSim) CancelAllOrders(symbol string) (err error)

func (*DiribitSim) CancelOrder

func (b *DiribitSim) CancelOrder(symbol string, id string) (result Order, err error)

func (*DiribitSim) GetAccountSummary

func (b *DiribitSim) GetAccountSummary(currency string) (result AccountSummary, err error)

func (*DiribitSim) GetContractID

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

func (*DiribitSim) GetName

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

func (*DiribitSim) GetOpenOrders

func (b *DiribitSim) GetOpenOrders(symbol string) (result []Order, err error)

func (*DiribitSim) GetOrder

func (b *DiribitSim) GetOrder(symbol string, id string) (result Order, err error)

func (*DiribitSim) GetOrderBook

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

func (*DiribitSim) GetPosition

func (b *DiribitSim) GetPosition(symbol string) (result Position, err error)

func (*DiribitSim) GetRecords

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

func (*DiribitSim) PlaceOrder

func (b *DiribitSim) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64,
	stopPx float64, size float64, postOnly bool, reduceOnly bool, params map[string]interface{}) (result Order, err error)

func (*DiribitSim) RunEventLoopOnce

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

func (*DiribitSim) SetContractType

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

func (*DiribitSim) SetLeverRate

func (b *DiribitSim) SetLeverRate(value float64) (err 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