exchange

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEPOSIT_WAITING_TIME  uint64 = 10 * 60 * 1000
	WITHDRAW_WAITING_TIME uint64 = 5 * 60 * 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

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 {
	Msg        string `json:"msg"`
	Address    string `json:"address"`
	Success    bool   `json:"success"`
	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) *Binance

func (*Binance) Address

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

func (*Binance) CancelOrder

func (self *Binance) CancelOrder(id common.ActivityID) error

func (*Binance) DepositStatus

func (self *Binance) DepositStatus(id common.ActivityID, timepoint uint64) (string, error)

func (*Binance) FetchEBalanceData

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

func (*Binance) FetchOrderData

func (self *Binance) FetchOrderData(timepoint uint64) (common.OrderEntry, error)

func (Binance) FetchPriceData

func (self Binance) FetchPriceData(timepoint uint64) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Binance) ID

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

func (*Binance) MarshalText

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

func (*Binance) Name

func (self *Binance) Name() string

func (*Binance) OrderStatus

func (self *Binance) OrderStatus(id common.ActivityID, timepoint uint64) (string, error)

func (*Binance) TokenPairs

func (self *Binance) TokenPairs() []common.TokenPair

func (*Binance) Trade

func (self *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) UpdateAllDepositAddresses

func (self *Binance) UpdateAllDepositAddresses(address string)

func (*Binance) UpdateDepositAddress

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

func (*Binance) Withdraw

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

func (*Binance) WithdrawStatus

func (self *Binance) WithdrawStatus(id common.ActivityID, timepoint uint64) (string, error)

type BinanceInterface

type BinanceInterface interface {
	FetchOnePairData(
		wg *sync.WaitGroup,
		pair common.TokenPair,
		data *sync.Map,
		timepoint uint64)

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

	GetInfo(timepoint uint64) (Binainfo, error)

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

	Trade(
		tradeType string,
		base, quote common.Token,
		rate, amount float64,
		timepoint uint64) (id string, done float64, remaining float64, finished bool, err 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, timepoint uint64) (Binaorder, error)
}

type Binaorder

type Binaorder struct {
	Code          int    `json:"code"`
	Message       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 Binaresp

type Binaresp struct {
	LastUpdatedId int64      `json:"lastUpdateId"`
	Code          int        `json:"code"`
	Msg           string     `json:"msg"`
	Bids          [][]string `json:"bids"`
	Asks          [][]string `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"`
	Message 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 Bitfinex

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

func NewBitfinex

func NewBitfinex(interf BitfinexInterface) *Bitfinex

func (*Bitfinex) Address

func (self *Bitfinex) Address(token common.Token) (ethereum.Address, bool)

func (*Bitfinex) FetchEBalanceData

func (self *Bitfinex) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*Bitfinex) FetchPriceData

func (self *Bitfinex) FetchPriceData(timepoint uint64) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Bitfinex) ID

func (self *Bitfinex) ID() common.ExchangeID

func (*Bitfinex) MarshalText

func (self *Bitfinex) MarshalText() (text []byte, err error)

func (*Bitfinex) Name

func (self *Bitfinex) Name() string

func (*Bitfinex) TokenPairs

func (self *Bitfinex) TokenPairs() []common.TokenPair

func (*Bitfinex) Trade

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

func (*Bitfinex) UpdateAllDepositAddresses

func (self *Bitfinex) UpdateAllDepositAddresses(address string)

func (*Bitfinex) UpdateDepositAddress

func (self *Bitfinex) UpdateDepositAddress(token common.Token, address string)

func (*Bitfinex) Withdraw

func (self *Bitfinex) Withdraw(token common.Token, amount *big.Int, address ethereum.Address, timepoint uint64) error

type BitfinexInterface

