exchange

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	//BtcID is the string ID used for bitcoin
	BtcID = "BTC"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaAccountTradeHistory added in v0.1.1

type BinaAccountTradeHistory []struct {
	Symbol          string `json:"symbol"`
	ID              uint64 `json:"id"`
	OrderID         uint64 `json:"orderId"`
	Price           string `json:"price"`
	Qty             string `json:"qty"`
	QuoteQty        string `json:"quoteQty"`
	Commission      string `json:"commission"`
	CommissionAsset string `json:"commissionAsset"`
	Time            uint64 `json:"time"`
	IsBuyer         bool   `json:"isBuyer"`
	IsMaker         bool   `json:"isMaker"`
	IsBestMatch     bool   `json:"isBestMatch"`
}

BinaAccountTradeHistory object for a trade

type BinaServerTime added in v0.1.1

type BinaServerTime struct {
	ServerTime uint64 `json:"serverTime"`
}

type Binacancel

type Binacancel struct {
	Code              int    `json:"code"`
	Msg               string `json:"msg"`
	Symbol            string `json:"symbol"`
	OrigClientOrderID string `json:"origClientOrderId"`
	OrderID           uint64 `json:"orderId"`
	ClientOrderID     string `json:"clientOrderId"`
}

type Binadeposit

type Binadeposit struct {
	InsertTime uint64  `json:"insertTime"`
	Amount     float64 `json:"amount"`
	Asset      string  `json:"asset"`
	Address    string  `json:"address"`
	TxID       string  `json:"txId"`
	Status     int     `json:"status"`
}

type Binadepositaddress

type Binadepositaddress struct {
	Success    bool   `json:"success"`
	Msg        string `json:"msg"`
	Address    string `json:"address"`
	AddressTag string `json:"addressTag"`
	Asset      string `json:"asset"`
}

type Binadeposits

type Binadeposits struct {
	Success  bool          `json:"success"`
	Msg      string        `json:"msg"`
	Deposits []Binadeposit `json:"depositList"`
}
{
	"depositList": [
		{
			"insertTime": 1508198532000,
			"amount": 0.04670582,
			"asset": "ETH",
			"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
			"txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
			"status": 1
		},
		{
			"insertTime": 1508298532000,
			"amount": 1000,
			"asset": "XMR",
			"address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",
			"addressTag": "342341222",
			"txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",
			"status": 1
		}
	],
	"success": true
}

type Binainfo

type Binainfo struct {
	Code             int    `json:"code"`
	Msg              string `json:"msg"`
	MakerCommission  int64  `json:"makerCommission"`
	TakerCommission  int64  `json:"takerCommission"`
	BuyerCommission  int64  `json:"buyerCommission"`
	SellerCommission int64  `json:"sellerCommission"`
	CanTrade         bool   `json:"canTrade"`
	CanWithdraw      bool   `json:"canWithdraw"`
	CanDeposit       bool   `json:"canDeposit"`
	Balances         []struct {
		Asset  string `json:"asset"`
		Free   string `json:"free"`
		Locked string `json:"locked"`
	} `json:"balances"`
}

type Binance

type Binance struct {
	// contains filtered or unexported fields
}

func NewBinance

func NewBinance(
	interf BinanceInterface,
	storage BinanceStorage,
	setting Setting) (*Binance, error)

func (*Binance) Address

func (bn *Binance) Address(token common.Token) (ethereum.Address, bool)

Address returns the deposit address of a token on Binance. It will prioritize the live adress from Binance over the current address in storage

func (*Binance) CancelOrder

func (bn *Binance) CancelOrder(id string, base, quote string) error

func (*Binance) DepositStatus

func (bn *Binance) DepositStatus(id common.ActivityID, txHash, currency string, amount float64, timepoint uint64) (string, error)

func (*Binance) FetchEBalanceData

func (bn *Binance) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*Binance) FetchOnePairData added in v0.1.1

