okex

package
v0.0.0-...-4c12c4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 10 Imported by: 0

README

GoCryptoTrader package Okex

Build Status Software License GoDoc Coverage Status Go Report Card

This okex package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

OKex Exchange

Current Features
  • REST Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var o exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "OKex" {
    y = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := o.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := o.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := o.GetAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := o.GetSpotTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := o.GetSpotMarketDepth()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetContractPosition returns contract positioning
accountInfo, err := o.GetContractPosition(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := o.PlaceContractOrders(...)
if err != nil {
  // Handle error
}
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

View Source
const (

	// OkExWebsocketURL WebsocketURL
	OkExWebsocketURL = "wss://real.okex.com:10442/ws/v3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OKEX

type OKEX struct {
	okgroup.OKGroup
}

OKEX bases all account, spot and margin methods off okgroup implementation

func (*OKEX) CancelETTOrder

func (o *OKEX) CancelETTOrder(orderID string) (resp okgroup.PlaceETTOrderResponse, _ error)

CancelETTOrder Cancel an unfilled order.

func (*OKEX) CancelFuturesOrder

func (o *OKEX) CancelFuturesOrder(request okgroup.CancelFuturesOrderRequest) (resp okgroup.CancelFuturesOrderResponse, _ error)

CancelFuturesOrder Cancelling an unfilled order.

func (*OKEX) CancelFuturesOrderBatch

func (o *OKEX) CancelFuturesOrderBatch(request okgroup.CancelMultipleSpotOrdersRequest) (resp okgroup.CancelMultipleSpotOrdersResponse, _ error)

CancelFuturesOrderBatch With best effort, cancel all open orders.

func (*OKEX) CancelMultipleSwapOrders

func (o *OKEX) CancelMultipleSwapOrders(request okgroup.CancelMultipleSwapOrdersRequest) (resp okgroup.CancelMultipleSwapOrdersResponse, _ error)

CancelMultipleSwapOrders With best effort, cancel all open orders.

func (*OKEX) CancelSwapOrder

func (o *OKEX) CancelSwapOrder(request okgroup.CancelSwapOrderRequest) (resp okgroup.CancelSwapOrderResponse, _ error)

CancelSwapOrder Cancelling an unfilled order

func (*OKEX) GetAllFuturesTokenInfo

func (o *OKEX) GetAllFuturesTokenInfo() (resp []okgroup.GetFuturesTokenInfoResponse, _ error)

GetAllFuturesTokenInfo Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all contracts.

func (*OKEX) GetAllSwapTokensInformation

func (o *OKEX) GetAllSwapTokensInformation() (resp []okgroup.GetAllSwapTokensInformationResponse, _ error)

GetAllSwapTokensInformation Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all contracts.

func (*OKEX) GetETT

func (o *OKEX) GetETT() (resp []okgroup.GetETTResponse, _ error)

GetETT List the assets in ETT account. Get information such as balance, amount on hold/ available.

func (*OKEX) GetETTAccountInformationForCurrency

func (o *OKEX) GetETTAccountInformationForCurrency(currency string) (resp okgroup.GetETTResponse, _ error)

GetETTAccountInformationForCurrency Getting the balance, amount available/on hold of a token in ETT account.

func (*OKEX) GetETTBillsDetails

func (o *OKEX) GetETTBillsDetails(currency string) (resp []okgroup.GetETTBillsDetailsResponse, _ error)

GetETTBillsDetails Bills details. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first

func (*OKEX) GetETTConstituents

func (o *OKEX) GetETTConstituents(ett string) (resp okgroup.GetETTConstituentsResponse, _ error)

GetETTConstituents Get ETT Constituents.This is a public endpoint, no identity verification is needed.

func (*OKEX) GetETTOrderDetails

func (o *OKEX) GetETTOrderDetails(orderID string) (resp okgroup.GetETTOrderListResponse, _ error)

GetETTOrderDetails Get order details by order ID.

func (*OKEX) GetETTOrderList

func (o *OKEX) GetETTOrderList(request okgroup.GetETTOrderListRequest) (resp []okgroup.GetETTOrderListResponse, _ error)

GetETTOrderList List your orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetETTSettlementPriceHistory

func (o *OKEX) GetETTSettlementPriceHistory(ett string) (resp []okgroup.GetETTSettlementPriceHistoryResponse, _ error)

GetETTSettlementPriceHistory Get ETT settlement price history. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesAccountOfACurrency

func (o *OKEX) GetFuturesAccountOfACurrency(instrumentID string) (resp okgroup.FuturesCurrencyData, _ error)

GetFuturesAccountOfACurrency Get the futures account info of a token.

func (*OKEX) GetFuturesAccountOfAllCurrencies

func (o *OKEX) GetFuturesAccountOfAllCurrencies() (resp okgroup.FuturesAccountForAllCurrenciesResponse, _ error)

GetFuturesAccountOfAllCurrencies Get the futures account info of all token. Due to high energy consumption, you are advised to capture data with the "Futures Account of a Currency" API instead.

func (*OKEX) GetFuturesBillDetails

GetFuturesBillDetails Shows the account’s historical coin in flow and out flow. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetFuturesContractInformation

func (o *OKEX) GetFuturesContractInformation() (resp []okgroup.GetFuturesContractInformationResponse, _ error)

GetFuturesContractInformation Get market data. This endpoint provides the snapshots of market data and can be used without verifications.

func (*OKEX) GetFuturesCurrentMarkPrice

func (o *OKEX) GetFuturesCurrentMarkPrice(instrumentID string) (resp okgroup.GetFuturesCurrentMarkPriceResponse, _ error)

GetFuturesCurrentMarkPrice The maximum buying price and the minimum selling price of the contract. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesCurrentPriceLimit

func (o *OKEX) GetFuturesCurrentPriceLimit(instrumentID string) (resp okgroup.GetFuturesCurrentPriceLimitResponse, _ error)

GetFuturesCurrentPriceLimit The maximum buying price and the minimum selling price of the contract. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesEstimatedDeliveryPrice

func (o *OKEX) GetFuturesEstimatedDeliveryPrice(instrumentID string) (resp okgroup.GetFuturesEstimatedDeliveryPriceResponse, _ error)

GetFuturesEstimatedDeliveryPrice the estimated delivery price. It is available 3 hours before delivery. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesExchangeRates

func (o *OKEX) GetFuturesExchangeRates() (resp okgroup.GetFuturesExchangeRatesResponse, _ error)

GetFuturesExchangeRates Get the fiat exchange rates. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesFilledOrder

func (o *OKEX) GetFuturesFilledOrder(request okgroup.GetFuturesFilledOrderRequest) (resp []okgroup.GetFuturesFilledOrdersResponse, _ error)

GetFuturesFilledOrder Get the recent 300 transactions of all contracts. Pagination is not supported here. The whole book will be returned for one request. Websocket is recommended here.

func (*OKEX) GetFuturesForceLiquidatedOrders

func (o *OKEX) GetFuturesForceLiquidatedOrders(request okgroup.GetFuturesForceLiquidatedOrdersRequest) (resp []okgroup.GetFuturesForceLiquidatedOrdersResponse, _ error)

GetFuturesForceLiquidatedOrders Get force liquidated orders. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesHoldAmount

func (o *OKEX) GetFuturesHoldAmount(instrumentID string) (resp okgroup.GetFuturesHoldAmountResponse, _ error)

GetFuturesHoldAmount Get the number of futures with hold.

func (*OKEX) GetFuturesIndices

func (o *OKEX) GetFuturesIndices(instrumentID string) (resp okgroup.GetFuturesIndicesResponse, _ error)

GetFuturesIndices Get Indices of tokens. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesLeverage

func (o *OKEX) GetFuturesLeverage(instrumentID string) (resp okgroup.GetFuturesLeverageResponse, _ error)

GetFuturesLeverage Get the leverage of the futures account

func (*OKEX) GetFuturesMarketData

func (o *OKEX) GetFuturesMarketData(request okgroup.GetFuturesMarketDateRequest) (resp okgroup.GetFuturesMarketDataResponse, _ error)

GetFuturesMarketData Get the charts of the trading pairs. Charts are returned in grouped buckets based on requested granularity.

func (*OKEX) GetFuturesOpenInterests

func (o *OKEX) GetFuturesOpenInterests(instrumentID string) (resp okgroup.GetFuturesOpenInterestsResponse, _ error)

GetFuturesOpenInterests Get the open interest of a contract. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesOrderBook

func (o *OKEX) GetFuturesOrderBook(request okgroup.GetFuturesOrderBookRequest) (resp okgroup.GetFuturesOrderBookResponse, err error)

GetFuturesOrderBook List all contracts. This request does not support pagination. The full list will be returned for a request.

func (*OKEX) GetFuturesOrderDetails

func (o *OKEX) GetFuturesOrderDetails(request okgroup.GetFuturesOrderDetailsRequest) (resp okgroup.GetFuturesOrderDetailsResponseData, _ error)

GetFuturesOrderDetails Get order details by order ID.

func (*OKEX) GetFuturesOrderList

func (o *OKEX) GetFuturesOrderList(request okgroup.GetFuturesOrdersListRequest) (resp okgroup.GetFuturesOrderListResponse, _ error)

GetFuturesOrderList List your orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetFuturesPostions

func (o *OKEX) GetFuturesPostions() (resp okgroup.GetFuturesPositionsResponse, _ error)

GetFuturesPostions Get the information of all holding positions in futures trading. Due to high energy consumption, you are advised to capture data with the "Futures Account of a Currency" API instead.

func (*OKEX) GetFuturesPostionsForCurrency

func (o *OKEX) GetFuturesPostionsForCurrency(instrumentID string) (resp okgroup.GetFuturesPositionsForCurrencyResponse, _ error)

GetFuturesPostionsForCurrency Get the information of holding positions of a contract.

func (*OKEX) GetFuturesTagPrice

func (o *OKEX) GetFuturesTagPrice(instrumentID string) (resp okgroup.GetFuturesTagPriceResponse, _ error)

GetFuturesTagPrice Get the tag price. This is a public endpoint, no identity verification is needed.

func (*OKEX) GetFuturesTokenInfoForCurrency

func (o *OKEX) GetFuturesTokenInfoForCurrency(instrumentID string) (resp okgroup.GetFuturesTokenInfoResponse, _ error)

GetFuturesTokenInfoForCurrency Get the last traded price, best bid/ask price, 24 hour trading volume and more info of a contract.

func (*OKEX) GetFuturesTransactionDetails

func (o *OKEX) GetFuturesTransactionDetails(request okgroup.GetFuturesTransactionDetailsRequest) (resp []okgroup.GetFuturesTransactionDetailsResponse, _ error)

GetFuturesTransactionDetails Get details of the recent filled orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetSwapAccountOfAllCurrency

func (o *OKEX) GetSwapAccountOfAllCurrency() (resp okgroup.GetSwapAccountOfAllCurrencyResponse, _ error)

GetSwapAccountOfAllCurrency Get the perpetual swap account info of a token. Margin ratio set as 10,000 when users have no open position.

func (*OKEX) GetSwapAccountSettingsOfAContract

func (o *OKEX) GetSwapAccountSettingsOfAContract(instrumentID string) (resp okgroup.GetSwapAccountSettingsOfAContractResponse, _ error)

GetSwapAccountSettingsOfAContract Get leverage level and margin mode of a contract.

func (*OKEX) GetSwapBillDetails

func (o *OKEX) GetSwapBillDetails(request okgroup.GetSpotBillDetailsForCurrencyRequest) (resp []okgroup.GetSwapBillDetailsResponse, _ error)

GetSwapBillDetails Shows the account’s historical coin in flow and out flow. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetSwapContractInformation

func (o *OKEX) GetSwapContractInformation() (resp []okgroup.GetSwapContractInformationResponse, _ error)

GetSwapContractInformation Get market data.

func (*OKEX) GetSwapCurrentPriceLimits

func (o *OKEX) GetSwapCurrentPriceLimits(instrumentID string) (resp okgroup.GetSwapCurrentPriceLimitsResponse, _ error)

GetSwapCurrentPriceLimits Get the open interest of a contract.

func (*OKEX) GetSwapExchangeRates

func (o *OKEX) GetSwapExchangeRates() (resp okgroup.GetSwapExchangeRatesResponse, _ error)

GetSwapExchangeRates Get the fiat exchange rates.

func (*OKEX) GetSwapFilledOrdersData

func (o *OKEX) GetSwapFilledOrdersData(request *okgroup.GetSwapFilledOrdersDataRequest) (resp []okgroup.GetSwapFilledOrdersDataResponse, _ error)

GetSwapFilledOrdersData Get details of the recent filled orders

func (*OKEX) GetSwapForceLiquidatedOrders

func (o *OKEX) GetSwapForceLiquidatedOrders(request okgroup.GetSwapForceLiquidatedOrdersRequest) (resp []okgroup.GetSwapForceLiquidatedOrdersResponse, _ error)

GetSwapForceLiquidatedOrders Get force liquidated orders.

func (*OKEX) GetSwapFundingRateHistory

func (o *OKEX) GetSwapFundingRateHistory(request okgroup.GetSwapFundingRateHistoryRequest) (resp []okgroup.GetSwapFundingRateHistoryResponse, _ error)

GetSwapFundingRateHistory Get Funding Rate History.

func (*OKEX) GetSwapIndices

func (o *OKEX) GetSwapIndices(instrumentID string) (resp okgroup.GetSwapIndecesResponse, _ error)

GetSwapIndices Get Indices of tokens.

func (*OKEX) GetSwapMarkPrice

func (o *OKEX) GetSwapMarkPrice(instrumentID string) (resp okgroup.GetSwapMarkPriceResponse, _ error)

GetSwapMarkPrice Get the time of next settlement.

func (*OKEX) GetSwapMarketData

func (o *OKEX) GetSwapMarketData(request okgroup.GetSwapMarketDataRequest) (resp []okgroup.GetSwapMarketDataResponse, _ error)

GetSwapMarketData Get the charts of the trading pairs.

func (*OKEX) GetSwapNextSettlementTime

func (o *OKEX) GetSwapNextSettlementTime(instrumentID string) (resp okgroup.GetSwapNextSettlementTimeResponse, _ error)

GetSwapNextSettlementTime Get the time of next settlement.

func (*OKEX) GetSwapOnHoldAmountForOpenOrders

func (o *OKEX) GetSwapOnHoldAmountForOpenOrders(instrumentID string) (resp okgroup.GetSwapOnHoldAmountForOpenOrdersResponse, _ error)

GetSwapOnHoldAmountForOpenOrders Get On Hold Amount for Open Orders.

func (*OKEX) GetSwapOpenInterest

func (o *OKEX) GetSwapOpenInterest(instrumentID string) (resp okgroup.GetSwapExchangeRatesResponse, _ error)

GetSwapOpenInterest Get the open interest of a contract.

func (*OKEX) GetSwapOrderBook

func (o *OKEX) GetSwapOrderBook(request okgroup.GetSwapOrderBookRequest) (resp okgroup.GetSwapOrderBookResponse, _ error)

GetSwapOrderBook Get the charts of the trading pairs.

func (*OKEX) GetSwapOrderDetails

func (o *OKEX) GetSwapOrderDetails(request okgroup.GetSwapOrderDetailsRequest) (resp okgroup.GetSwapOrderListResponseData, _ error)

GetSwapOrderDetails Get order details by order ID.

func (*OKEX) GetSwapOrderList

func (o *OKEX) GetSwapOrderList(request okgroup.GetSwapOrderListRequest) (resp okgroup.GetSwapOrderListResponse, _ error)

GetSwapOrderList List your orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

func (*OKEX) GetSwapPostions

func (o *OKEX) GetSwapPostions() (resp []okgroup.GetSwapPostionsResponse, _ error)

GetSwapPostions Get the information of all holding positions in swap trading. Due to high energy consumption, you are advised to capture data with the "Swap Account of a Currency" API instead.

func (*OKEX) GetSwapPostionsForContract

func (o *OKEX) GetSwapPostionsForContract(instrumentID string) (resp okgroup.GetSwapPostionsResponse, _ error)

GetSwapPostionsForContract Get the information of holding positions of a contract.

func (*OKEX) GetSwapTokensInformationForCurrency

func (o *OKEX) GetSwapTokensInformationForCurrency(instrumentID string) (resp okgroup.GetAllSwapTokensInformationResponse, _ error)

GetSwapTokensInformationForCurrency Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all contracts.

func (*OKEX) GetSwapTransactionDetails

func (o *OKEX) GetSwapTransactionDetails(request okgroup.GetSwapTransactionDetailsRequest) (resp []okgroup.GetSwapTransactionDetailsResponse, _ error)

GetSwapTransactionDetails Get details of the recent filled orders

func (*OKEX) PlaceETTOrder

func (o *OKEX) PlaceETTOrder(request *okgroup.PlaceETTOrderRequest) (resp okgroup.PlaceETTOrderResponse, _ error)

PlaceETTOrder You can place subscription or redemption orders under ETT trading. You can place an order only if you have enough funds. Once your order is placed, the amount will be put on hold in the order lifecycle. The assets and amount on hold depends on the order's specific type and parameters.

func (*OKEX) PlaceFuturesOrder

func (o *OKEX) PlaceFuturesOrder(request okgroup.PlaceFuturesOrderRequest) (resp okgroup.PlaceFuturesOrderResponse, _ error)

PlaceFuturesOrder OKEx futures trading only supports limit orders. You can place an order only if you have enough funds. Once your order is placed, the amount will be put on hold in the order lifecycle. The assets and amount on hold depends on the order's specific type and parameters.

func (*OKEX) PlaceFuturesOrderBatch

func (o *OKEX) PlaceFuturesOrderBatch(request okgroup.PlaceFuturesOrderBatchRequest) (resp okgroup.PlaceFuturesOrderBatchResponse, _ error)

PlaceFuturesOrderBatch Batch contract placing order operation.

func (*OKEX) PlaceMultipleSwapOrders

func (o *OKEX) PlaceMultipleSwapOrders(request okgroup.PlaceMultipleSwapOrdersRequest) (resp okgroup.PlaceMultipleSwapOrdersResponse, _ error)

PlaceMultipleSwapOrders Batch contract placing order operation.

func (*OKEX) PlaceSwapOrder

func (o *OKEX) PlaceSwapOrder(request okgroup.PlaceSwapOrderRequest) (resp okgroup.PlaceSwapOrderResponse, _ error)

PlaceSwapOrder OKEx perpetual swap trading only supports limit orders,USD as quote currency for orders. You can place an order only if you have enough funds. Once your order is placed, the amount will be put on hold in the order lifecycle. The assets and amount on hold depends on the order's specific type and parameters.

func (*OKEX) SetDefaults

func (o *OKEX) SetDefaults()

SetDefaults method assignes the default values for OKEX

func (*OKEX) SetFuturesLeverage

func (o *OKEX) SetFuturesLeverage(request okgroup.SetFuturesLeverageRequest) (resp okgroup.SetFuturesLeverageResponse, _ error)

SetFuturesLeverage Adjusting the leverage for futures account。 Cross margin request requirements: {"leverage":"10"} Fixed margin request requirements: {"instrument_id":"BTC-USD-180213","direction":"long","leverage":"10"}

func (*OKEX) SetSwapLeverageLevelOfAContract

func (o *OKEX) SetSwapLeverageLevelOfAContract(request okgroup.SetSwapLeverageLevelOfAContractRequest) (resp okgroup.SetSwapLeverageLevelOfAContractResponse, _ error)

SetSwapLeverageLevelOfAContract Setting the leverage level of a contract TODO this returns invalid parameters, but matches spec. Unsure how to fix

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL