bcex

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: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 47
	DEFAULT_TAKER_FEE    = 0.002
	DEFAULT_MAKER_FEE    = 0.001
	DEFAULT_TXFEE        = 0.005
	DEFAULT_WITHDRAW     = true
	DEFAULT_DEPOSIT      = true
	DEFAULT_CONFIRMATION = 2
	DEFAULT_LISTED       = true
)
View Source
const (
	API_URL string = "http://api.bcex.top"
)

Variables

This section is empty.

Functions

func ComputeSHA1

func ComputeSHA1(mapParamsJson string, secretKey string) string

Types

type AccountBalances

type AccountBalances struct {
	Count int `json:"count"`
	Data  []struct {
		// UserID  interface{} `json:"user_id"`
		// OrgID   int         `json:"org_id"`
		Token string `json:"token"`
		// TokenAs string      `json:"token_as"`
		Usable string `json:"usable"`
		Locked string `json:"locked"`
		Total  string `json:"total"`
	} `json:"data"`
}

this exchange often return different type for the same field

type Bcex

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

	API_KEY    string
	API_SECRET string

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

func CreateBcex

func CreateBcex(config *exchange.Config) *Bcex

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

func (*Bcex) ApiKeyGET

func (e *Bcex) ApiKeyGET(strRequestPath string, mapParams map[string]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 (*Bcex) ApiKeyPost

func (e *Bcex) ApiKeyPost(strRequestPath string, mapParams map[string]interface{}) string

func (*Bcex) CanDeposit

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

func (*Bcex) CanWithdraw

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

func (*Bcex) CancelAllOrder

func (e *Bcex) CancelAllOrder() error

func (*Bcex) CancelOrder

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

func (*Bcex) DeleteCoin

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

func (*Bcex) DeletePair

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

func (*Bcex) DoAccountOperation

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

************** Private API **************

func (*Bcex) GetBalance

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

func (*Bcex) GetCoinBySymbol

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

func (*Bcex) GetCoinConstraint

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

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

func (*Bcex) GetCoinList

func (e *Bcex) GetCoinList() []string

func (*Bcex) GetCoins

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

func (*Bcex) GetCoinsData

func (e *Bcex) 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 (*Bcex) GetConfirmation

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

func (*Bcex) GetConstraintFetchMethod

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

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

func (*Bcex) GetFee

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

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

func (*Bcex) GetID

func (e *Bcex) GetID() int

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

func (*Bcex) GetLotSize

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

func (*Bcex) GetName

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

func (*Bcex) GetPairBySymbol

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

func (*Bcex) GetPairConstraint

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

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

func (*Bcex) GetPairs

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

func (*Bcex) GetPairsData

func (e *Bcex) 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) this require an API key

func (*Bcex) GetPriceFilter

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

func (*Bcex) GetSymbolByCoin

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

func (*Bcex) GetSymbolByPair

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

func (*Bcex) GetTradingWebURL

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

func (*Bcex) GetTxFee

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

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

func (*Bcex) HasPair

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

func (*Bcex) InitData

func (e *Bcex) InitData() error

func (*Bcex) LimitBuy

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

func (*Bcex) LimitSell

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

func (*Bcex) ListOrders

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

func (*Bcex) LoadPublicData

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

func (*Bcex) OrderBook

func (e *Bcex) 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 (*Bcex) OrderStatus

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

func (*Bcex) SetCoinConstraint

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

func (*Bcex) SetPairConstraint

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

func (*Bcex) UpdateAllBalances

func (e *Bcex) UpdateAllBalances()

func (*Bcex) UpdateConstraint

func (e *Bcex) UpdateConstraint()

func (*Bcex) Withdraw

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

type CoinsData

type CoinsData struct {
	CalcPrecision  int    `json:"calc_precision"`
	BizPrecision   int    `json:"biz_precision"`
	PhyPrecision   int    `json:"phy_precision"`
	OrderAmountMin string `json:"order_amount_min"`
	OrderAmountMax string `json:"order_amount_max"`
}

type JsonResponse

type JsonResponse struct {
	Code    int             `json:"code"`
	Message string          `json:"msg"`
	Data    json.RawMessage `json:"data"`
}

type OrderBook

type OrderBook struct {
	Bids [][]string `json:"bids"`
	Asks [][]string `json:"asks"`
}

type PairDetail

type PairDetail struct {
	ID            int         `json:"id"`
	Vol           interface{} `json:"vol"`
	Market        string      `json:"market"`
	MarketAs      string      `json:"market_as"`
	Token         string      `json:"token"`
	TokenAs       string      `json:"token_as"`
	Amount        interface{} `json:"amount"`
	MaxPrice      string      `json:"max_price"`
	MinPrice      string      `json:"min_price"`
	OpenPrice     string      `json:"open_price"`
	IsUp          string      `json:"is_up"`
	Last          string      `json:"last"`
	PrevPrice     string      `json:"prev_price"`
	PPrecision    string      `json:"p_precision"`
	NPrecision    string      `json:"n_precision"`
	LatestPrice   string      `json:"latest_price"`
	PercentChange string      `json:"percent_change"`
	Currency      struct {
		CNY string `json:"CNY"`
		KRW string `json:"KRW"`
	} `json:"currency"`
}

type PairsData

type PairsData struct {
	Main map[string][]*PairDetail `json:"main"`
}

type PlaceOrder

type PlaceOrder struct {
	ID            int    `json:"id"`
	Status        int    `json:"status"`
	OrderNo       string `json:"order_no"`
	Type          string `json:"type"`
	MarketType    string `json:"market_type"`
	AccountID     int    `json:"account_id"`
	OrgID         int    `json:"org_id"`
	UserID        int    `json:"user_id"`
	Market        string `json:"market"`
	Token         string `json:"token"`
	Price         string `json:"price"`
	Amount        string `json:"amount"`
	Volume        string `json:"volume"`
	MatchedAmount string `json:"matched_amount"`
	MatchedVolume string `json:"matched_volume"`
	AvgPrice      string `json:"avg_price"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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