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 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 // Id should be uint64 ClientOrderId string `bson:"clientOrderId"` Type string Symbol string InitialPrice decimal.Decimal `bson:"initialPrice"` InitialAmount decimal.Decimal Timestamp int64 Status string FilledPrice decimal.Decimal FilledAmount decimal.Decimal Trades []Trade Fee map[string]decimal.Decimal }
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 { AllSymbols() (s []Symbol, err error) GetSymbol(symbol string) (Symbol, error) SpotAvailableBalance() (map[string]decimal.Decimal, error) LastPrice(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, clientOrderId string, amount decimal.Decimal) (orderId uint64, err error) SellMarket(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 }
common exchange interface for all symbols
type Symbol ¶ added in v0.13.0
type Symbol struct { Symbol string `json:"symbol"` 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 WsAPIExchange ¶ added in v0.13.0
type WsAPIExchange interface { SubscribeOrder(ctx context.Context, symbol, clientId string, responseHandler ResponseHandler) SubscribeCandlestick(ctx context.Context, symbol, clientId string, period time.Duration, responseHandler ResponseHandler) SubscribeCandlestickWithReq(ctx context.Context, symbol, clientId string, period time.Duration, responseHandler ResponseHandler) }
Click to show internal directories.
Click to hide internal directories.