okex

package
v0.0.0-...-db5ea55 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 13
	DEFAULT_TAKER_FEE    = 0.0015
	DEFAULT_MAKER_FEE    = 0.001
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001
	DEFAULT_CONFIRMATION = 2
	DEFAULT_LISTED       = true
)
View Source
const (
	API_URL string = "https://www.okex.com"
)

Variables

This section is empty.

Functions

func IsoTime

func IsoTime() string

Types

type AccountBalances

type AccountBalances []struct {
	Frozen    string `json:"frozen"`
	Hold      string `json:"hold"`
	ID        string `json:"id"`
	Currency  string `json:"currency"`
	Balance   string `json:"balance"`
	Available string `json:"available"`
	Holds     string `json:"holds"`
}

type AssetBalance

type AssetBalance []struct {
	ID        string `json:"id"`
	Balance   string `json:"balance"`
	Available string `json:"available"`
	Currency  string `json:"currency"`
	Hold      string `json:"hold"`
}

type CoinsData

type CoinsData []struct {
	CanDeposit    string `json:"can_deposit"`
	CanWithdraw   string `json:"can_withdraw"`
	Currency      string `json:"currency"`
	MinWithdrawal string `json:"min_withdrawal"`
	Name          string `json:"name"`
}

type ErrorMsg

type ErrorMsg struct {
	Code string `json:"code"`
	Msg  string `json:"message"`
}

type Okex

type Okex struct {
	ID      int
	Name    string `bson:"name"`
	Website string `bson:"website"`

	API_KEY       string
	API_SECRET    string
	Passphrase    string
	TradePassword string

	Source    exchange.DataSource // / exchange API / microservicve api 1 / PSQL
	SourceURI string
}

func CreateOkex

func CreateOkex(config *exchange.Config) *Okex

*************************************************

func (*Okex) ApiKeyRequest

func (e *Okex) ApiKeyRequest(method string, mapParams map[string]interface{}, strRequestPath string) string

************** Signature Http Request ************** Method: API Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request Step 3: Add HttpGetRequest below strUrl if API has different requests

func (*Okex) CanDeposit

func (e *Okex) CanDeposit(coin *coin.Coin) bool

func (*Okex) CanWithdraw

func (e *Okex) CanWithdraw(coin *coin.Coin) bool

func (*Okex) CancelAllOrder

func (e *Okex) CancelAllOrder() error

func (*Okex) CancelOrder

func (e *Okex) CancelOrder(order *exchange.Order) error

func (*Okex) DeleteCoin

func (e *Okex) DeleteCoin(coin *coin.Coin)

func (*Okex) DeletePair

func (e *Okex) DeletePair(pair *pair.Pair)

func (*Okex) DoAccountOperation

func (e *Okex) DoAccountOperation(operation *exchange.AccountOperation) error

func (*Okex) GetBalance

func (e *Okex) GetBalance(coin *coin.Coin) float64

func (*Okex) GetCoinBySymbol

func (e *Okex) GetCoinBySymbol(symbol string) *coin.Coin

func (*Okex) GetCoinConstraint

func (e *Okex) GetCoinConstraint(coin *coin.Coin) *exchange.CoinConstraint

************** Coins on the Exchanges **************

func (*Okex) GetCoins

func (e *Okex) GetCoins() []*coin.Coin

func (*Okex) GetCoinsData

func (e *Okex) GetCoinsData() error

************** Public API ************** Get Coins Information (If API provide) Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Okex) GetConfirmation

func (e *Okex) GetConfirmation(coin *coin.Coin) int

func (*Okex) GetConstraintFetchMethod

func (e *Okex) GetConstraintFetchMethod(pair *pair.Pair) *exchange.ConstrainFetchMethod

*************** Exchange Constraint ***************

func (*Okex) GetFee

func (e *Okex) GetFee(pair *pair.Pair) float64

*************** Pair Constraint ***************

func (*Okex) GetID

func (e *Okex) GetID() int

*************** Exchange Information ***************

func (*Okex) GetLotSize

