okex

package
v0.0.0-...-a67d69f Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActualContractDepth

type ActualContractDepth struct {
	Asks []struct {
		Price  float64
		Volume float64
	}
	Bids []struct {
		Price  float64
		Volume float64
	}
}

ActualContractDepth better manipulated structure to return

type ActualContractTradeHistory

type ActualContractTradeHistory struct {
	Amount   float64 `json:"amount"`
	DateInMS float64 `json:"date_ms"`
	Date     float64 `json:"date"`
	Price    float64 `json:"price"`
	TID      float64 `json:"tid"`
	Type     string  `json:"buy"`
}

ActualContractTradeHistory holds contract trade history

type ActualSpotDepth

type ActualSpotDepth struct {
	Asks []struct {
		Price  float64
		Volume float64
	}
	Bids []struct {
		Price  float64
		Volume float64
	}
}

ActualSpotDepth better manipulated structure to return

type ActualSpotTradeHistory

type ActualSpotTradeHistory struct {
	Amount   float64 `json:"amount"`
	DateInMS float64 `json:"date_ms"`
	Date     float64 `json:"date"`
	Price    float64 `json:"price"`
	TID      float64 `json:"tid"`
	Type     string  `json:"buy"`
}

ActualSpotTradeHistory holds contract trade history

type CandleStickData

type CandleStickData struct {
	Timestamp float64 `json:"timestamp"`
	Open      float64 `json:"open"`
	High      float64 `json:"high"`
	Low       float64 `json:"low"`
	Close     float64 `json:"close"`
	Volume    float64 `json:"volume"`
	Amount    float64 `json:"amount"`
}

CandleStickData holds candlestick data

type ContractDepth

type ContractDepth struct {
	Asks   []interface{} `json:"asks"`
	Bids   []interface{} `json:"bids"`
	Result bool          `json:"result"`
	Error  interface{}   `json:"error_code"`
}

ContractDepth response depth

type ContractPrice

type ContractPrice struct {
	Date   string `json:"date"`
	Ticker struct {
		Buy        float64 `json:"buy"`
		ContractID int     `json:"contract_id"`
		High       float64 `json:"high"`
		Low        float64 `json:"low"`
		Last       float64 `json:"last"`
		Sell       float64 `json:"sell"`
		UnitAmount float64 `json:"unit_amount"`
		Vol        float64 `json:"vol"`
	} `json:"ticker"`
	Result bool        `json:"result"`
	Error  interface{} `json:"error_code"`
}

ContractPrice holds date and ticker price price for contracts.

type FuturePosition

type FuturePosition struct {
	ForceLiquidationPrice float64    `json:"force_liqu_price"`
	Holding               []HoldData `json:"holding"`
}

FuturePosition contains an array of holding types

type FutureTradeHistory

type FutureTradeHistory struct {
	Amount float64 `json:"amount"`
	Date   int     `json:"date"`
	Price  float64 `json:"price"`
	TID    float64 `json:"tid"`
	Type   string  `json:"type"`
}

FutureTradeHistory will contain futures trade data

type HoldData

type HoldData struct {
	BuyAmount      float64 `json:"buy_amount"`
	BuyAvailable   float64 `json:"buy_available"`
	BuyPriceAvg    float64 `json:"buy_price_avg"`
	BuyPriceCost   float64 `json:"buy_price_cost"`
	BuyProfitReal  float64 `json:"buy_profit_real"`
	ContractID     int     `json:"contract_id"`
	ContractType   string  `json:"contract_type"`
	CreateDate     int     `json:"create_date"`
	LeverRate      float64 `json:"lever_rate"`
	SellAmount     float64 `json:"sell_amount"`
	SellAvailable  float64 `json:"sell_available"`
	SellPriceAvg   float64 `json:"sell_price_avg"`
	SellPriceCost  float64 `json:"sell_price_cost"`
	SellProfitReal float64 `json:"sell_profit_real"`
	Symbol         string  `json:"symbol"`
}

HoldData is a sub type for FuturePosition

type Info