func (bn *Binance) FetchOnePairData(
	wg *sync.WaitGroup,
	baseID, quoteID string,
	data *sync.Map,
	timepoint uint64)

func (*Binance) FetchOnePairTradeHistory added in v0.1.1

func (bn *Binance) FetchOnePairTradeHistory(
	wait *sync.WaitGroup,
	data *sync.Map,
	pair common.TokenPair)

FetchOnePairTradeHistory fetch trade history for one pair from exchange

func (*Binance) FetchPriceData

func (bn *Binance) FetchPriceData(timepoint uint64, fetchBTCPrice bool) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Binance) FetchTradeHistory added in v0.1.1

func (bn *Binance) FetchTradeHistory()

FetchTradeHistory get all trade history for all tokens in the exchange

func (*Binance) GetExchangeInfo added in v0.1.1

func (bn *Binance) GetExchangeInfo(pair common.TokenPairID) (common.ExchangePrecisionLimit, error)

func (*Binance) GetFee added in v0.1.1

func (bn *Binance) GetFee() (common.ExchangeFees, error)

func (*Binance) GetInfo added in v0.1.1

func (bn *Binance) GetInfo() (common.ExchangeInfo, error)

func (*Binance) GetLiveExchangeInfos added in v0.1.1

func (bn *Binance) GetLiveExchangeInfos(tokenPairIDs []common.TokenPairID) (common.ExchangeInfo, error)

GetLiveExchangeInfo queries the Exchange Endpoint for exchange precision and limit of a certain pair ID It return error if occurs.

func (*Binance) GetMinDeposit added in v0.1.1

func (bn *Binance) GetMinDeposit() (common.ExchangesMinDeposit, error)

func (*Binance) GetTradeHistory added in v0.1.1

func (bn *Binance) GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)

func (*Binance) ID

func (bn *Binance) ID() common.ExchangeID

ID must return the exact string or else simulation will fail

func (*Binance) MarshalText

func (bn *Binance) MarshalText() (text []byte, err error)

func (*Binance) Name

func (bn *Binance) Name() string

func (*Binance) OpenOrdersForOnePair added in v0.1.1

func (bn *Binance) OpenOrdersForOnePair(
	wg *sync.WaitGroup,
	pair common.TokenPair,
	data *sync.Map,
	timepoint uint64)

func (*Binance) OrderStatus

func (bn *Binance) OrderStatus(id string, base, quote string) (string, error)

func (*Binance) QueryOrder added in v0.1.1

func (bn *Binance) QueryOrder(symbol string, id uint64) (done float64, remaining float64, finished bool, err error)

func (*Binance) TokenAddresses added in v0.1.1

func (bn *Binance) TokenAddresses() (map[string]ethereum.Address, error)

func (*Binance) TokenPairs

func (bn *Binance) TokenPairs() ([]common.TokenPair, error)

func (*Binance) Trade

func (bn *Binance) Trade(tradeType string, base common.Token, quote common.Token, rate float64, amount float64, timepoint uint64) (id string, done float64, remaining float64, finished bool, err error)

func (*Binance) UpdateDepositAddress

func (bn *Binance) UpdateDepositAddress(token common.Token, address string) error

UpdateDepositAddress update deposit address from binance api

func (*Binance) UpdatePairsPrecision added in v0.1.1

func (bn *Binance) UpdatePairsPrecision() error

func (*Binance) Withdraw

func (bn *Binance) Withdraw(token common.Token, amount *big.Int, address ethereum.Address, timepoint uint64) (string, error)

func (*Binance) WithdrawStatus

func (bn *Binance) WithdrawStatus(id, currency string, amount float64, timepoint uint64) (string, string, error)

type BinanceExchangeInfo added in v0.1.1

type BinanceExchangeInfo struct {
	Symbols []BinanceSymbol
}

type BinanceInterface