func (e *Okex) GetLotSize(pair *pair.Pair) float64

func (*Okex) GetName

func (e *Okex) GetName() exchange.ExchangeName

func (*Okex) GetPairBySymbol

func (e *Okex) GetPairBySymbol(symbol string) *pair.Pair

func (*Okex) GetPairConstraint

func (e *Okex) GetPairConstraint(pair *pair.Pair) *exchange.PairConstraint

************** Pairs on the Exchanges **************

func (*Okex) GetPairs

func (e *Okex) GetPairs() []*pair.Pair

func (*Okex) GetPairsData

func (e *Okex) GetPairsData() error
GetPairsData - Get Pairs Information (If API provide)

Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Okex) GetPriceFilter

func (e *Okex) GetPriceFilter(pair *pair.Pair) float64

func (*Okex) GetSymbolByCoin

func (e *Okex) GetSymbolByCoin(coin *coin.Coin) string

func (*Okex) GetSymbolByPair

func (e *Okex) GetSymbolByPair(pair *pair.Pair) string

func (*Okex) GetTradingWebURL

func (e *Okex) GetTradingWebURL(pair *pair.Pair) string

func (*Okex) GetTxFee

func (e *Okex) GetTxFee(coin *coin.Coin) float64

*************** Coin Constraint ***************

func (*Okex) HasPair

func (e *Okex) HasPair(pair *pair.Pair) bool

func (*Okex) InitData

func (e *Okex) InitData() error

func (*Okex) LimitBuy

func (e *Okex) LimitBuy(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Okex) LimitSell

func (e *Okex) LimitSell(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Okex) ListOrders

func (e *Okex) ListOrders() ([]*exchange.Order, error)

func (*Okex) LoadPublicData

func (e *Okex) LoadPublicData(operation *exchange.PublicOperation) error

func (*Okex) OrderBook

func (e *Okex) OrderBook(pair *pair.Pair) (*exchange.Maker, error)

Get Pair Market Depth Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Get Exchange Pair Code ex. symbol := e.GetPairCode(p) Step 4: Modify API Path(strRequestUrl) Step 5: Add Params - Depend on API request Step 6: Convert the response to Standard Maker struct

func (*Okex) OrderStatus

func (e *Okex) OrderStatus(order *exchange.Order) error

func (*Okex) SetCoinConstraint

func (e *Okex) SetCoinConstraint(coinConstraint *exchange.CoinConstraint)

func (*Okex) SetPairConstraint

func (e *Okex) SetPairConstraint(pairConstraint *exchange.PairConstraint)

func (*Okex) Transfer

func (e *Okex) Transfer(coin *coin.Coin, quantity float64, from, to int) bool

func (*Okex) UpdateAllBalances

func (e *Okex) UpdateAllBalances()

func (*Okex) UpdateConstraint

func (e *Okex) UpdateConstraint()

func (*Okex) Withdraw

func (e *Okex) Withdraw(coin *coin.Coin, quantity float64, addr, tag string) bool

func (*Okex) WithdrawFee

func (e *Okex) WithdrawFee() error

type OpenOrders

type OpenOrders []struct {
	ClientOid      string    `json:"client_oid"`
	CreatedAt      time.Time `json:"created_at"`
	FilledNotional string    `json:"filled_notional"`
	FilledSize     string    `json:"filled_size"`
	Funds          string    `json:"funds"`
	InstrumentID   string    `json:"instrument_id"`
	Notional       string    `json:"notional"`
	OrderID        string    `json:"order_id"`
	OrderType      string    `json:"order_type"`
	Price          string    `json:"price"`
	PriceAvg       string    `json:"price_avg"`
	ProductID      string    `json:"product_id"`
	Side           string    `json:"side"`
	Size           string    `json:"size"`
	Status         string    `json:"status"`
	State          string    `json:"state"`
	Timestamp      time.Time `json:"timestamp"`
	Type           string    `json:"type"`
}

type OrderBook

type OrderBook struct {
	Asks      [][]string `json:"asks"`
	Bids      [][]string `json:"bids"`
	Timestamp time.Time  `json:"timestamp"`
}