type Info struct {
	AccountRights float64 `json:"account_rights"`
	KeepDeposit   float64 `json:"keep_deposit"`
	ProfitReal    float64 `json:"profit_real"`
	ProfitUnreal  float64 `json:"profit_unreal"`
	RiskRate      float64 `json:"risk_rate"`
}

Info holds individual information

type OKEX

type OKEX struct {
	exchange.Base

	// Spot and contract market error codes as per https://www.okex.com/rest_request.html
	ErrorCodes map[string]error

	// Stores for corresponding variable checks
	ContractTypes    []string
	CurrencyPairs    []string
	ContractPosition []string
	Types            []string
}

OKEX is the overaching type across the OKEX methods

func (*OKEX) CheckContractPosition

func (o *OKEX) CheckContractPosition(position string) error

CheckContractPosition checks to see if the string is a valid position for okex

func (*OKEX) CheckContractType

func (o *OKEX) CheckContractType(contractType string) error

CheckContractType checks to see if the string is a correct asset

func (*OKEX) CheckSymbol

func (o *OKEX) CheckSymbol(symbol string) error

CheckSymbol checks to see if the string is a valid symbol for okex

func (*OKEX) CheckType

func (o *OKEX) CheckType(typeInput string) error

CheckType checks to see if the string is a correct type

func (*OKEX) GetContractCandlestickData

func (o *OKEX) GetContractCandlestickData(symbol, typeInput, contractType string, size, since int) ([]CandleStickData, error)

GetContractCandlestickData returns CandleStickData

symbol e.g. btc_usd type e.g. 1min or 1 minute candlestick data contract_type e.g. this_week size: specify data size to be acquired since: timestamp(eg:1417536000000). data after the timestamp will be returned

func (*OKEX) GetContractExchangeRate

func (o *OKEX) GetContractExchangeRate() (float64, error)

GetContractExchangeRate returns the current exchange rate for the currency pair USD-CNY exchange rate used by OKEX, updated weekly

func (*OKEX) GetContractFutureEstimatedPrice

func (o *OKEX) GetContractFutureEstimatedPrice(symbol string) (float64, error)

GetContractFutureEstimatedPrice returns futures estimated price

symbol e.g btc_usd

func (*OKEX) GetContractFuturesTradeHistory

func (o *OKEX) GetContractFuturesTradeHistory(symbol, date string, since int) error

GetContractFuturesTradeHistory returns OKEX Contract Trade History (Not for Personal)

func (*OKEX) GetContractHoldingsNumber

func (o *OKEX) GetContractHoldingsNumber(symbol, contractType string) (map[string]float64, error)

GetContractHoldingsNumber returns current number of holdings

func (*OKEX) GetContractIndexPrice

func (o *OKEX) GetContractIndexPrice(symbol string) (float64, error)

GetContractIndexPrice returns the current index price

symbol e.g. btc_usd

func (*OKEX) GetContractMarketDepth

func (o *OKEX) GetContractMarketDepth(symbol, contractType string) (ActualContractDepth, error)

GetContractMarketDepth returns contract market depth

symbol e.g. "btc_usd" contractType e.g. "this_week" "next_week" "quarter"

func (*OKEX) GetContractPosition

func (o *OKEX) GetContractPosition(symbol, contractType string) error

GetContractPosition returns User Contract Positions (Cross-Margin Mode)

func (*OKEX) GetContractPrice

func (o *OKEX) GetContractPrice(symbol, contractType string) (ContractPrice, error)

GetContractPrice returns current contract prices

symbol e.g. "btc_usd" contractType e.g. "this_week" "next_week" "quarter"

func (*OKEX) GetContractTradeHistory

func (o *OKEX) GetContractTradeHistory(symbol, contractType string) ([]ActualContractTradeHistory, error)

GetContractTradeHistory returns trade history for the contract market

func (*OKEX) GetContractUserInfo

func (o *OKEX) GetContractUserInfo() error

GetContractUserInfo returns OKEX Contract Account Info(Cross-Margin Mode)

func (*OKEX) GetContractlimit

func (o *OKEX) GetContractlimit(symbol, contractType string) (map[string]float64, error)

GetContractlimit returns upper and lower price limit

func (*OKEX) GetErrorCode

func (o *OKEX) GetErrorCode(code interface{}) error