type BinanceInterface interface {
	GetDepthOnePair(baseID, quoteID string) (Binaresp, error)

	OpenOrdersForOnePair(pair common.TokenPair) (Binaorders, error)

	GetInfo() (Binainfo, error)

	GetExchangeInfo() (BinanceExchangeInfo, error)

	GetDepositAddress(tokenID string) (Binadepositaddress, error)

	GetAccountTradeHistory(base, quote common.Token, fromID string) (BinaAccountTradeHistory, error)

	Withdraw(
		token common.Token,
		amount *big.Int,
		address ethereum.Address) (string, error)

	Trade(
		tradeType string,
		base, quote common.Token,
		rate, amount float64) (Binatrade, error)

	CancelOrder(symbol string, id uint64) (Binacancel, error)

	DepositHistory(startTime, endTime uint64) (Binadeposits, error)

	WithdrawHistory(startTime, endTime uint64) (Binawithdrawals, error)

	OrderStatus(symbol string, id uint64) (Binaorder, error)
}

BinanceInterface contains the methods to interact with Binance centralized exchange.

type BinanceStorage added in v0.1.1

type BinanceStorage interface {
	StoreTradeHistory(data common.ExchangeTradeHistory) error

	GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)
	GetLastIDTradeHistory(pair string) (string, error)
}

BinanceStorage is the interface that wraps all database operation of Binance exchange.

type BinanceSymbol added in v0.1.1

type BinanceSymbol struct {
	Symbol             string        `json:"symbol"`
	BaseAssetPrecision int           `json:"baseAssetPrecision"`
	QuotePrecision     int           `json:"quotePrecision"`
	Filters            []FilterLimit `json:"filters"`
}

type BinanceTradeHistory added in v0.1.1

type BinanceTradeHistory []struct {
	ID           uint64 `json:"id"`
	Price        string `json:"price"`
	Qty          string `json:"qty"`
	Time         uint64 `json:"time"`
	IsBuyerMaker bool   `json:"isBuyerMaker"`
	IsBestMatch  bool   `json:"isBestMatch"`
}

BinanceTradeHistory recent trade history

type Binaorder

type Binaorder struct {
	Code          int    `json:"code"`
	Msg           string `json:"msg"`
	Symbol        string `json:"symbol"`
	OrderID       uint64 `json:"orderId"`
	ClientOrderID string `json:"clientOrderId"`
	Price         string `json:"price"`
	OrigQty       string `json:"origQty"`
	ExecutedQty   string `json:"executedQty"`
	Status        string `json:"status"`
	TimeInForce   string `json:"timeInForce"`
	Type          string `json:"type"`
	Side          string `json:"side"`
	StopPrice     string `json:"stopPrice"`
	IcebergQty    string `json:"icebergQty"`
	Time          uint64 `json:"time"`
}

type Binaorders

type Binaorders []Binaorder

type Binaprice added in v0.1.1

type Binaprice struct {
	Quantity string
	Rate     string
}

func (*Binaprice) UnmarshalJSON added in v0.1.1

func (bp *Binaprice) UnmarshalJSON(text []byte) error

type Binaresp

type Binaresp struct {
	LastUpdatedID int64       `json:"lastUpdateId"`
	Code          int         `json:"code"`
	Msg           string      `json:"msg"`
	Bids          []Binaprice `json:"bids"`
	Asks          []Binaprice `json:"asks"`
}

type Binatrade

type Binatrade struct {
	Symbol        string `json:"symbol"`
	OrderID       uint64 `json:"orderId"`
	ClientOrderID string `json:"clientOrderId"`
	TransactTime  uint64 `json:"transactTime"`
}

type Binawithdraw

type Binawithdraw struct {
	Success bool   `json:"success"`
	Msg     string `json:"msg"`
	ID      string `json:"id"`
}

type Binawithdrawal

type Binawithdrawal struct {
	ID        string  `json:"id"`
	Amount    float64 `json:"amount"`
	Address   string  `json:"address"`
	Asset     string  `json:"asset"`
	TxID      string  `json:"txId"`
	ApplyTime uint64  `json:"applyTime"`
	Status    int     `json:"status"`
}

