Documentation ¶
Index ¶
- Constants
- Variables
- func AdaptKlinePeriodForOKEx(period int) string
- func CancelAllUnfinishedFutureOrders(api FutureRestAPI, contractType string, currencyPair CurrencyPair) int
- func CancelAllUnfinishedOrders(api API, currencyPair CurrencyPair) int
- func FlateDecompress(data []byte) ([]byte, error)
- func FloatToFixed(v float64, precision int) float64
- func FloatToString(v float64, precision int) string
- func GenerateOrderClientId(size int) string
- func GetParamHmacMD5Sign(secret, params string) (string, error)
- func GetParamHmacSHA1Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Base64Sign(secret, params string) (string, error)
- func GetParamHmacSHA256Sign(secret, params string) (string, error)
- func GetParamHmacSHA512Base64Sign(hmac_key string, hmac_data string) string
- func GetParamHmacSHA512Sign(secret, params string) (string, error)
- func GetParamHmacSha384Sign(secret, params string) (string, error)
- func GetParamMD5Sign(secret, params string) (string, error)
- func GetSHA(text string) (string, error)
- func GzipDecompress(data []byte) ([]byte, error)
- func HttpDeleteForm(client *http.Client, reqUrl string, postData url.Values, ...) ([]byte, error)
- func HttpGet(client *http.Client, reqUrl string) (map[string]interface{}, error)
- func HttpGet2(client *http.Client, reqUrl string, headers map[string]string) (map[string]interface{}, error)
- func HttpGet3(client *http.Client, reqUrl string, headers map[string]string) ([]interface{}, error)
- func HttpGet4(client *http.Client, reqUrl string, headers map[string]string, ...) error
- func HttpGet5(client *http.Client, reqUrl string, headers map[string]string) ([]byte, error)
- func HttpPostForm(client *http.Client, reqUrl string, postData url.Values) ([]byte, error)
- func HttpPostForm2(client *http.Client, reqUrl string, postData url.Values, ...) ([]byte, error)
- func HttpPostForm3(client *http.Client, reqUrl string, postData string, headers map[string]string) ([]byte, error)
- func HttpPostForm4(client *http.Client, reqUrl string, postData map[string]string, ...) ([]byte, error)
- func HttpPut(client *http.Client, reqUrl string, postData url.Values, ...) ([]byte, error)
- func NewHttpRequest(client *http.Client, reqType string, reqUrl string, postData string, ...) ([]byte, error)
- func NewHttpRequestWithFasthttp(client *http.Client, reqMethod, reqUrl, postData string, ...) ([]byte, error)
- func RE(retry int, delay time.Duration, method interface{}, params ...interface{}) interface{}
- func ToFloat64(v interface{}) float64
- func ToInt(v interface{}) int
- func ToInt64(v interface{}) int64
- func ToUint64(v interface{}) uint64
- func ValuesToJson(v url.Values) ([]byte, error)
- type API
- type APIConfig
- type Account
- type ApiError
- type BorrowParameter
- type Currency
- type CurrencyPair
- func (pair CurrencyPair) AdaptBccToBch() CurrencyPair
- func (pair CurrencyPair) AdaptBchToBcc() CurrencyPair
- func (pair CurrencyPair) AdaptUsdToUsdt() CurrencyPair
- func (pair CurrencyPair) AdaptUsdtToUsd() CurrencyPair
- func (c CurrencyPair) Eq(c2 CurrencyPair) bool
- func (pair CurrencyPair) Reverse() CurrencyPair
- func (c CurrencyPair) String() string
- func (pair CurrencyPair) ToLower() CurrencyPair
- func (pair CurrencyPair) ToSymbol(joinChar string) string
- func (pair CurrencyPair) ToSymbol2(joinChar string) string
- type DepositWithdrawHistory
- type Depth
- type DepthRecord
- type DepthRecords
- type FutureAccount
- type FutureKline
- type FutureOrder
- type FuturePosition
- type FutureRestAPI
- type FutureSubAccount
- type FutureTicker
- type FuturesContractInfo
- type FuturesWsApi
- type HistoricalFunding
- type Kline
- type KlinePeriod
- type LimitOrderOptionalParameter
- type MarginAccount
- type MarginSubAccount
- type Order
- type OrderFeature
- type OrderType
- type RepaymentParameter
- type SpotWsApi
- type SubAccount
- type TickSize
- type Ticker
- type Trade
- type TradeSide
- type TradeStatus
- type TransferParameter
- type WalletApi
- type WithdrawParameter
- type WsBuilder
- func (b *WsBuilder) AutoReconnect() *WsBuilder
- func (b *WsBuilder) Build() *WsConn
- func (b *WsBuilder) ConnectSuccessAfterSendMessage(msg func() []byte) *WsBuilder
- func (b *WsBuilder) DecompressFunc(f func([]byte) ([]byte, error)) *WsBuilder
- func (b *WsBuilder) Dump() *WsBuilder
- func (b *WsBuilder) ErrorHandleFunc(f func(err error)) *WsBuilder
- func (b *WsBuilder) Heartbeat(heartbeat func() []byte, t time.Duration) *WsBuilder
- func (b *WsBuilder) ProtoHandleFunc(f func([]byte) error) *WsBuilder
- func (b *WsBuilder) ProxyUrl(proxyUrl string) *WsBuilder
- func (b *WsBuilder) ReconnectInterval(t time.Duration) *WsBuilder
- func (b *WsBuilder) ReqHeader(key, value string) *WsBuilder
- func (b *WsBuilder) WsUrl(wsUrl string) *WsBuilder
- type WsConfig
- type WsConn
- func (ws *WsConn) CloseWs()
- func (ws *WsConn) NewWs() *WsConn
- func (ws *WsConn) SendCloseMessage(msg []byte)
- func (ws *WsConn) SendJsonMessage(m interface{}) error
- func (ws *WsConn) SendMessage(msg []byte)
- func (ws *WsConn) SendPingMessage(msg []byte)
- func (ws *WsConn) SendPongMessage(msg []byte)
- func (ws *WsConn) Subscribe(subEvent interface{}) error
Constants ¶
View Source
const ( OPEN_BUY = 1 + iota //开多 OPEN_SELL //开空 CLOSE_BUY //平多 CLOSE_SELL //平空 )
View Source
const ( KLINE_PERIOD_1MIN = 1 + iota KLINE_PERIOD_3MIN KLINE_PERIOD_5MIN KLINE_PERIOD_15MIN KLINE_PERIOD_30MIN KLINE_PERIOD_60MIN KLINE_PERIOD_1H KLINE_PERIOD_2H KLINE_PERIOD_3H KLINE_PERIOD_4H KLINE_PERIOD_6H KLINE_PERIOD_8H KLINE_PERIOD_12H KLINE_PERIOD_1DAY KLINE_PERIOD_3DAY KLINE_PERIOD_1WEEK KLINE_PERIOD_1MONTH KLINE_PERIOD_1YEAR )
k线周期
View Source
const ( ORDER_FEATURE_ORDINARY = 0 + iota ORDER_FEATURE_POST_ONLY ORDER_FEATURE_FOK ORDER_FEATURE_IOC ORDER_FEATURE_FAK ORDER_FEATURE_LIMIT )
View Source
const ( ORDER_TYPE_LIMIT = 1 + iota ORDER_TYPE_MARKET )
View Source
const ( KUCOIN = "kucoin.com" OKCOIN_COM = "okcoin.com" OKEX = "okex.com" OKEX_V3 = "okex.com_v3" OKEX_FUTURE = "okex.com_future" OKEX_SWAP = "okex.com_swap" HUOBI = "huobi.com" HUOBI_PRO = "huobi.pro" BITSTAMP = "bitstamp.net" KRAKEN = "kraken.com" ZB = "zb.com" BITFINEX = "bitfinex.com" BINANCE = "binance.com" BINANCE_SWAP = "binance.com_swap" POLONIEX = "poloniex.com" COINEX = "coinex.com" BITHUMB = "bithumb.com" GATEIO = "gate.io" BITTREX = "bittrex.com" GDAX = "gdax.com" BIGONE = "big.one" FCOIN = "fcoin.com" FCOIN_MARGIN = "fcoin.com_margin" FMEX = "fmex.com" HITBTC = "hitbtc.com" BITMEX = "bitmex.com" BITMEX_TEST = "testnet.bitmex.com" CRYPTOPIA = "cryptopia.co.nz" HBDM = "hbdm.com" COINBENE = "coinbene.com" ATOP = "a.top" BITGET_SWAP = "bitget_swap" )
exchanges const
View Source
const ( SUB_ACCOUNT = iota //子账户 SPOT // 币币交易 FUTURE //交割合约 C2C //法币 SPOT_MARGIN //币币杠杆交易 WALLET // 资金账户 TIPS //余币宝 SWAP //永续合约 )
Variables ¶
View Source
var ( API_ERR = ApiError{ErrCode: "EX_ERR_0000", ErrMsg: "unknown error"} HTTP_ERR_CODE = ApiError{ErrCode: "HTTP_ERR_0001", ErrMsg: "http request error"} EX_ERR_API_LIMIT = ApiError{ErrCode: "EX_ERR_1000", ErrMsg: "api limited"} EX_ERR_SIGN = ApiError{ErrCode: "EX_ERR_0001", ErrMsg: "signature error"} EX_ERR_NOT_FIND_SECRETKEY = ApiError{ErrCode: "EX_ERR_0002", ErrMsg: "not find secretkey"} EX_ERR_NOT_FIND_APIKEY = ApiError{ErrCode: "EX_ERR_0003", ErrMsg: "not find apikey"} EX_ERR_INSUFFICIENT_BALANCE = ApiError{ErrCode: "EX_ERR_0004", ErrMsg: "Insufficient Balance"} EX_ERR_PLACE_ORDER_FAIL = ApiError{ErrCode: "EX_ERR_0005", ErrMsg: "place order failure"} EX_ERR_CANCEL_ORDER_FAIL = ApiError{ErrCode: "EX_ERR_0006", ErrMsg: "cancel order failure"} EX_ERR_INVALID_CURRENCY_PAIR = ApiError{ErrCode: "EX_ERR_0007", ErrMsg: "invalid currency pair"} EX_ERR_NOT_FIND_ORDER = ApiError{ErrCode: "EX_ERR_0008", ErrMsg: "not find order"} EX_ERR_SYMBOL_ERR = ApiError{ErrCode: "EX_ERR_0009", ErrMsg: "symbol error"} )
View Source
var ( THIS_WEEK_CONTRACT = "this_week" //周合约 NEXT_WEEK_CONTRACT = "next_week" //次周合约 QUARTER_CONTRACT = "quarter" //季度合约 BI_QUARTER_CONTRACT = "bi_quarter" // NEXT QUARTER SWAP_CONTRACT = "swap" //永续合约 )
View Source
var ( UNKNOWN = Currency{"UNKNOWN", ""} CNY = Currency{"CNY", ""} USD = Currency{"USD", ""} USDT = Currency{"USDT", ""} PAX = Currency{"PAX", "https://www.paxos.com/"} USDC = Currency{"USDC", "https://www.centre.io/"} EUR = Currency{"EUR", ""} KRW = Currency{"KRW", ""} JPY = Currency{"JPY", ""} BTC = Currency{"BTC", "https://bitcoin.org/"} XBT = Currency{"XBT", ""} BCC = Currency{"BCC", ""} BCH = Currency{"BCH", ""} BCX = Currency{"BCX", ""} LTC = Currency{"LTC", ""} ETH = Currency{"ETH", ""} ETC = Currency{"ETC", ""} EOS = Currency{"EOS", ""} BTS = Currency{"BTS", ""} QTUM = Currency{"QTUM", ""} SC = Currency{"SC", ""} ANS = Currency{"ANS", ""} ZEC = Currency{"ZEC", ""} DCR = Currency{"DCR", ""} XRP = Currency{"XRP", ""} BTG = Currency{"BTG", ""} BCD = Currency{"BCD", ""} NEO = Currency{"NEO", ""} HSR = Currency{"HSR", ""} BSV = Currency{"BSV", ""} OKB = Currency{"OKB", "OKB is a global utility token issued by OK Blockchain Foundation"} HT = Currency{"HT", "HuoBi Token"} BNB = Currency{"BNB", "BNB, or Binance Coin, is a cryptocurrency created by Binance."} TRX = Currency{"TRX", ""} BTC_CNY = CurrencyPair{BTC, CNY} LTC_CNY = CurrencyPair{LTC, CNY} BCC_CNY = CurrencyPair{BCC, CNY} ETH_CNY = CurrencyPair{ETH, CNY} ETC_CNY = CurrencyPair{ETC, CNY} EOS_CNY = CurrencyPair{EOS, CNY} BTS_CNY = CurrencyPair{BTS, CNY} QTUM_CNY = CurrencyPair{QTUM, CNY} SC_CNY = CurrencyPair{SC, CNY} ANS_CNY = CurrencyPair{ANS, CNY} ZEC_CNY = CurrencyPair{ZEC, CNY} BTC_KRW = CurrencyPair{BTC, KRW} ETH_KRW = CurrencyPair{ETH, KRW} ETC_KRW = CurrencyPair{ETC, KRW} LTC_KRW = CurrencyPair{LTC, KRW} BCH_KRW = CurrencyPair{BCH, KRW} BTC_USD = CurrencyPair{BTC, USD} LTC_USD = CurrencyPair{LTC, USD} ETH_USD = CurrencyPair{ETH, USD} ETC_USD = CurrencyPair{ETC, USD} BCH_USD = CurrencyPair{BCH, USD} BCC_USD = CurrencyPair{BCC, USD} XRP_USD = CurrencyPair{XRP, USD} BCD_USD = CurrencyPair{BCD, USD} EOS_USD = CurrencyPair{EOS, USD} BTG_USD = CurrencyPair{BTG, USD} BSV_USD = CurrencyPair{BSV, USD} BTC_USDT = CurrencyPair{BTC, USDT} LTC_USDT = CurrencyPair{LTC, USDT} BCH_USDT = CurrencyPair{BCH, USDT} BCC_USDT = CurrencyPair{BCC, USDT} ETC_USDT = CurrencyPair{ETC, USDT} ETH_USDT = CurrencyPair{ETH, USDT} BCD_USDT = CurrencyPair{BCD, USDT} NEO_USDT = CurrencyPair{NEO, USDT} EOS_USDT = CurrencyPair{EOS, USDT} XRP_USDT = CurrencyPair{XRP, USDT} HSR_USDT = CurrencyPair{HSR, USDT} BSV_USDT = CurrencyPair{BSV, USDT} OKB_USDT = CurrencyPair{OKB, USDT} HT_USDT = CurrencyPair{HT, USDT} BNB_USDT = CurrencyPair{BNB, USDT} PAX_USDT = CurrencyPair{PAX, USDT} TRX_USDT = CurrencyPair{TRX, USDT} XRP_EUR = CurrencyPair{XRP, EUR} BTC_JPY = CurrencyPair{BTC, JPY} LTC_JPY = CurrencyPair{LTC, JPY} ETH_JPY = CurrencyPair{ETH, JPY} ETC_JPY = CurrencyPair{ETC, JPY} BCH_JPY = CurrencyPair{BCH, JPY} LTC_BTC = CurrencyPair{LTC, BTC} ETH_BTC = CurrencyPair{ETH, BTC} ETC_BTC = CurrencyPair{ETC, BTC} BCC_BTC = CurrencyPair{BCC, BTC} BCH_BTC = CurrencyPair{BCH, BTC} DCR_BTC = CurrencyPair{DCR, BTC} XRP_BTC = CurrencyPair{XRP, BTC} BTG_BTC = CurrencyPair{BTG, BTC} BCD_BTC = CurrencyPair{BCD, BTC} NEO_BTC = CurrencyPair{NEO, BTC} EOS_BTC = CurrencyPair{EOS, BTC} HSR_BTC = CurrencyPair{HSR, BTC} BSV_BTC = CurrencyPair{BSV, BTC} OKB_BTC = CurrencyPair{OKB, BTC} HT_BTC = CurrencyPair{HT, BTC} BNB_BTC = CurrencyPair{BNB, BTC} TRX_BTC = CurrencyPair{TRX, BTC} ETC_ETH = CurrencyPair{ETC, ETH} EOS_ETH = CurrencyPair{EOS, ETH} ZEC_ETH = CurrencyPair{ZEC, ETH} NEO_ETH = CurrencyPair{NEO, ETH} HSR_ETH = CurrencyPair{HSR, ETH} LTC_ETH = CurrencyPair{LTC, ETH} UNKNOWN_PAIR = CurrencyPair{UNKNOWN, UNKNOWN} )
Functions ¶
func AdaptKlinePeriodForOKEx ¶
func CancelAllUnfinishedFutureOrders ¶
func CancelAllUnfinishedFutureOrders(api FutureRestAPI, contractType string, currencyPair CurrencyPair) int
*
- call all unfinished future orders
- @return c 成功撤单数量
func CancelAllUnfinishedOrders ¶
func CancelAllUnfinishedOrders(api API, currencyPair CurrencyPair) int
*
- call all unfinished orders
func FlateDecompress ¶ added in v1.2.3
func FloatToFixed ¶ added in v1.2.3
func FloatToString ¶
func GenerateOrderClientId ¶ added in v1.2.3
func GetParamHmacMD5Sign ¶
func GetParamHmacSHA1Sign ¶
func GetParamHmacSHA256Sign ¶
func GetParamHmacSHA512Sign ¶
func GetParamHmacSha384Sign ¶
for bitfinex.com
func GzipDecompress ¶ added in v1.2.3
func HttpDeleteForm ¶
func HttpPostForm ¶
func HttpPostForm2 ¶
func HttpPostForm3 ¶
func HttpPostForm4 ¶
func NewHttpRequest ¶
func NewHttpRequestWithFasthttp ¶ added in v1.2.3
Types ¶
type API ¶
type API interface { LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error) LimitSell(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error) MarketSell(amount, price string, currency CurrencyPair) (*Order, error) CancelOrder(orderId string, currency CurrencyPair) (bool, error) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error) GetUnfinishOrders(currency CurrencyPair) ([]Order, error) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error) GetAccount() (*Account, error) GetTicker(currency CurrencyPair) (*Ticker, error) GetDepth(size int, currency CurrencyPair) (*Depth, error) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error) //非个人,整个交易所的交易记录 GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error) GetExchangeName() string }
type Account ¶
type Account struct { Exchange string Asset float64 //总资产 NetAsset float64 //净资产 SubAccounts map[Currency]SubAccount }
type BorrowParameter ¶
type BorrowParameter struct { CurrencyPair CurrencyPair Currency Currency Amount float64 }
type CurrencyPair ¶
A->B(A兑换为B)
func NewCurrencyPair ¶
func NewCurrencyPair(currencyA Currency, currencyB Currency) CurrencyPair
func NewCurrencyPair2 ¶
func NewCurrencyPair2(currencyPairSymbol string) CurrencyPair
func NewCurrencyPair3 ¶ added in v1.2.3
func NewCurrencyPair3(currencyPairSymbol string, sep string) CurrencyPair
func (CurrencyPair) AdaptBccToBch ¶
func (pair CurrencyPair) AdaptBccToBch() CurrencyPair
func (CurrencyPair) AdaptBchToBcc ¶
func (pair CurrencyPair) AdaptBchToBcc() CurrencyPair
It is currently applicable to binance and zb
func (CurrencyPair) AdaptUsdToUsdt ¶
func (pair CurrencyPair) AdaptUsdToUsdt() CurrencyPair
func (CurrencyPair) AdaptUsdtToUsd ¶
func (pair CurrencyPair) AdaptUsdtToUsd() CurrencyPair
func (CurrencyPair) Eq ¶
func (c CurrencyPair) Eq(c2 CurrencyPair) bool
func (CurrencyPair) Reverse ¶
func (pair CurrencyPair) Reverse() CurrencyPair
func (CurrencyPair) String ¶
func (c CurrencyPair) String() string
func (CurrencyPair) ToLower ¶
func (pair CurrencyPair) ToLower() CurrencyPair
for to symbol lower , Not practical '==' operation method
func (CurrencyPair) ToSymbol ¶
func (pair CurrencyPair) ToSymbol(joinChar string) string
func (CurrencyPair) ToSymbol2 ¶
func (pair CurrencyPair) ToSymbol2(joinChar string) string
type DepositWithdrawHistory ¶ added in v1.2.3
type DepositWithdrawHistory struct { WithdrawalId string `json:"withdrawal_id,omitempty"` Currency string `json:"currency"` Txid string `json:"txid"` Amount float64 `json:"amount,string"` From string `json:"from,omitempty"` To string `json:"to"` Memo string `json:"memo,omitempty"` Fee string `json:"fee"` Status int `json:"status,string"` Timestamp time.Time `json:"timestamp"` }
type Depth ¶
type Depth struct { ContractType string `json:"contract_type,omitempty"` //for futures ContractId string `json:"contract_id,omitempty"` // for futures Pair CurrencyPair UTime time.Time AskList DepthRecords // Descending order BidList DepthRecords // Descending order }
type DepthRecord ¶
type DepthRecords ¶
type DepthRecords []DepthRecord
func (DepthRecords) Len ¶
func (dr DepthRecords) Len() int
func (DepthRecords) Less ¶
func (dr DepthRecords) Less(i, j int) bool
func (DepthRecords) Swap ¶
func (dr DepthRecords) Swap(i, j int)
type FutureAccount ¶
type FutureAccount struct {
FutureSubAccounts map[Currency]FutureSubAccount
}
type FutureKline ¶
type FutureOrder ¶
type FutureOrder struct { ClientOid string //自定义ID,GoEx内部自动生成 OrderID2 string //请尽量用这个字段替代OrderID字段 Price float64 Amount float64 AvgPrice float64 DealAmount float64 OrderID int64 //deprecated OrderTime int64 Status TradeStatus Currency CurrencyPair OrderType int //ORDINARY=0 POST_ONLY=1 FOK= 2 IOC= 3 OType int //1:开多 2:开空 3:平多 4: 平空 LeverRate float64 //倍数 Fee float64 //手续费 ContractName string FinishedTime int64 // finished timestamp //策略委托单 TriggerPrice float64 AlgoType int //1:限价 2:市场价;触发价格类型,默认是限价;为市场价时,委托价格不必填; }
type FuturePosition ¶
type FuturePosition struct { BuyAmount float64 BuyAvailable float64 BuyPriceAvg float64 BuyPriceCost float64 BuyProfitReal float64 BuyProfit float64 CreateDate int64 LeverRate float64 SellAmount float64 SellAvailable float64 SellPriceAvg float64 SellPriceCost float64 SellProfitReal float64 SellProfit float64 Symbol CurrencyPair //btc_usd:比特币,ltc_usd:莱特币 ContractType string ContractId int64 ForceLiquPrice float64 //预估爆仓价 ShortPnlRatio float64 //空仓收益率 LongPnlRatio float64 //多仓收益率 }
type FutureRestAPI ¶
type FutureRestAPI interface { /** *获取交易所名字 */ GetExchangeName() string /** *获取交割预估价 */ GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error) /** * 期货行情 * @param currency_pair btc_usd:比特币 ltc_usd :莱特币 * @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度 */ GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error) /** * 期货深度 * @param currencyPair btc_usd:比特币 ltc_usd :莱特币 * @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度 * @param size 获取深度档数 * @return */ GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error) /** * 期货指数 * @param currencyPair btc_usd:比特币 ltc_usd :莱特币 */ GetFutureIndex(currencyPair CurrencyPair) (float64, error) /** *全仓账户 *@param currency */ GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error) /** * @deprecated * 期货下单 * @param currencyPair btc_usd:比特币 ltc_usd :莱特币 * @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度 * @param price 价格 * @param amount 委托数量 * @param openType 1:开多 2:开空 3:平多 4:平空 * @param matchPrice 是否为对手价 0:不是 1:是 ,当取值为1时,price无效 */ PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error) //对手价下单 MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error) /** * 取消订单 * @param symbol btc_usd:比特币 ltc_usd :莱特币 * @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度 * @param orderId 订单ID */ FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error) /** * 用户持仓查询 * @param symbol btc_usd:比特币 ltc_usd :莱特币 * @param contractType 合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度 * @return */ GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error) /** *获取订单信息 */ GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error) /** *获取单个订单信息 */ GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error) /** *获取未完成订单信息 */ GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error) /** *获取交易费 */ GetFee() (float64, error) /** *获取每张合约价值 */ GetContractValue(currencyPair CurrencyPair) (float64, error) /** *获取交割时间 星期(0,1,2,3,4,5,6),小时,分,秒 */ GetDeliveryTime() (int, int, int, int) /** * 获取K线数据 */ GetKlineRecords(contractType string, currency CurrencyPair, period, size, since int) ([]FutureKline, error) /** * 获取Trade数据 */ GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error) }
type FutureSubAccount ¶
type FutureTicker ¶
type FuturesContractInfo ¶ added in v1.2.3
type FuturesWsApi ¶ added in v1.2.3
type FuturesWsApi interface { DepthCallback(func(depth *Depth)) TickerCallback(func(ticker *FutureTicker)) TradeCallback(func(trade *Trade, contract string)) SubscribeDepth(pair CurrencyPair, contractType string) error SubscribeTicker(pair CurrencyPair, contractType string) error SubscribeTrade(pair CurrencyPair, contractType string) error }
type HistoricalFunding ¶ added in v1.0.5
type KlinePeriod ¶ added in v1.0.3
type KlinePeriod int
type LimitOrderOptionalParameter ¶ added in v1.2.3
type LimitOrderOptionalParameter int
const ( PostOnly LimitOrderOptionalParameter = iota + 1 Ioc Fok )
func (LimitOrderOptionalParameter) String ¶ added in v1.2.3
func (opt LimitOrderOptionalParameter) String() string
type MarginAccount ¶
type MarginAccount struct { Sub map[Currency]MarginSubAccount LiquidationPrice float64 RiskRate float64 MarginRatio float64 }
type MarginSubAccount ¶
type Order ¶
type Order struct { Price float64 Amount float64 AvgPrice float64 DealAmount float64 Fee float64 Cid string //客户端自定义ID OrderID2 string OrderID int //deprecated Status TradeStatus Currency CurrencyPair Side TradeSide Type string //limit / market OrderType int //0:default,1:maker,2:fok,3:ioc OrderTime int // create timestamp FinishedTime int64 //finished timestamp }
type OrderFeature ¶ added in v1.2.3
type OrderFeature int
func (OrderFeature) String ¶ added in v1.2.3
func (of OrderFeature) String() string
type RepaymentParameter ¶
type RepaymentParameter struct { BorrowParameter BorrowId string }
type SpotWsApi ¶ added in v1.2.3
type SpotWsApi interface { DepthCallback(func(depth *Depth)) TickerCallback(func(ticker *Ticker)) TradeCallback(func(trade *Trade)) SubscribeDepth(pair CurrencyPair) error SubscribeTicker(pair CurrencyPair) error SubscribeTrade(pair CurrencyPair) error }
type SubAccount ¶
type TradeStatus ¶
type TradeStatus int
const ( ORDER_UNFINISH TradeStatus = iota ORDER_PART_FINISH ORDER_FINISH ORDER_CANCEL ORDER_REJECT ORDER_CANCEL_ING ORDER_FAIL )
func (TradeStatus) String ¶
func (ts TradeStatus) String() string
type TransferParameter ¶ added in v1.2.3
type WalletApi ¶ added in v1.2.3
type WalletApi interface { //获取钱包资产 GetAccount() (*Account, error) //提币 Withdrawal(param WithdrawParameter) (withdrawId string, err error) //划转资产 Transfer(param TransferParameter) error //获取提币记录 GetWithDrawHistory(currency *Currency) ([]DepositWithdrawHistory, error) //获取充值记录 GetDepositHistory(currency *Currency) ([]DepositWithdrawHistory, error) }
type WithdrawParameter ¶ added in v1.2.3
type WsBuilder ¶
type WsBuilder struct {
// contains filtered or unexported fields
}
func NewWsBuilder ¶
func NewWsBuilder() *WsBuilder
func (*WsBuilder) AutoReconnect ¶ added in v1.2.3
func (*WsBuilder) ConnectSuccessAfterSendMessage ¶ added in v1.2.3
func (*WsBuilder) DecompressFunc ¶ added in v1.2.3
func (*WsBuilder) ErrorHandleFunc ¶
func (*WsBuilder) ProtoHandleFunc ¶
func (*WsBuilder) ReconnectInterval ¶ added in v1.2.3
type WsConfig ¶
type WsConfig struct { WsUrl string ProxyUrl string ReqHeaders map[string][]string //连接的时候加入的头部信息 HeartbeatIntervalTime time.Duration // HeartbeatData func() []byte //心跳数据2 IsAutoReconnect bool ProtoHandleFunc func([]byte) error //协议处理函数 DecompressFunc func([]byte) ([]byte, error) //解压函数 ErrorHandleFunc func(err error) ConnectSuccessAfterSendMessage func() []byte //for reconnect IsDump bool // contains filtered or unexported fields }
type WsConn ¶
type WsConn struct { WsConfig // contains filtered or unexported fields }
func (*WsConn) SendCloseMessage ¶ added in v1.2.3
func (*WsConn) SendJsonMessage ¶
func (*WsConn) SendMessage ¶ added in v1.2.3
func (*WsConn) SendPingMessage ¶ added in v1.2.3
func (*WsConn) SendPongMessage ¶ added in v1.2.3
Source Files ¶
Click to show internal directories.
Click to hide internal directories.