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 MergeOptionalParameter(values *url.Values, opts ...OptionalParameter) url.Values
- 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) AdaptUsdToUsdt() CurrencyPair
- func (pair CurrencyPair) AdaptUsdtToUsd() CurrencyPair
- func (pair CurrencyPair) Eq(c2 CurrencyPair) bool
- func (pair CurrencyPair) Reverse() CurrencyPair
- func (pair *CurrencyPair) SetAmountTickSize(tickSize int) CurrencyPair
- func (pair *CurrencyPair) SetPriceTickSize(tickSize int) CurrencyPair
- func (pair 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 OptionalParameter
- func (optional OptionalParameter) GetFloat64(name string) float64
- func (optional OptionalParameter) GetInt(name string) int
- func (optional OptionalParameter) GetInt64(name string) int64
- func (optional OptionalParameter) GetString(name string) string
- func (optional OptionalParameter) GetTime(name string) *time.Time
- func (optional OptionalParameter) Optional(name string, value interface{}) OptionalParameter
- type Order
- type OrderFeature
- type OrderType
- type PoloniexCurrency
- 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) DisableEnableCompression() *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" BINANCE_FUTURES = "binance.com_futures" 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" HBDM_SWAP = "hbdm.com_swap" 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 //永续合约 SWAP_USDT //usdt本位永续合约 )
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" //永续合约 SWAP_USDT_CONTRACT = "swap-usdt" )
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", ""} GBP = Currency{"GBP", ""} XLM = Currency{"XLM", ""} DOT = Currency{"DOT", ""} DASH = Currency{"DASH", ""} CRV = Currency{"CRV", ""} ALGO = Currency{"ALGO", ""} //currency pair BTC_KRW = CurrencyPair{CurrencyA: BTC, CurrencyB: KRW, AmountTickSize: 2, PriceTickSize: 1} ETH_KRW = CurrencyPair{CurrencyA: ETH, CurrencyB: KRW, AmountTickSize: 2, PriceTickSize: 2} ETC_KRW = CurrencyPair{CurrencyA: ETC, CurrencyB: KRW, AmountTickSize: 2, PriceTickSize: 2} LTC_KRW = CurrencyPair{CurrencyA: LTC, CurrencyB: KRW, AmountTickSize: 2, PriceTickSize: 2} BCH_KRW = CurrencyPair{CurrencyA: BCH, CurrencyB: KRW, AmountTickSize: 2, PriceTickSize: 2} BTC_USD = CurrencyPair{CurrencyA: BTC, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 1} LTC_USD = CurrencyPair{CurrencyA: LTC, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} ETH_USD = CurrencyPair{CurrencyA: ETH, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} ETC_USD = CurrencyPair{CurrencyA: ETC, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} BCH_USD = CurrencyPair{CurrencyA: BCH, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} XRP_USD = CurrencyPair{CurrencyA: XRP, CurrencyB: USD, AmountTickSize: 3, PriceTickSize: 3} BCD_USD = CurrencyPair{CurrencyA: BCD, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 3} EOS_USD = CurrencyPair{CurrencyA: EOS, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} BTG_USD = CurrencyPair{CurrencyA: BTG, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} BSV_USD = CurrencyPair{CurrencyA: BSV, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} DOT_USD = CurrencyPair{CurrencyA: DOT, CurrencyB: USD, AmountTickSize: 3, PriceTickSize: 2} DASH_USD = CurrencyPair{CurrencyA: DASH, CurrencyB: USD, AmountTickSize: 2, PriceTickSize: 2} CRV_USD = CurrencyPair{CurrencyA: CRV, CurrencyB: USD, AmountTickSize: 4, PriceTickSize: 3} ALGO_USD = CurrencyPair{CurrencyA: ALGO, CurrencyB: USD, AmountTickSize: 4, PriceTickSize: 4} BTC_USDT = CurrencyPair{CurrencyA: BTC, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 1} LTC_USDT = CurrencyPair{CurrencyA: LTC, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} BCH_USDT = CurrencyPair{CurrencyA: BCH, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} ETC_USDT = CurrencyPair{CurrencyA: ETC, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 3} ETH_USDT = CurrencyPair{CurrencyA: ETH, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} BCD_USDT = CurrencyPair{CurrencyA: BCD, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} NEO_USDT = CurrencyPair{CurrencyA: NEO, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} EOS_USDT = CurrencyPair{CurrencyA: EOS, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} XRP_USDT = CurrencyPair{CurrencyA: XRP, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} HSR_USDT = CurrencyPair{CurrencyA: HSR, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} BSV_USDT = CurrencyPair{CurrencyA: BSV, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} OKB_USDT = CurrencyPair{CurrencyA: OKB, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} HT_USDT = CurrencyPair{CurrencyA: HT, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 4} BNB_USDT = CurrencyPair{CurrencyA: BNB, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} PAX_USDT = CurrencyPair{CurrencyA: PAX, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 3} TRX_USDT = CurrencyPair{CurrencyA: TRX, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 3} DOT_USDT = CurrencyPair{CurrencyA: DOT, CurrencyB: USDT, AmountTickSize: 3, PriceTickSize: 2} DASH_USDT = CurrencyPair{CurrencyA: DASH, CurrencyB: USDT, AmountTickSize: 2, PriceTickSize: 2} CRV_USDT = CurrencyPair{CurrencyA: CRV, CurrencyB: USDT, AmountTickSize: 3, PriceTickSize: 3} ALGO_USDT = CurrencyPair{CurrencyA: ALGO, CurrencyB: USDT, AmountTickSize: 3, PriceTickSize: 4} XRP_EUR = CurrencyPair{CurrencyA: XRP, CurrencyB: EUR, AmountTickSize: 2, PriceTickSize: 4} BTC_JPY = CurrencyPair{CurrencyA: BTC, CurrencyB: JPY, AmountTickSize: 2, PriceTickSize: 0} LTC_JPY = CurrencyPair{CurrencyA: LTC, CurrencyB: JPY, AmountTickSize: 2, PriceTickSize: 0} ETH_JPY = CurrencyPair{CurrencyA: ETH, CurrencyB: JPY, AmountTickSize: 2, PriceTickSize: 0} ETC_JPY = CurrencyPair{CurrencyA: ETC, CurrencyB: JPY, AmountTickSize: 2, PriceTickSize: 0} BCH_JPY = CurrencyPair{CurrencyA: BCH, CurrencyB: JPY, AmountTickSize: 2, PriceTickSize: 0} LTC_BTC = CurrencyPair{CurrencyA: LTC, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} ETH_BTC = CurrencyPair{CurrencyA: ETH, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} ETC_BTC = CurrencyPair{CurrencyA: ETC, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} BCC_BTC = CurrencyPair{CurrencyA: BCC, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} BCH_BTC = CurrencyPair{CurrencyA: BCH, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} DCR_BTC = CurrencyPair{CurrencyA: DCR, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} XRP_BTC = CurrencyPair{CurrencyA: XRP, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 6} BTG_BTC = CurrencyPair{CurrencyA: BTG, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} BCD_BTC = CurrencyPair{CurrencyA: BCD, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} NEO_BTC = CurrencyPair{CurrencyA: NEO, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} EOS_BTC = CurrencyPair{CurrencyA: EOS, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 5} HSR_BTC = CurrencyPair{CurrencyA: HSR, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} BSV_BTC = CurrencyPair{CurrencyA: BSV, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 4} OKB_BTC = CurrencyPair{CurrencyA: OKB, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 6} HT_BTC = CurrencyPair{CurrencyA: HT, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 7} BNB_BTC = CurrencyPair{CurrencyA: BNB, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 6} TRX_BTC = CurrencyPair{CurrencyA: TRX, CurrencyB: BTC, AmountTickSize: 2, PriceTickSize: 7} DOT_BTC = CurrencyPair{CurrencyA: DOT, CurrencyB: BTC, AmountTickSize: 3, PriceTickSize: 6} ETC_ETH = CurrencyPair{CurrencyA: ETC, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} EOS_ETH = CurrencyPair{CurrencyA: EOS, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} ZEC_ETH = CurrencyPair{CurrencyA: ZEC, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} NEO_ETH = CurrencyPair{CurrencyA: NEO, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} HSR_ETH = CurrencyPair{CurrencyA: HSR, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} LTC_ETH = CurrencyPair{CurrencyA: LTC, CurrencyB: ETH, AmountTickSize: 2, PriceTickSize: 4} UNKNOWN_PAIR = CurrencyPair{CurrencyA: UNKNOWN, CurrencyB: 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 ¶
func FloatToFixed ¶
func FloatToString ¶
func GenerateOrderClientId ¶
func GetParamHmacMD5Sign ¶
func GetParamHmacSHA1Sign ¶
func GetParamHmacSHA256Sign ¶
func GetParamHmacSHA512Sign ¶
func GetParamHmacSha384Sign ¶
for bitfinex.com
func GzipDecompress ¶
func HttpDeleteForm ¶
func HttpPostForm ¶
func HttpPostForm2 ¶
func HttpPostForm3 ¶
func HttpPostForm4 ¶
func MergeOptionalParameter ¶
func MergeOptionalParameter(values *url.Values, opts ...OptionalParameter) url.Values
func NewHttpRequest ¶
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, opt ...OptionalParameter) ([]Order, error) GetAccount() (*Account, error) GetTicker(currency CurrencyPair) (*Ticker, error) GetDepth(size int, currency CurrencyPair) (*Depth, error) GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]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 ¶
type CurrencyPair struct { CurrencyA Currency CurrencyB Currency AmountTickSize int // 下单量精度 PriceTickSize int //交易对价格精度 }
A->B(A兑换为B)
func NewCurrencyPair ¶
func NewCurrencyPair(currencyA Currency, currencyB Currency) CurrencyPair
func NewCurrencyPair2 ¶
func NewCurrencyPair2(currencyPairSymbol string) CurrencyPair
func NewCurrencyPair3 ¶
func NewCurrencyPair3(currencyPairSymbol string, sep string) CurrencyPair
func (CurrencyPair) AdaptUsdToUsdt ¶
func (pair CurrencyPair) AdaptUsdToUsdt() CurrencyPair
func (CurrencyPair) AdaptUsdtToUsd ¶
func (pair CurrencyPair) AdaptUsdtToUsd() CurrencyPair
func (CurrencyPair) Eq ¶
func (pair CurrencyPair) Eq(c2 CurrencyPair) bool
func (CurrencyPair) Reverse ¶
func (pair CurrencyPair) Reverse() CurrencyPair
func (*CurrencyPair) SetAmountTickSize ¶
func (pair *CurrencyPair) SetAmountTickSize(tickSize int) CurrencyPair
func (*CurrencyPair) SetPriceTickSize ¶
func (pair *CurrencyPair) SetPriceTickSize(tickSize int) CurrencyPair
func (CurrencyPair) String ¶
func (pair 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 ¶
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) /** * 获取个人订单历史,默认获取最近的订单历史列表,返回多少条订单数据,需根据平台接口定义而定 */ GetFutureOrderHistory(pair CurrencyPair, contractType string, optional ...OptionalParameter) ([]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 KlinePeriod, size int, optional ...OptionalParameter) ([]FutureKline, error) /** * 获取Trade数据 */ GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error) }
type FutureSubAccount ¶
type FutureTicker ¶
type FuturesContractInfo ¶
type FuturesWsApi ¶
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 ¶
type KlinePeriod ¶
type KlinePeriod int
type LimitOrderOptionalParameter ¶
type LimitOrderOptionalParameter int
const ( PostOnly LimitOrderOptionalParameter = iota + 1 Ioc Fok )
func (LimitOrderOptionalParameter) String ¶
func (opt LimitOrderOptionalParameter) String() string
type MarginAccount ¶
type MarginAccount struct { Sub map[Currency]MarginSubAccount LiquidationPrice float64 RiskRate float64 MarginRatio float64 }
type MarginSubAccount ¶
type OptionalParameter ¶
type OptionalParameter map[string]interface{}
func (OptionalParameter) GetFloat64 ¶
func (optional OptionalParameter) GetFloat64(name string) float64
func (OptionalParameter) GetInt ¶
func (optional OptionalParameter) GetInt(name string) int
func (OptionalParameter) GetInt64 ¶
func (optional OptionalParameter) GetInt64(name string) int64
func (OptionalParameter) GetString ¶
func (optional OptionalParameter) GetString(name string) string
func (OptionalParameter) GetTime ¶
func (optional OptionalParameter) GetTime(name string) *time.Time
func (OptionalParameter) Optional ¶
func (optional OptionalParameter) Optional(name string, value interface{}) OptionalParameter
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 ¶
type OrderFeature int
func (OrderFeature) String ¶
func (of OrderFeature) String() string
type PoloniexCurrency ¶
type PoloniexCurrency struct { ID int `json:"id"` Name string `json:"name"` HumanType string `json:"humanType"` CurrencyType string `json:"currencyType"` TxFee string `json:"txFee"` MinConf int `json:"minConf"` DepositAddress string `json:"depositAddress"` Disabled int `json:"disabled"` //Designates whether (1) or not (0) deposits and withdrawals are disabled. Frozen int `json:"frozen"` //Designates whether (1) or not (0) trading for this currency is disabled for trading. Blockchain string `json:"blockchain"` Delisted int `json:"delisted"` IsGeofenced int `json:"isGeofenced"` }
type RepaymentParameter ¶
type RepaymentParameter struct { BorrowParameter BorrowId string }
type SpotWsApi ¶
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 ¶
type WalletApi ¶
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 ¶
type WsBuilder ¶
type WsBuilder struct {
// contains filtered or unexported fields
}
func NewWsBuilder ¶
func NewWsBuilder() *WsBuilder
func (*WsBuilder) AutoReconnect ¶
func (*WsBuilder) ConnectSuccessAfterSendMessage ¶
func (*WsBuilder) DecompressFunc ¶
func (*WsBuilder) DisableEnableCompression ¶
func (*WsBuilder) ErrorHandleFunc ¶
func (*WsBuilder) ProtoHandleFunc ¶
func (*WsBuilder) ReconnectInterval ¶
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 DisableEnableCompression bool // contains filtered or unexported fields }
type WsConn ¶
type WsConn struct { WsConfig // contains filtered or unexported fields }
func (*WsConn) SendCloseMessage ¶
func (*WsConn) SendJsonMessage ¶
func (*WsConn) SendMessage ¶
func (*WsConn) SendPingMessage ¶
func (*WsConn) SendPongMessage ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.