Documentation
¶
Index ¶
- Constants
- Variables
- func InitBroadcastService()
- func InitSpecification()
- type Broadcast
- type Exchange
- func (c *Exchange) Buy(p map[string]interface{}) (interfaces.Resp, error)
- func (c *Exchange) Conf(conf interfaces.Conf) interfaces.Exchange
- func (c *Exchange) MarketBuy(symbol string, quoteOrderQty float64) (interfaces.Resp, error)
- func (c *Exchange) MarketSell(symbol string, quantity float64) (interfaces.Resp, error)
- func (c *Exchange) Sell(p map[string]interface{}) (interfaces.Resp, error)
- func (c *Exchange) SpecificationInfo() (*Info, error)
- func (c *Exchange) TestOrder() interfaces.Exchange
- func (c *Exchange) TickerPrice() (interfaces.Ticker, error)
- type ExchangeTicker
- type Info
- type InfoRateLimits
- type InfoSymbol
- type Resp
- type RespFills
- type Ticker
Constants ¶
View Source
const ( // TickerPriceURL 最新交易对价格列表路由 TickerPriceURL = "/api/v3/ticker/price" // SpecificationURL 行情规范路由 SpecificationURL = "/api/v3/exchangeInfo" // OrderURL 订单路由 OrderURL = "/api/v3/order" // TestOrderURL 测试订单路由 TestOrderURL = "/api/v3/order/test" )
View Source
const BaseURL = "https://api.binance.com"
BaseURL 基础接口
View Source
const BroadcastMessageTypeTickerPrice = "TickerPrice"
Variables ¶
View Source
var SpecificationInfo = &Info{}
SpecificationInfo 交易所规范信息
View Source
var SpecificationSymbolInfo = map[string]*InfoSymbol{}
SpecificationSymbolInfo 交易所交易对规范
Functions ¶
Types ¶
type Broadcast ¶
type Broadcast struct { Service *utils.Broadcast // 广播服务 // contains filtered or unexported fields }
Broadcast 广播
var BroadcastService *Broadcast
BroadcastService 广播服务
func (*Broadcast) TickerPrice ¶
TickerPrice 广播最新价格
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange 币安交易所
func (*Exchange) Buy ¶
func (c *Exchange) Buy(p map[string]interface{}) (interfaces.Resp, error)
Buy 买入
func (*Exchange) Conf ¶
func (c *Exchange) Conf(conf interfaces.Conf) interfaces.Exchange
Conf 配置交易所配置
func (*Exchange) MarketSell ¶
MarketSell 市价卖出
func (*Exchange) Sell ¶
func (c *Exchange) Sell(p map[string]interface{}) (interfaces.Resp, error)
Sell 卖出
func (*Exchange) SpecificationInfo ¶
SpecificationInfo 交易所规范信息
func (*Exchange) TickerPrice ¶
func (c *Exchange) TickerPrice() (interfaces.Ticker, error)
TickerPrice 请求交易对最新价格列表
type ExchangeTicker ¶
type Info ¶
type Info struct { Timezone string `json:"timezone"` // 时区 ServerTime time.Duration `json:"serverTime"` // 服务器时间 // 交易平台API使用的一些次数要求 // rateLimits有三种类型,别分是 // 一分钟内请求权重之和的上限 // 每秒钟交易次数的上限 // 每天交易次数的上限 RateLimits []*InfoRateLimits `json:"rateLimits"` Symbols []*InfoSymbol `json:"symbols"` }
type InfoRateLimits ¶
type InfoRateLimits struct { RateLimitType string `json:"rateLimitType"` Interval string `json:"interval"` IntervalNum int `json:"intervalNum"` Limit int `json:"limit"` }
InfoRateLimits api 要求
type InfoSymbol ¶
type InfoSymbol struct { Symbol string `json:"symbol"` // 交易对 Status string `json:"status"` // 状态,trading应该表示可交易 BaseAsset string `json:"baseAsset"` // BaseAssetPrecision int `json:"baseAssetPrecision"` // 资产精确的小数点位数,这里是8位 QuoteAsset string `json:"quoteAsset"` // QuotePrecision int `json:"quotePrecision"` // QuoteAssetPrecision int `json:"quoteAssetPrecision"` // 同理 BaseCommissionPrecision int `json:"baseCommissionPrecision"` // QuoteCommissionPrecision int `json:"quoteCommissionPrecision"` // OrderTypes []string `json:"orderTypes"` // 交易的类别有哪些 IcebergAllowed bool `json:"icebergAllowed"` // 是否允许——冰山订单 OcoAllowed bool `json:"ocoAllowed"` // 是否允许——OCO订单 QuoteOrderQtyMarketAllowed bool `json:"quoteOrderQtyMarketAllowed"` // IsSpotTradingAllowed bool `json:"isSpotTradingAllowed"` // 是否允许——现货交易订单 IsMarginTradingAllowed bool `json:"isMarginTradingAllowed"` // 是否允许——保证金交易订单 Filters []map[string]interface{} `json:"filters"` // 筛选器,订单不满足这些筛选器的要求是无法进行交易的 FiltersMap map[string]map[string]interface{} `json:"filtersMap"` // 筛选器,处理之后的 }
InfoSymbol 交易对
type Resp ¶
type Resp struct { Symbol string `json:"symbol"` // 交易对 OrderId int64 `json:"orderId"` // 订单ID OrderListId int64 `json:"orderListId"` // OCO订单的ID,不然就是-1 ClientOrderId string `json:"clientOrderId"` // 客户自己设置的ID TransactTime time.Duration `json:"transactTime"` // 交易的时间戳 Price string `json:"price"` // 订单价格 OrigQty string `json:"origQty"` // 用户设置的原始订单数量 ExecutedQty string `json:"executedQty"` // 交易的订单数量 CumulativeQuoteQty string `json:"cummulativeQuoteQty"` // 累计交易的金额 Status string `json:"status"` // 订单状态 TimeInForce string `json:"timeInForce"` // 订单的时效方式 Type string `json:"type"` // 订单类型, 比如市价单,现价单等 Side string `json:"side"` // 订单方向,买还是卖 Fills []*RespFills `json:"fills"` // 订单中交易的信息 }
func (*Resp) GetCumulativeQty ¶
GetCumulativeQty 获取累计交易的金额
type RespFills ¶
type RespFills struct { Price string `json:"price"` // 交易的价格 Qty string `json:"qty"` // 交易的数量 Commission string `json:"commission"` // 手续费金额 CommissionAsset string `json:"commissionAsset"` // 手续费的币种 }
RespFills 订单中的交易信息
type Ticker ¶
type Ticker struct { TickerList []*ExchangeTicker TickerMap map[string]float64 }
func (*Ticker) SymbolPrice ¶
SymbolPrice 交易对最新的价格
func (*Ticker) SymbolPriceMap ¶
SymbolPriceMap 交易对列表最新价格
func (*Ticker) TickerListToTickerMap ¶
TickerListToTickerMap 最新价格数组转最新价格Map
Click to show internal directories.
Click to hide internal directories.