type OrderStatus

type OrderStatus struct {
	OrderID        string    `json:"order_id"`
	Notional       string    `json:"notional"`
	Price          string    `json:"price"`
	Size           string    `json:"size"`
	InstrumentID   string    `json:"instrument_id"`
	Side           string    `json:"side"`
	Type           string    `json:"type"`
	Timestamp      time.Time `json:"timestamp"`
	FilledSize     string    `json:"filled_size"`
	FilledNotional string    `json:"filled_notional"`
	Status         string    `json:"status"`
	Code           string    `json:"code"`
	Message        string    `json:"message"`
}

type PairsData

type PairsData []struct {
	BaseCurrency  string `json:"base_currency"`
	InstrumentID  string `json:"instrument_id"`
	MinSize       string `json:"min_size"`
	QuoteCurrency string `json:"quote_currency"`
	SizeIncrement string `json:"size_increment"`
	TickSize      string `json:"tick_size"`
}

type PlaceOrder

type PlaceOrder struct {
	OrderID   string `json:"order_id"`
	ClientOid string `json:"client_oid"`
	Result    bool   `json:"result"`
	Code      string `json:"code"`
	Message   string `json:"message"`
}

type TickerPrice

type TickerPrice []struct {
	BestAsk        string    `json:"best_ask"`
	BestBid        string    `json:"best_bid"`
	InstrumentID   string    `json:"instrument_id"`
	ProductID      string    `json:"product_id"`
	Last           string    `json:"last"`
	LastQty        string    `json:"last_qty"`
	Ask            string    `json:"ask"`
	BestAskSize    string    `json:"best_ask_size"`
	Bid            string    `json:"bid"`
	BestBidSize    string    `json:"best_bid_size"`
	Open24H        string    `json:"open_24h"`
	High24H        string    `json:"high_24h"`
	Low24H         string    `json:"low_24h"`
	BaseVolume24H  string    `json:"base_volume_24h"`
	Timestamp      time.Time `json:"timestamp"`
	QuoteVolume24H string    `json:"quote_volume_24h"`
}

type TradeHistory

type TradeHistory []struct {
	Time      time.Time `json:"time"`
	Timestamp time.Time `json:"timestamp"`
	TradeID   string    `json:"trade_id"`
	Price     string    `json:"price"`
	Size      string    `json:"size"`
	Side      string    `json:"side"`
}

type Transfer

type Transfer struct {
	TransferID string `json:"transfer_id"`
	Currency   string `json:"currency"`
	From       string `json:"from"`
	Amount     string `json:"amount"`
	To         string `json:"to"`
	Result     bool   `json:"result"`
}

type TransferHistory

type TransferHistory []struct {
	Amount    string    `json:"amount"`
	Balance   string    `json:"balance"`
	Currency  string    `json:"currency"`
	Fee       string    `json:"fee"`
	LedgerID  string    `json:"ledger_id"`
	Timestamp time.Time `json:"timestamp"`
	Typename  string    `json:"typename"`
}

type WSOrderBook

type WSOrderBook struct {
	Table  string `json:"table"`
	Action string `json:"action"`
	Data   []struct {
		InstrumentID string     `json:"instrument_id"`
		Asks         [][]string `json:"asks"`
		Bids         [][]string `json:"bids"`
		Timestamp    time.Time  `json:"timestamp"`
		Checksum     int        `json:"checksum"`
	} `json:"data"`
}

type WithdrawFee

type WithdrawFee []struct {
	Currency string `json:"currency"`
	MaxFee   string `json:"max_fee"`
	MinFee   string `json:"min_fee"`
}

type WithdrawResponse

type WithdrawResponse struct {
	Result       bool   `json:"result"`
	Amount       string `json:"amount"`
	WithdrawalID string `json:"withdrawal_id"`
	Currency     string `json:"currency"`
	Code         string `json:"code"`
	Message      string `json:"message"`
}

Jump to

Keyboard shortcuts

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