type Binawithdrawals

type Binawithdrawals struct {
	Success     bool             `json:"success"`
	Msg         string           `json:"msg"`
	Withdrawals []Binawithdrawal `json:"withdrawList"`
}
{
	"withdrawList": [
		{
			"id":"7213fea8e94b4a5593d507237e5a555b"
			"amount": 1,
			"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
			"asset": "ETH",
			"txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
			"applyTime": 1508198532000
			"status": 4
		},
		{
			"id":"7213fea8e94b4a5534ggsd237e5a555b"
			"amount": 1000,
			"address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",
			"addressTag": "342341222",
			"txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",
			"asset": "XMR",
			"applyTime": 1508198532000,
			"status": 4
		}
	],
	"success": true
}

type FilterLimit added in v0.1.1

type FilterLimit struct {
	FilterType  string `json:"filterType"`
	MinPrice    string `json:"minPrice"`
	MaxPrice    string `json:"maxPrice"`
	MinQuantity string `json:"minQty"`
	MaxQuantity string `json:"maxQty"`
	StepSize    string `json:"stepSize"`
	TickSize    string `json:"tickSize"`
	MinNotional string `json:"minNotional"`
}

type Huobi added in v0.1.1

type Huobi struct {
	// contains filtered or unexported fields
}

func NewHuobi added in v0.1.1

func NewHuobi(
	interf HuobiInterface,
	blockchain *blockchain.BaseBlockchain,
	signer blockchain.Signer,
	nonce blockchain.NonceCorpus,
	storage HuobiStorage,
	setting Setting) (*Huobi, error)

NewHuobi creates new Huobi exchange instance

func (*Huobi) Address added in v0.1.1

func (h *Huobi) Address(token common.Token) (ethereum.Address, bool)

Address return the deposit address of a token in Huobi exchange. Due to the logic of Huobi exchange, every token if supported will be deposited to an Intermediator address instead.

func (*Huobi) CancelOrder added in v0.1.1

func (h *Huobi) CancelOrder(id, base, quote string) error

func (*Huobi) DepositStatus added in v0.1.1

func (h *Huobi) DepositStatus(id common.ActivityID, tx1Hash, currency string, sentAmount float64, timepoint uint64) (string, error)

func (*Huobi) FetchEBalanceData added in v0.1.1

func (h *Huobi) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*Huobi) FetchOnePairData added in v0.1.1

func (h *Huobi) FetchOnePairData(
	wg *sync.WaitGroup,
	baseID, quoteID string,
	data *sync.Map,
	timepoint uint64)

func (*Huobi) FetchOnePairTradeHistory added in v0.1.1

func (h *Huobi) FetchOnePairTradeHistory(
	wait *sync.WaitGroup,
	data *sync.Map,
	pair common.TokenPair)

func (*Huobi) FetchOrderData added in v0.1.1

func (h *Huobi) FetchOrderData(timepoint uint64) (common.OrderEntry, error)

func (*Huobi) FetchPriceData added in v0.1.1

func (h *Huobi) FetchPriceData(timepoint uint64, fetchPriceData bool) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Huobi) FetchTradeHistory added in v0.1.1

func (h *Huobi) FetchTradeHistory()

FetchTradeHistory get all trade history for all pairs from huobi exchange

func (*Huobi) FindTx2 added in v0.1.1

func (h *Huobi) FindTx2(id common.ActivityID) (tx2 common.TXEntry, found bool)

FindTx2 : find Tx2 Record associates with activity ID, return

func (*Huobi) FindTx2InPending added in v0.1.1

func (h *Huobi) FindTx2InPending(id common.ActivityID) (common.TXEntry, bool)

func (*Huobi) GetExchangeInfo added in v0.1.1

func (h *Huobi) GetExchangeInfo(pair common.TokenPairID) (common.ExchangePrecisionLimit, error)

