Documentation ¶
Index ¶
- Constants
- Variables
- func NewBadArg(msg string, arg interface{}) error
- func NewBadExResp(err error) error
- func Round(val decimal.Decimal, p decimal.Decimal) decimal.Decimal
- type BaseFutureSymbol
- type BaseMarginSymbol
- type BaseMarket
- type BaseOptionSymbol
- type BaseSpotSymbol
- type BaseSwapSymbol
- type BaseSymbolProperty
- type Channel
- type Client
- func (c *Client) Close() error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Error() error
- func (c *Client) Handle(_ context.Context, notify *rpc.Notify)
- func (c *Client) Index(sym Symbol) (*Index, error)
- func (c *Client) OrderBook(symbol Symbol) (*OrderBook, error)
- func (c *Client) Run(ctx context.Context) error
- type CodeC
- type ConnCB
- type ErrBadArg
- type ErrBadExResp
- type Finance
- type FinanceProp
- type FinanceReqParam
- type FinanceType
- type FutureType
- type FuturesSymbol
- type Index
- type IndexNotify
- type IntID
- type MarginSymbol
- type OptionSymbol
- type OptionType
- type Order
- type OrderBook
- type OrderBookDS
- type OrderBookNotify
- type OrderElem
- type OrderID
- type OrderReqOption
- type OrderRequest
- type OrderSide
- type OrderStatus
- type OrderType
- type Position
- type PositionMode
- type PositionSide
- type PostOnlyOption
- type Property
- type RawMixin
- type SpotSymbol
- type StrID
- type SubType
- type SwapSymbol
- type Symbol
- type SymbolConfig
- type Ticker
- type TimeInForceFlag
- type TimeInForceOption
- type Trade
- type TradeFee
- type TradeReqParam
- type TradesProp
- type WSClient
- type WSNotify
Constants ¶
const ( OrderTypeLimit OrderType = iota OrderTypeMarket OrderTypeStopLimit OrderTypeStopMarket //OrderStatusUnknown means order info need check with api OrderStatusUnknown OrderStatus = iota OrderStatusOpen OrderStatusDone OrderStatusCancel OrderStatusFailed //TimeInForceGTC good_till_cancel TimeInForceGTC = "gtc" //TimeInForceFOK fill_or_kill TimeInForceFOK = "fok" //TimeInForceIOC immediate_or_cancel TimeInForceIOC = "ioc" )
const ( PositionSideLong = iota PositionSideShort PositionModeFixed PositionModeCross )
const ( OptionTypeCall = iota OptionTypePut //FutureTypeCW current week settle future FutureTypeCW //FutureTypeNW next week settle future FutureTypeNW //FutureTypeCQ current quarter settle future FutureTypeCQ //FutureTypeNQ next quarter settle future FutureTypeNQ //FutureTypeNNQ next next quart settle future (deribit only) FutureTypeNNQ )
Variables ¶
var (
TimeNoExpire = time.Time{}
)
Functions ¶
func NewBadExResp ¶
Types ¶
type BaseFutureSymbol ¶
type BaseFutureSymbol struct { RawMixin BaseSymbolProperty // contains filtered or unexported fields }
BaseFutureSymbol define common property of future symbol
func NewBaseFutureSymbol ¶
func NewBaseFutureSymbol(index string, st time.Time, typ FutureType) *BaseFutureSymbol
func NewBaseFuturesSymbolWithCfg ¶ added in v0.3.0
func NewBaseFuturesSymbolWithCfg(index string, st time.Time, typ FutureType, cfg SymbolConfig, raw interface{}) *BaseFutureSymbol
func (*BaseFutureSymbol) Index ¶
func (bfs *BaseFutureSymbol) Index() string
func (*BaseFutureSymbol) SettleTime ¶
func (bfs *BaseFutureSymbol) SettleTime() time.Time
func (*BaseFutureSymbol) Type ¶ added in v0.3.0
func (bfs *BaseFutureSymbol) Type() FutureType
type BaseMarginSymbol ¶ added in v0.3.0
type BaseMarginSymbol struct { *BaseSpotSymbol // contains filtered or unexported fields }
func NewBaseMarginSymbol ¶ added in v0.3.0
func NewBaseMarginSymbol(base, quote string, cfg SymbolConfig, lever decimal.Decimal, raw interface{}) *BaseMarginSymbol
func (*BaseMarginSymbol) Lever ¶ added in v0.3.0
func (ms *BaseMarginSymbol) Lever() decimal.Decimal
type BaseMarket ¶
type BaseMarket struct {
// contains filtered or unexported fields
}
func (*BaseMarket) Expire ¶
func (m *BaseMarket) Expire() bool
func (*BaseMarket) Symbol ¶
func (m *BaseMarket) Symbol() Symbol
type BaseOptionSymbol ¶
type BaseOptionSymbol struct { RawMixin BaseSymbolProperty // contains filtered or unexported fields }
BaseOptionSymbol define common property of option symbol
func NewBaseOptionSymbol ¶
func NewBaseOptionSymbol(index string, st time.Time, strike decimal.Decimal, typ OptionType, prop SymbolConfig, raw interface{}) *BaseOptionSymbol
func (*BaseOptionSymbol) Index ¶
func (bos *BaseOptionSymbol) Index() string
func (*BaseOptionSymbol) SettleTime ¶
func (bos *BaseOptionSymbol) SettleTime() time.Time
func (*BaseOptionSymbol) Strike ¶
func (bos *BaseOptionSymbol) Strike() decimal.Decimal
func (*BaseOptionSymbol) Type ¶
func (bos *BaseOptionSymbol) Type() OptionType
type BaseSpotSymbol ¶
type BaseSpotSymbol struct { RawMixin BaseSymbolProperty // contains filtered or unexported fields }
BaseSpotSymbol define common property of spot symbol
func NewBaseSpotSymbol ¶
func NewBaseSpotSymbol(base, quote string, cfg SymbolConfig, raw interface{}) *BaseSpotSymbol
func (*BaseSpotSymbol) Base ¶
func (bss *BaseSpotSymbol) Base() string
func (*BaseSpotSymbol) Quote ¶
func (bss *BaseSpotSymbol) Quote() string
type BaseSwapSymbol ¶
type BaseSwapSymbol struct { RawMixin BaseSymbolProperty // contains filtered or unexported fields }
func NewBaseSwapSymbol ¶
func NewBaseSwapSymbol(index string) *BaseSwapSymbol
func NewBaseSwapSymbolWithCfg ¶ added in v0.3.0
func NewBaseSwapSymbolWithCfg(index string, cf decimal.Decimal, cfg SymbolConfig, raw interface{}) *BaseSwapSymbol
func (*BaseSwapSymbol) ContractVal ¶ added in v0.3.0
func (bsv *BaseSwapSymbol) ContractVal() decimal.Decimal
func (*BaseSwapSymbol) Index ¶
func (bsw *BaseSwapSymbol) Index() string
type BaseSymbolProperty ¶ added in v0.3.0
type BaseSymbolProperty struct {
// contains filtered or unexported fields
}
BaseSymbolProperty define common property of all kind symbol
func (*BaseSymbolProperty) AmountMax ¶ added in v0.3.0
func (p *BaseSymbolProperty) AmountMax() decimal.Decimal
AmountMax minum order amount zero means no limit
func (*BaseSymbolProperty) AmountMin ¶ added in v0.3.0
func (p *BaseSymbolProperty) AmountMin() decimal.Decimal
AmountMin minium order amount
func (*BaseSymbolProperty) AmountPrecision ¶ added in v0.3.0
func (p *BaseSymbolProperty) AmountPrecision() decimal.Decimal
AmountPrecision return amount precision value
func (*BaseSymbolProperty) PricePrecision ¶ added in v0.3.0
func (p *BaseSymbolProperty) PricePrecision() decimal.Decimal
PricePrecision return price precision value
func (*BaseSymbolProperty) ValueMin ¶ added in v0.3.0
func (p *BaseSymbolProperty) ValueMin() decimal.Decimal
ValueMin return minium amount * price value zero means no limit
type Client ¶
type Client struct { NewConn ConnCB Conn rpc.Conn Addr string Key string Secret string Timeout time.Duration //subscribe struct will be updated via rpc Conn notify message Sub map[string]interface{} SubMu sync.Mutex }
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done get notify if running loop closed
type ErrBadArg ¶
type ErrBadArg struct { Arg interface{} Msg string }
ErrBadArg means func argument is incorrect
type ErrBadExResp ¶
type ErrBadExResp struct {
Err error
}
ErrBadResp means exchange response message error
func (*ErrBadExResp) Error ¶
func (ebe *ErrBadExResp) Error() string
func (*ErrBadExResp) Is ¶
func (ebe *ErrBadExResp) Is(target error) bool
type FinanceProp ¶ added in v0.3.0
type FinanceReqParam ¶ added in v0.3.0
type FinanceReqParam struct { TradeReqParam Type FinanceType }
type FinanceType ¶ added in v0.3.0
type FinanceType int
const ( FinanceTypeOther FinanceType = iota FinanceTypeFunding FinanceTypeInterest )
type FutureType ¶ added in v0.3.0
type FutureType int
type FuturesSymbol ¶
type FuturesSymbol interface { Symbol Index() string SettleTime() time.Time Type() FutureType }
type IndexNotify ¶
type IndexNotify Index
func (*IndexNotify) Key ¶
func (i *IndexNotify) Key() string
func (*IndexNotify) Snapshot ¶
func (i *IndexNotify) Snapshot() *Index
type MarginSymbol ¶ added in v0.3.0
type OptionSymbol ¶
type OptionType ¶
type OptionType int
func (OptionType) String ¶
func (ot OptionType) String() string
type Order ¶
type Order struct { ID OrderID ClientID OrderID Symbol Symbol Amount decimal.Decimal Filled decimal.Decimal Price decimal.Decimal AvgPrice decimal.Decimal Fee decimal.Decimal FeeCurrency string Created time.Time Updated time.Time Side OrderSide Status OrderStatus Type OrderType Raw interface{} `json:"-"` }
type OrderBook ¶
type OrderBook struct { Symbol Symbol Bids []OrderElem Asks []OrderElem Created time.Time Raw interface{} }
OrderBook get via OrderBookDS.Snapshot
type OrderBookDS ¶
type OrderBookDS struct {
// contains filtered or unexported fields
}
OrderBookDS is the ds which hold orderbook info
func NewOrderBookDS ¶
func NewOrderBookDS(notify *OrderBookNotify) *OrderBookDS
func (*OrderBookDS) Snapshot ¶
func (ds *OrderBookDS) Snapshot() *OrderBook
func (*OrderBookDS) Update ¶
func (ds *OrderBookDS) Update(notify *OrderBookNotify)
type OrderBookNotify ¶
OrderBookNotify change of current orderbook OrderElem.Amount == 0 means delete
func (*OrderBookNotify) Key ¶
func (notify *OrderBookNotify) Key() string
type OrderReqOption ¶
type OrderReqOption interface { }
OrderReqOption specific option to create order each exchange support different options.
func NewPostOnlyOption ¶
func NewPostOnlyOption(postOnly bool) OrderReqOption
func NewTimeInForceOption ¶
func NewTimeInForceOption(flag TimeInForceFlag) OrderReqOption
type OrderRequest ¶
type OrderRequest struct { Symbol Symbol ClientID OrderID Side OrderSide Type OrderType Price decimal.Decimal Amount decimal.Decimal }
OrderRequest carry field which used to create order
func NewOrderRequest ¶
type OrderStatus ¶
type OrderStatus int
type Position ¶
type Position struct { Symbol Symbol Mode PositionMode Side PositionSide LiquidationPrice decimal.Decimal AvgOpenPrice decimal.Decimal CreateTime time.Time Margin decimal.Decimal MarginMaintRatio decimal.Decimal Position decimal.Decimal AvailPosition decimal.Decimal RealizedPNL decimal.Decimal UNRealizedPNL decimal.Decimal Leverage decimal.Decimal Raw interface{} }
Position info
type PositionMode ¶
type PositionMode int
func (PositionMode) String ¶
func (pm PositionMode) String() string
type PositionSide ¶
type PositionSide int
func (PositionSide) String ¶
func (ps PositionSide) String() string
type PostOnlyOption ¶
type PostOnlyOption struct {
PostOnly bool
}
PostOnlyOption wether the order ensure maker
type Property ¶ added in v0.3.0
type Property struct { Trades *TradesProp Finance *FinanceProp }
type SpotSymbol ¶
type Symbol ¶
type Symbol interface { Raw() interface{} AmountPrecision() decimal.Decimal PricePrecision() decimal.Decimal AmountMax() decimal.Decimal AmountMin() decimal.Decimal ValueMin() decimal.Decimal String() string }
Symbol is used to unit different exchange markets symbol serialize
type SymbolConfig ¶ added in v0.3.0
type SymbolConfig struct { PricePrecision decimal.Decimal AmountPrecision decimal.Decimal AmountMin decimal.Decimal AmountMax decimal.Decimal ValueMin decimal.Decimal }
SymbolConfig used to specific symbol property
func (*SymbolConfig) Property ¶ added in v0.3.0
func (p *SymbolConfig) Property() BaseSymbolProperty
type TimeInForceOption ¶
type TimeInForceOption struct {
Flag TimeInForceFlag
}
TimeInForceOption specific how long the order remains in effect
type TradeReqParam ¶ added in v0.3.0
type TradesProp ¶ added in v0.3.0
TradesProp specific property which used to build Trades request