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 ExSim
- func (b *ExSim) AmendOrder(symbol string, id string, price float64, size float64, opts ...OrderOption) (result *Order, err error)
- func (b *ExSim) CancelAllOrders(symbol string, opts ...OrderOption) (err error)
- func (b *ExSim) CancelOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
- func (b *ExSim) CloseLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *ExSim) CloseShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *ExSim) GetBalance(symbol string) (result *Balance, err error)
- func (b *ExSim) GetContractID() (symbol string, err error)
- func (b *ExSim) GetName() (name string)
- func (b *ExSim) GetOpenOrders(symbol string, opts ...OrderOption) (result []*Order, err error)
- func (b *ExSim) GetOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
- func (b *ExSim) GetOrderBook(symbol string, depth int) (result *OrderBook, err error)
- func (b *ExSim) GetPValue(symbol string) float64
- func (b *ExSim) GetPositions(symbol string) (result []*Position, err error)
- func (b *ExSim) GetRecords(symbol string, period string, from int64, end int64, limit int) (records []*Record, err error)
- func (b *ExSim) GetTime() (tm int64, err error)
- func (b *ExSim) IO(name string, params string) (string, error)
- func (b *ExSim) OpenLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *ExSim) OpenShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *ExSim) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64, ...) (result *Order, err error)
- func (b *ExSim) RunEventLoopOnce() (err error)
- func (b *ExSim) SetBacktest(backtest IBacktest)
- func (b *ExSim) SetContractType(pair string, contractType string) (err error)
- func (b *ExSim) SetExchangeLogger(l ExchangeLogger)
- func (b *ExSim) SetLeverRate(value float64) (err error)
- func (b *ExSim) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error
- func (b *ExSim) SubscribeOrders(market Market, callback func(orders []*Order)) error
- func (b *ExSim) SubscribePositions(market Market, callback func(positions []*Position)) error
- func (b *ExSim) SubscribeTrades(market Market, callback func(trades []*Trade)) error
- type MarginInfo
- type Positions
Constants ¶
View Source
const (
PositionSizeLimit = 1000000 // Position size limit
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExSim ¶
type ExSim struct {
// contains filtered or unexported fields
}
ExSim the exchange for backtest
func NewExSim ¶
func NewExSim(data *dataloader.Data, cash float64, makerFeeRate float64, takerFeeRate float64, valueOfContract float64, hedgedPosition bool, forwardContract bool) *ExSim
NewExSim 创建模拟交易所 cash: 初始资金 makerFeeRate: Maker 费率 takerFeeRate: Taker 费率 valueOfContract: 合约单张面值 hedgedPosition: 双向持仓 forwardContract: true-正向合约 false-反向合约
func (*ExSim) AmendOrder ¶
func (*ExSim) CancelAllOrders ¶
func (*ExSim) CancelOrder ¶
func (*ExSim) CloseShort ¶
func (*ExSim) GetBalance ¶
func (*ExSim) GetContractID ¶
func (*ExSim) GetOpenOrders ¶
func (*ExSim) GetOrderBook ¶
func (*ExSim) GetPositions ¶
func (*ExSim) GetRecords ¶
func (*ExSim) PlaceOrder ¶
func (*ExSim) RunEventLoopOnce ¶
func (*ExSim) SetBacktest ¶ added in v1.2.3
func (b *ExSim) SetBacktest(backtest IBacktest)
func (*ExSim) SetContractType ¶
func (*ExSim) SetExchangeLogger ¶
func (b *ExSim) SetExchangeLogger(l ExchangeLogger)
func (*ExSim) SetLeverRate ¶
func (*ExSim) SubscribeLevel2Snapshots ¶
func (*ExSim) SubscribeOrders ¶
func (*ExSim) SubscribePositions ¶
func (*ExSim) SubscribeTrades ¶
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.