func (*Huobi) GetFee added in v0.1.1

func (h *Huobi) GetFee() (common.ExchangeFees, error)

func (*Huobi) GetInfo added in v0.1.1

func (h *Huobi) GetInfo() (common.ExchangeInfo, error)

func (*Huobi) GetLiveExchangeInfos added in v0.1.1

func (h *Huobi) GetLiveExchangeInfos(tokenPairIDs []common.TokenPairID) (common.ExchangeInfo, error)

GetLiveExchangeInfos querry the Exchange Endpoint for exchange precision and limit of a list of tokenPairIDs It return error if occurs.

func (*Huobi) GetMinDeposit added in v0.1.1

func (h *Huobi) GetMinDeposit() (common.ExchangesMinDeposit, error)

func (*Huobi) GetTradeHistory added in v0.1.1

func (h *Huobi) GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)

func (*Huobi) ID added in v0.1.1

func (h *Huobi) ID() common.ExchangeID

ID must return the exact string or else simulation will fail

func (*Huobi) MarshalText added in v0.1.1

func (h *Huobi) MarshalText() (text []byte, err error)

func (*Huobi) Name added in v0.1.1

func (h *Huobi) Name() string

func (*Huobi) OpenOrdersForOnePair added in v0.1.1

func (h *Huobi) OpenOrdersForOnePair(
	wg *sync.WaitGroup,
	pair common.TokenPair,
	data *sync.Map,
	timepoint uint64)

func (*Huobi) OrderStatus added in v0.1.1

func (h *Huobi) OrderStatus(id string, base, quote string) (string, error)

func (*Huobi) PendingIntermediateTxs added in v0.1.1

func (h *Huobi) PendingIntermediateTxs() (map[common.ActivityID]common.TXEntry, error)

func (*Huobi) QueryOrder added in v0.1.1

func (h *Huobi) QueryOrder(symbol string, id uint64) (done float64, remaining float64, finished bool, err error)

func (*Huobi) RealDepositAddress added in v0.1.1

func (h *Huobi) RealDepositAddress(tokenID string) (ethereum.Address, error)

RealDepositAddress return the actual Huobi deposit address of a token It should only be used to send 2nd transaction.

func (*Huobi) Send2ndTransaction added in v0.1.1

func (h *Huobi) Send2ndTransaction(amount float64, token common.Token, exchangeAddress ethereum.Address) (*types.Transaction, error)

func (*Huobi) TokenAddresses added in v0.1.1

func (h *Huobi) TokenAddresses() (map[string]ethereum.Address, error)

func (*Huobi) TokenPairs added in v0.1.1

func (h *Huobi) TokenPairs() ([]common.TokenPair, error)

func (*Huobi) Trade added in v0.1.1

func (h *Huobi) Trade(tradeType string, base common.Token, quote common.Token, rate float64, amount float64, timepoint uint64) (id string, done float64, remaining float64, finished bool, err error)

func (*Huobi) UpdateDepositAddress added in v0.1.1

func (h *Huobi) UpdateDepositAddress(token common.Token, address string) error

UpdateDepositAddress update the deposit address of a token in Huobi It will prioritize the live address over the input address

func (*Huobi) UpdatePairsPrecision added in v0.1.1

func (h *Huobi) UpdatePairsPrecision() error

func (*Huobi) Withdraw added in v0.1.1

func (h *Huobi) Withdraw(token common.Token, amount *big.Int, address ethereum.Address, timepoint uint64) (string, error)

Withdraw return withdraw id from huobi

func (*Huobi) WithdrawStatus added in v0.1.1

func (h *Huobi) WithdrawStatus(
	id, currency string, amount float64, timepoint uint64) (string, string, error)

WithdrawStatus return withdraw status from huobi

type HuobiAccounts added in v0.1.1

