Documentation ¶
Index ¶
- Constants
- func CalcInitialMargin(sizeCurrency float64) float64
- func CalcMaintMargin(sizeCurrency float64) float64
- func CalcPnl(side Direction, positionSize float64, entryPrice float64, exitPrice float64) (pnl float64, pnlUsd float64)
- type DeribitSim
- func (b *DeribitSim) AmendOrder(symbol string, id string, price float64, size float64, opts ...OrderOption) (result Order, err error)
- func (b *DeribitSim) CancelAllOrders(symbol string, opts ...OrderOption) (err error)
- func (b *DeribitSim) CancelOrder(symbol string, id string, opts ...OrderOption) (result Order, err error)
- func (b *DeribitSim) CloseLong(symbol string, orderType OrderType, price float64, size float64) (result Order, err error)
- func (b *DeribitSim) CloseShort(symbol string, orderType OrderType, price float64, size float64) (result Order, err error)
- func (b *DeribitSim) GetBalance(currency string) (result Balance, err error)
- func (b *DeribitSim) GetContractID() (symbol string, err error)
- func (b *DeribitSim) GetName() (name string)
- func (b *DeribitSim) GetOpenOrders(symbol string, opts ...OrderOption) (result []Order, err error)
- func (b *DeribitSim) GetOrder(symbol string, id string, opts ...OrderOption) (result Order, err error)
- func (b *DeribitSim) GetOrderBook(symbol string, depth int) (result OrderBook, err error)
- func (b *DeribitSim) GetPositions(symbol string) (result []Position, err error)
- func (b *DeribitSim) GetRecords(symbol string, period string, from int64, end int64, limit int) (records []Record, err error)
- func (b *DeribitSim) GetTime() (tm int64, err error)
- func (b *DeribitSim) OpenLong(symbol string, orderType OrderType, price float64, size float64) (result Order, err error)
- func (b *DeribitSim) OpenShort(symbol string, orderType OrderType, price float64, size float64) (result Order, err error)
- func (b *DeribitSim) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64, ...) (result Order, err error)
- func (b *DeribitSim) RunEventLoopOnce() (err error)
- func (b *DeribitSim) SetContractType(pair string, contractType string) (err error)
- func (b *DeribitSim) SetLeverRate(value float64) (err error)
- func (b *DeribitSim) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error
- func (b *DeribitSim) SubscribeOrders(market Market, callback func(orders []Order)) error
- func (b *DeribitSim) SubscribePositions(market Market, callback func(positions []Position)) error
- func (b *DeribitSim) SubscribeTrades(market Market, callback func(trades []Trade)) error
- type MarginInfo
Constants ¶
View Source
const (
PositionSizeLimit = 1000000 // Position size limit
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeribitSim ¶
type DeribitSim struct {
// contains filtered or unexported fields
}
DeribitSim the deribit exchange for backtest
func NewDeribitSim ¶
func (*DeribitSim) AmendOrder ¶
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 (*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)
计算保证金参数
Click to show internal directories.
Click to hide internal directories.