Skip to content

现货支持API接口

bit_he edited this page Mar 6, 2022 · 3 revisions

公共接口,无需授权

  • GetExchangeName() 获取交易所名字,一般是个主域名
  • GetTicker(currency CurrencyPair) (*Ticker, error) 获取Ticker信息
  • GetDepth(size int, currency CurrencyPair) (*Depth, error) 获取市场深度信息

特别提醒:

  1. ask 逆序,价格从高到低,取卖一应该是: AskList[len(AskList)-1)
  2. bid 逆序,价格从高到低,取买一应该是: BidList[0]
  • GetKlineRecords(currency CurrencyPair, period , size, since int) ([]Kline, error) 获取K线数据
  • GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error) 获取交易所交易记录

私有接口,需要授权

  • GetAccount() (*Account, error) 获取账号资产信息
  • LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error) 下限价买单
//比如下postOnly订单
 order , err := okex.OKExSpot.LimitBuy("0.001", "9910", goex.BTC_USD ,goex.PostOnly))
  • 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, optional ...OptionalParameter) ([]Order, error) 获取历史订单信息
  orders, err := okex.OKExSpot.GetOrderHistorys(
		  goex.NewCurrencyPair2("DASH_USDT"),
		  goex.OptionalParameter{}.Optional("after", "6085990323539968"))
Clone this wiki locally