type HuobiAccounts struct {
	Status string `json:"status"`
	Data   []struct {
		ID     uint64 `json:"id"`
		Type   string `json:"type"`
		State  string `json:"state"`
		UserID uint64 `json:"user-id"`
	} `json:"data"`
	Reason string `json:"err-msg"`
}

HuobiAccounts get huobi account info

type HuobiBlockchain added in v0.1.1

type HuobiBlockchain interface {
	SendETHFromAccountToExchange(amount *big.Int, exchangeAddress ethereum.Address) (*types.Transaction, error)
	SendTokenFromAccountToExchange(amount *big.Int, exchangeAddress ethereum.Address, tokenAddress ethereum.Address) (*types.Transaction, error)
	TxStatus(hash ethereum.Hash) (string, uint64, error)
	GetIntermediatorAddr() ethereum.Address
}

HuobiBlockchain contains methods to interact with blockchain from Huobi address.

type HuobiCancel added in v0.1.1

type HuobiCancel struct {
	Status  string `json:"status"`
	OrderID string `json:"data"`
	Reason  string `json:"err-msg"`
}

HuobiCancel cancel order on huobi

type HuobiDeposit added in v0.1.1

type HuobiDeposit struct {
	ID       uint64  `json:"id"`
	TxID     uint64  `json:"transaction-id"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
	State    string  `json:"state"`
	TxHash   string  `json:"tx-hash"`
	Address  string  `json:"address"`
}

HuobiDeposit deposit record on huobi

type HuobiDepositAddress added in v0.1.1

type HuobiDepositAddress struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    []struct {
		Currency   string `json:"currency"`
		Address    string `json:"address"`
		AddressTag string `json:"addressTag"`
		Chain      string `json:"chain"`
	} `json:"data"`
}

HuobiDepositAddress response from huobi

type HuobiDeposits added in v0.1.1

type HuobiDeposits struct {
	Status string         `json:"status"`
	Data   []HuobiDeposit `json:"data"`
	Reason string         `json:"err-msg"`
}

HuobiDeposits deposit on huobi

type HuobiDepth added in v0.1.1

type HuobiDepth struct {
	Status    string `json:"status"`
	Timestamp uint64 `json:"ts"`
	Tick      struct {
		Bids [][]float64 `json:"bids"`
		Asks [][]float64 `json:"asks"`
	} `json:"tick"`
	Reason string `json:"err-msg"`
}

HuobiDepth get its orderbook

type HuobiExchangeInfo added in v0.1.1

type HuobiExchangeInfo struct {
	Status string `json:"status"`
	Data   []struct {
		Base            string `json:"base-currency"`
		Quote           string `json:"quote-currency"`
		PricePrecision  int    `json:"price-precision"`
		AmountPrecision int    `json:"amount-precision"`
	} `json:"data"`
	Reason string `json:"err-msg"`
}

HuobiExchangeInfo exchange info on huobi

type HuobiInfo added in v0.1.1

type HuobiInfo struct {
	Status string `json:"status"`
	Data   struct {
		ID    uint64 `json:"id"`
		Type  string `json:"type"`
		State string `json:"state"`
		List  []struct {
			Currency string `json:"currency"`
			Type     string `json:"type"`
			Balance  string `json:"balance"`
		} `json:"list"`
	} `json:"data"`
	Reason string `json:"err-msg"`
}

HuobiInfo exchange info

type HuobiInterface added in v0.1.1

type HuobiInterface interface {
	GetDepthOnePair(baseID, quoteID string) (HuobiDepth, error)

	GetInfo() (HuobiInfo, error)

	GetExchangeInfo() (HuobiExchangeInfo, error)

	GetDepositAddress(token string) (HuobiDepositAddress, error)

	GetAccountTradeHistory(base, quote common.Token) (HuobiTradeHistory, error)

	Withdraw(
		token common.Token,
		amount *big.Int,
		address ethereum.Address) (string, error)

	Trade(
		tradeType string,
		base, quote common.Token,
		rate, amount float64,
		timepoint uint64) (HuobiTrade, error)

	CancelOrder(symbol string, id uint64) (HuobiCancel, error)

	DepositHistory(tokens []common.Token) (HuobiDeposits, error)

	WithdrawHistory(token []common.Token) (HuobiWithdraws, error)

	OrderStatus(symbol string, id uint64) (HuobiOrder, error)
}

HuobiInterface contains the methods to interact with Huobi centralized exchange.

type HuobiOrder added in v0.1.1

type HuobiOrder struct {
	Status string `json:"status"`
	Data   struct {
		OrderID     uint64 `json:"id"`
		Symbol      string `json:"symbol"`
		AccountID   uint64 `json:"account-id"`
		OrigQty     string `json:"amount"`
		Price       string `json:"price"`
		Type        string `json:"type"`
		State       string `json:"state"`
		ExecutedQty string `json:"field-amount"`
	} `json:"data"`
	Reason string `json:"err-msg"`
}

HuobiOrder orderon huobi

type HuobiStorage added in v0.1.1

type HuobiStorage interface {
	StoreIntermediateTx(id common.ActivityID, data common.TXEntry) error
	StorePendingIntermediateTx(id common.ActivityID, data common.TXEntry) error

	// get intermediate tx corresponding to the id. It can be done, failed or pending
	GetIntermedatorTx(id common.ActivityID) (common.TXEntry, error)
	GetPendingIntermediateTXs() (map[common.ActivityID]common.TXEntry, error)

	StoreTradeHistory(data common.ExchangeTradeHistory) error

	GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)
}

HuobiStorage is the interface that wraps all database operation of Huobi exchange.

type HuobiTrade added in v0.1.1

type HuobiTrade struct {
	Status  string `json:"status"`
	OrderID string `json:"data"`
	Reason  string `json:"err-msg"`
}

HuobiTrade trade on huobi

type HuobiTradeHistory added in v0.1.1

type HuobiTradeHistory struct {
	Status string `json:"status"`
	Data   []struct {
		ID         uint64 `json:"id"`
		Symbol     string `json:"symbol"`
		Amount     string `json:"amount"`
		Price      string `json:"price"`
		Timestamp  uint64 `json:"created-at"`
		Type       string `json:"type"`
		FinishedAt uint64 `json:"finished-at"`
	} `json:"data"`
}

HuobiTradeHistory trade history record on huobi

type HuobiWithdraw added in v0.1.1

type HuobiWithdraw struct {
	Status  string `json:"status"`
	ErrCode string `json:"err-code"`
	Reason  string `json:"err-msg"`
	ID      uint64 `json:"data"`
}

HuobiWithdraw withdraw result from huobi

type HuobiWithdrawHistory added in v0.1.1

type HuobiWithdrawHistory struct {
	ID       uint64  `json:"id"`
	TxID     uint64  `json:"transaction-id"`
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount"`
	State    string  `json:"state"`
	TxHash   string  `json:"tx-hash"`
	Address  string  `json:"address"`
}