GetErrorCode finds the associated error code and returns its corresponding string

func (*OKEX) GetExchangeAccountInfo

func (o *OKEX) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the OKEX exchange

func (*OKEX) GetOrderbookEx

func (o *OKEX) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*OKEX) GetSpotCandleStick

func (o *OKEX) GetSpotCandleStick(symbol, typeInput string, size, since int) ([]CandleStickData, error)

GetSpotCandleStick returns candlestick data

func (*OKEX) GetSpotMarketDepth

func (o *OKEX) GetSpotMarketDepth(symbol, size string) (ActualSpotDepth, error)

GetSpotMarketDepth returns Market Depth

func (*OKEX) GetSpotRecentTrades

func (o *OKEX) GetSpotRecentTrades(symbol, since string) ([]ActualSpotTradeHistory, error)

GetSpotRecentTrades returns recent trades

func (*OKEX) GetSpotTicker

func (o *OKEX) GetSpotTicker(symbol string) (SpotPrice, error)

GetSpotTicker returns Price Ticker

func (*OKEX) GetSpotTrades

func (o *OKEX) GetSpotTrades(symbol string, tid string) ([]SpotTrade, error)

GetSpotTrades for symbol since transaction id

symbol e.g. "btc_usd" tid - transactionid

func (*OKEX) GetTickerPrice

func (o *OKEX) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*OKEX) PlaceContractOrders

func (o *OKEX) PlaceContractOrders(symbol, contractType, position string, leverageRate int, price, amount float64, matchPrice bool) (float64, error)

PlaceContractOrders places orders

func (*OKEX) Run

func (o *OKEX) Run()

Run implements the OKEX wrapper

func (*OKEX) SendAuthenticatedHTTPRequest

func (o *OKEX) SendAuthenticatedHTTPRequest(method string, values url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated http request to a desired path

func (*OKEX) SetCheckVarDefaults

func (o *OKEX) SetCheckVarDefaults()

SetCheckVarDefaults sets main variables that will be used in requests because api does not return an error if there are misspellings in strings. So better to check on this, this end.

func (*OKEX) SetDefaults

func (o *OKEX) SetDefaults()

SetDefaults method assignes the default values for Bittrex

func (*OKEX) SetErrorDefaults

func (o *OKEX) SetErrorDefaults()

SetErrorDefaults sets the full error default list

func (*OKEX) Setup

func (o *OKEX) Setup(exch config.ExchangeConfig)

Setup method sets current configuration details if enabled

func (*OKEX) Start

func (o *OKEX) Start()

Start starts the OKEX go routine

func (*OKEX) UpdateOrderbook

func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*OKEX) UpdateTicker

func (o *OKEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

type SpotDepth

type SpotDepth struct {
	Asks   []interface{} `json:"asks"`
	Bids   []interface{} `json:"bids"`
	Result bool          `json:"result"`
	Error  interface{}   `json:"error_code"`
}

SpotDepth response depth

type SpotPrice

type SpotPrice struct {
	Date   string `json:"date"`
	Ticker struct {
		Buy        float64 `json:"buy,string"`
		ContractID int     `json:"contract_id"`
		High       float64 `json:"high,string"`
		Low        float64 `json:"low,string"`
		Last       float64 `json:"last,string"`
		Sell       float64 `json:"sell,string"`
		UnitAmount float64 `json:"unit_amount,string"`
		Vol        float64 `json:"vol.string"`
	} `json:"ticker"`
	Result bool        `json:"result"`
	Error  interface{} `json:"error_code"`
}

SpotPrice holds date and ticker price price for contracts.

type SpotTrade

type SpotTrade struct {
	Amount float64 `json:"amount"`
	Date   int64   `json:"date"`
	MTS    int64   `json:"date_ms"`
	Price  float64 `json:"price"`
	TID    int64   `json:"tid"`
	Type   string  `json:"type"`
}

FutureTradeHistory will contain futures trade data

type UserInfo

type UserInfo struct {
	Info struct {
		BTC Info `json:"btc"`
		LTC Info `json:"ltc"`
	} `json:"info"`
	Result bool `json:"result"`
}

UserInfo holds a collection of user data

Jump to

Keyboard shortcuts

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