type BitfinexInterface interface {
	GetInfo(timepoint uint64) (Bitfinfo, error)

	FetchOnePairData(
		wg *sync.WaitGroup,
		pair common.TokenPair,
		data *sync.Map,
		timepoint uint64)

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

	Trade(
		tradeType string,
		base, quote common.Token,
		rate, amount float64,
		timepoint uint64) (done float64, remaining float64, finished bool, err error)
}

type Bitfinfo

type Bitfinfo struct {
	Success int `json:"success"`
	Return  map[string]map[string]float64
	Error   string `json:"error"`
}

type Bitfresp

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

type Bitftrade

type Bitftrade struct {
	Success int `json:"success"`
	Return  struct {
		Done      float64 `json:"received"`
		Remaining float64 `json:"remains"`
		OrderID   int64   `json:"order_id"`
	}
	Error string `json:"error"`
}

type Bitfwithdraw

type Bitfwithdraw struct {
	Success int `json:"success"`
	Return  map[string]interface{}
	Error   string `json:"error"`
}

type Bittinfo

type Bittinfo struct {
	Success int `json:"success"`
	Result  struct {
		Currency      string  `json:"Currency"`
		Balance       float64 `json:"Balance"`
		Available     float64 `json:"Available"`
		Pending       float64 `json:"Pending"`
		CryptoAddress string  `json:"CryptoAddress"`
		Requested     bool    `json:"Requested"`
		Uuid          string  `json:"uuid"`
	}
	Error string `json:"error"`
}

type Bittresp

type Bittresp struct {
	Success bool                            `json:"success"`
	Msg     string                          `json:"message"`
	Result  map[string][]map[string]float64 `json:"result"`
}

map of token pair to map of asks/bids to array of [rate, amount]

type Bittrex

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

func NewBittrex

func NewBittrex(interf BittrexInterface) *Bittrex

func (*Bittrex) Address

func (self *Bittrex) Address(token common.Token) (ethereum.Address, bool)

func (*Bittrex) FetchEBalanceData

func (self *Bittrex) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*Bittrex) FetchPriceData

func (self *Bittrex) FetchPriceData(timepoint uint64) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Bittrex) ID

func (self *Bittrex) ID() common.ExchangeID

func (*Bittrex) MarshalText

func (self *Bittrex) MarshalText() (text []byte, err error)

func (*Bittrex) Name

func (self *Bittrex) Name() string

func (*Bittrex) TokenPairs

func (self *Bittrex) TokenPairs() []common.TokenPair

func (*Bittrex) Trade

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

func (*Bittrex) UpdateAllDepositAddresses

func (self *Bittrex) UpdateAllDepositAddresses(address string)

func (*Bittrex) UpdateDepositAddress

func (self *Bittrex) UpdateDepositAddress(token common.Token, address string)

func (*Bittrex) Withdraw

func (self *Bittrex) Withdraw(token common.Token, amount *big.Int, address ethereum.Address, timepoint uint64) error

type BittrexInterface

type BittrexInterface interface {
	FetchOnePairData(wq *sync.WaitGroup, pair common.TokenPair, data *sync.Map, timepoint uint64)

	GetInfo(timepoint uint64) (Bittinfo, error)

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

	Trade(
		tradeType string,
		base, quote common.Token,
		rate, amount float64,
		timepoint uint64) (done float64, remaining float64, finished bool, err error)
}

type Bitttrade

type Bitttrade struct {
	Success int             `json:"success"`
	Return  Bitttraderesult `json:"result"`
	Error   string          `json:"message"`
}

type Bitttraderesult

type Bitttraderesult struct {
	Done      float64 `json:"received"`
	Remaining float64 `json:"remains"`
	OrderID   int64   `json:"uuid"`
}

type Bittwithdraw

type Bittwithdraw struct {
	Success int `json:"success"`
	Return  map[string]interface{}
	Error   string `json:"message"`
}

type Liqcancel

type Liqcancel struct {
	Success int `json:"success"`
	Return  struct {
		OrderID uint64             `json:"order_id"`
		Funds   map[string]float64 `json:"funds"`
	} `json:"return"`
	Error string `json:"error"`
}

