Documentation
¶
Index ¶
Constants ¶
View Source
const ( MIN1 = time.Minute MIN5 = time.Minute * 5 MIN15 = time.Minute * 15 MIN30 = time.Minute * 30 HOUR1 = time.Hour HOUR4 = time.Hour * 4 DAY1 = time.Hour * 24 MON1 = DAY1 * 30 WEEK1 = DAY1 * 7 YEAR1 = DAY1 * 365 )
View Source
const ( Open OrderStatus = 1 // open but not filled Closed = 2 // full filled Filled = 3 // part filled Cancelled = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountBalance ¶ added in v0.28.0
type Exchange ¶ added in v0.13.0
type Exchange interface { RestAPIExchange WsAPIExchange }
common exchange interface, for all symbols, all crypto-exchanges
type Order ¶ added in v0.13.0
type Order struct { Id uint64 `json:"id"` // Id should be uint64 ClientOrderId string `json:"clientOrderId" bson:"clientOrderId"` // gate: limit // huobi: Type string `json:"type"` Symbol string `json:"symbol"` Price decimal.Decimal `json:"price"` Amount decimal.Decimal `json:"amount"` Time time.Time `json:"time"` Status string `json:"status"` FilledPrice decimal.Decimal `json:"filledPrice"` FilledAmount decimal.Decimal `json:"filledAmount"` Trades []Trade `json:"trades,omitempty"` }
Order is common order type between all exchanges, use for exchange interface
type OrderStatus ¶ added in v0.13.0
type OrderStatus = int
type ResponseHandler ¶ added in v0.13.0
type ResponseHandler func(response interface{})
type RestAPIExchange ¶ added in v0.13.0
type RestAPIExchange interface { FormatSymbol(base, quote string) string AllSymbols(ctx context.Context) (s []Symbol, err error) GetSymbol(ctx context.Context, symbol string) (Symbol, error) GetFee(symbol string) (fee Fee, err error) SpotBalance() (map[string]decimal.Decimal, error) SpotAvailableBalance() (map[string]decimal.Decimal, error) LastPrice(symbol string) (decimal.Decimal, error) Last24hVolume(symbol string) (decimal.Decimal, error) CandleBySize(symbol string, period time.Duration, size int) (hs.Candle, error) CandleFrom(symbol, clientId string, period time.Duration, from, to time.Time) (hs.Candle, error) //PlaceOrder(orderType, symbol, clientOrderId string, price, amount decimal.Decimal) (uint64, error) BuyLimit(symbol, clientOrderId string, price, amount decimal.Decimal) (orderId uint64, err error) SellLimit(symbol, clientOrderId string, price, amount decimal.Decimal) (orderId uint64, err error) BuyMarket(symbol Symbol, clientOrderId string, total decimal.Decimal) (orderId uint64, err error) SellMarket(symbol Symbol, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error) BuyStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error) SellStopLimit(symbol, clientOrderId string, price, amount, stopPrice decimal.Decimal) (orderId uint64, err error) GetOrderById(orderId uint64, symbol string) (Order, error) CancelOrder(symbol string, orderId uint64) error IsFullFilled(symbol string, orderId uint64) (Order, bool, error) }
common exchange interface for all symbols
type Symbol ¶ added in v0.13.0
type Symbol struct { Symbol string Disabled bool BaseCurrency string `json:"baseCurrency"` // 交易对中的基础币种, coin, eg. BTC QuoteCurrency string `json:"quoteCurrency"` // 交易对中的报价币种, cash, eg. USDT PricePrecision int32 `json:"pricePrecision"` AmountPrecision int32 `json:"amountPrecision"` MinAmount decimal.Decimal `json:"minAmount"` MinTotal decimal.Decimal `json:"minTotal"` }
type Ticker ¶
type Ticker struct { Id int64 Last decimal.Decimal // 最新成交价 LowestAsk decimal.Decimal // 卖1,卖方最低价 HighestBid decimal.Decimal // 买1,买方最高价 PercentChange decimal.Decimal // 涨跌百分比 BaseVolume decimal.Decimal // 交易量 QuoteVolume decimal.Decimal // 兑换货币交易量 High24hr decimal.Decimal // 24小时最高价 Low24hr decimal.Decimal // 24小时最低价 }
type Trade ¶ added in v0.13.0
type Trade struct { Id uint64 `json:"id"` // Id should be uint64 OrderId uint64 `json:"orderId"` Symbol string `json:"symbol,omitempty"` Type string `json:"type,omitempty"` // v4, side = buy/sell, role = maker/taker Side string `json:"side,omitempty"` Role string `json:"role,omitempty"` Price decimal.Decimal `json:"price"` Amount decimal.Decimal `json:"amount"` FeeCurrency string `json:"feeCurrency,omitempty"` FeeAmount decimal.Decimal `json:"feeAmount,omitempty"` Time time.Time `json:"time"` }
type WsAPIExchange ¶ added in v0.13.0
type WsAPIExchange interface { SubscribeOrder(symbol, clientId string, responseHandler ResponseHandler) UnsubscribeOrder(symbol, clientId string) SubscribeCandlestick(symbol, clientId string, period time.Duration, responseHandler ResponseHandler) UnsubscribeCandlestick(symbol, clientId string, period time.Duration) SubscribeCandlestickWithReq(symbol, clientId string, period time.Duration, responseHandler ResponseHandler) UnsubscribeCandlestickWithReq(symbol, clientId string, period time.Duration) }
Click to show internal directories.
Click to hide internal directories.