HuobiWithdrawHistory from huobi

type HuobiWithdraws added in v0.1.1

type HuobiWithdraws struct {
	Status string                 `json:"status"`
	Data   []HuobiWithdrawHistory `json:"data"`
	Reason string                 `json:"err-msg"`
}

HuobiWithdraws record

type Setting added in v0.1.1

type Setting interface {
	GetInternalTokenByID(tokenID string) (common.Token, error)
	GetAllTokens() ([]common.Token, error)
	GetTokenByID(tokenID string) (common.Token, error)
	GetFee(ex settings.ExchangeName) (common.ExchangeFees, error)
	GetMinDeposit(ex settings.ExchangeName) (common.ExchangesMinDeposit, error)
	GetDepositAddresses(ex settings.ExchangeName) (common.ExchangeAddresses, error)
	UpdateDepositAddress(name settings.ExchangeName, addrs common.ExchangeAddresses, timestamp uint64) error
	GetExchangeInfo(ex settings.ExchangeName) (common.ExchangeInfo, error)
	UpdateExchangeInfo(ex settings.ExchangeName, exInfo common.ExchangeInfo, timestamp uint64) error
	ETHToken() common.Token
}

type StableEx added in v0.1.1

type StableEx struct {
	// contains filtered or unexported fields
}