type Liqinfo

type Liqinfo struct {
	Success int                           `json:"success"`
	Return  map[string]map[string]float64 `json:"return"`
	Error   string                        `json:"error"`
}

type Liqorderinfo

type Liqorderinfo struct {
	Success int `json:"success"`
	Return  map[string]struct {
		Pair        string  `json:"pair"`
		Type        string  `json:"type"`
		StartAmount float64 `json:"start_amount"`
		Amount      float64 `json:"amount"`
		Rate        float64 `json:"rate"`
		Timestamp   uint64  `json:"timestamp_created"`
		Status      int     `json:"status"`
	} `json:"return"`
	Error string `json:"error"`
}

type Liqorders

type Liqorders struct {
	Success int `json:"success"`
	Return  map[string]struct {
		Pair      string  `json:"pair"`
		Type      string  `json:"type"`
		Amount    float64 `json:"amount"`
		Rate      float64 `json:"rate"`
		Timestamp uint64  `json:"timestamp_created"`
	} `json:"return"`
	Error string `json:"error"`
}

type Liqresp

type Liqresp map[string]map[string][][]float64

map of token pair to map of asks/bids to array of [rate, amount]

type Liqtrade

type Liqtrade struct {
	Success int `json:"success"`
	Return  struct {
		Done      float64 `json:"received"`
		Remaining float64 `json:"remains"`
		OrderID   uint64  `json:"order_id"`
	} `json:"return"`
	Error string `json:"error"`
}

type Liqui

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

func NewLiqui

func NewLiqui(interf LiquiInterface) *Liqui

func (*Liqui) Address

func (self *Liqui) Address(token common.Token) (ethereum.Address, bool)

func (*Liqui) CancelOrder

func (self *Liqui) CancelOrder(id common.ActivityID) error

func (*Liqui) DepositStatus

func (self *Liqui) DepositStatus(id common.ActivityID, timepoint uint64) (string, error)

func (*Liqui) FetchEBalanceData

func (self *Liqui) FetchEBalanceData(timepoint uint64) (common.EBalanceEntry, error)

func (*Liqui) FetchOrderData

func (self *Liqui) FetchOrderData(timepoint uint64) (common.OrderEntry, error)

func (*Liqui) FetchPriceData

func (self *Liqui) FetchPriceData(timepoint uint64) (map[common.TokenPairID]common.ExchangePrice, error)

func (*Liqui) ID

func (self *Liqui) ID() common.ExchangeID

func (*Liqui) MarshalText

func (self *Liqui) MarshalText() (text []byte, err error)

func (*Liqui) Name

func (self *Liqui) Name() string

func (*Liqui) OrderStatus

func (self *Liqui) OrderStatus(id common.ActivityID, timepoint uint64) (string, error)

func (*Liqui) TokenPairs

func (self *Liqui) TokenPairs() []common.TokenPair

func (*Liqui) Trade

func (self *Liqui) 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 (*Liqui) UpdateAllDepositAddresses

func (self *Liqui) UpdateAllDepositAddresses(address string)

func (*Liqui) UpdateDepositAddress

func (self *Liqui) UpdateDepositAddress(token common.Token, address string)

func (*Liqui) Withdraw

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

func (*Liqui) WithdrawStatus

func (self *Liqui) WithdrawStatus(id common.ActivityID, timepoint uint64) (string, error)

type LiquiInterface

type LiquiInterface interface {
	Depth(tokens string, timepoint uint64) (Liqresp, error)

	GetInfo(timepoint uint64) (Liqinfo, error)

	ActiveOrders(timepoint uint64) (Liqorders, error)

	OrderInfo(orderID string, timepoint uint64) (Liqorderinfo, error)

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

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

	CancelOrder(id string) (Liqcancel, error)
}

type Liqwithdraw

type Liqwithdraw struct {
	Success int                    `json:"success"`
	Return  map[string]interface{} `json:"return"`
	Error   string                 `json:"error"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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