func NewStableEx added in v0.1.1

func NewStableEx(setting Setting) (*StableEx, error)

func (*StableEx) Address added in v0.1.1

func (se *StableEx) Address(token common.Token) (ethereum.Address, bool)

func (*StableEx) CancelOrder added in v0.1.1

func (se *StableEx) CancelOrder(id, base, quote string) error

func (*StableEx) DepositStatus added in v0.1.1

func (se *StableEx) DepositStatus(id common.ActivityID, txHash, currency string, amount float64, timepoint uint64) (string, error)

func (*StableEx) FetchEBalanceData added in v0.1.1

func (se *StableEx) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*StableEx) FetchPriceData added in v0.1.1

func (se *StableEx) FetchPriceData(timepoint uint64, fetchBTCPrice bool) (map[common.TokenPairID]common.ExchangePrice, error)

func (*StableEx) FetchTradeHistory added in v0.1.1

func (se *StableEx) FetchTradeHistory(timepoint uint64) (map[common.TokenPairID][]common.TradeHistory, error)

func (*StableEx) GetExchangeInfo added in v0.1.1

func (se *StableEx) GetExchangeInfo(pair common.TokenPairID) (common.ExchangePrecisionLimit, error)

func (*StableEx) GetFee added in v0.1.1

func (se *StableEx) GetFee() (common.ExchangeFees, error)

func (*StableEx) GetInfo added in v0.1.1

func (se *StableEx) GetInfo() (common.ExchangeInfo, error)

func (*StableEx) GetLiveExchangeInfos added in v0.1.1

func (se *StableEx) GetLiveExchangeInfos(tokenPairIDs []common.TokenPairID) (common.ExchangeInfo, error)

func (*StableEx) GetMinDeposit added in v0.1.1

func (se *StableEx) GetMinDeposit() (common.ExchangesMinDeposit, error)

func (*StableEx) GetTradeHistory added in v0.1.1

func (se *StableEx) GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)

func (*StableEx) ID added in v0.1.1

func (se *StableEx) ID() common.ExchangeID

ID must return the exact string or else simulation will fail

func (*StableEx) MarshalText added in v0.1.1

func (se *StableEx) MarshalText() (text []byte, err error)

func (*StableEx) Name added in v0.1.1

func (se *StableEx) Name() string

func (*StableEx) OrderStatus added in v0.1.1

func (se *StableEx) OrderStatus(id string, base, quote string) (string, error)

func (*StableEx) QueryOrder added in v0.1.1

func (se *StableEx) QueryOrder(symbol string, id uint64) (done float64, remaining float64, finished bool, err error)

func (*StableEx) TokenAddresses added in v0.1.1

func (se *StableEx) TokenAddresses() (map[string]ethereum.Address, error)

func (*StableEx) TokenPairs added in v0.1.1

func (se *StableEx) TokenPairs() ([]common.TokenPair, error)

func (*StableEx) Trade added in v0.1.1

func (se *StableEx) Trade(tradeType string, base common.Token, quote common.Token, rate float64, amount float64, timepoint uint64) (id string, done float64, remaining float64, finished bool, err error)

func (*StableEx) UpdateDepositAddress added in v0.1.1

func (se *StableEx) UpdateDepositAddress(token common.Token, address string) error

func (*StableEx) Withdraw added in v0.1.1

func (se *StableEx) Withdraw(token common.Token, amount *big.Int, address ethereum.Address, timepoint uint64) (string, error)

func (*StableEx) WithdrawStatus added in v0.1.1

func (se *StableEx) WithdrawStatus(id, currency string, amount float64, timepoint uint64) (string, string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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