wex

package
v0.0.0-...-a2c5123 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 15 Imported by: 0

README

GoCryptoTrader package Wex

Build Status Software License GoDoc Coverage Status Go Report Card

This wex package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Wex Exchange

Current Features
  • REST Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var w exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "Wex" {
    y = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := w.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := w.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := w.GetExchangeAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := w.GetTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := w.GetDepth()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := w.GetAccountInfo()
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := w.Trade("BTCUSD", "MARKET", 1, 2)
if err != nil {
  // Handle error
}
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Funds      map[string]float64 `json:"funds"`
	OpenOrders int                `json:"open_orders"`
	Rights     struct {
		Info     int `json:"info"`
		Trade    int `json:"trade"`
		Withdraw int `json:"withdraw"`
	} `json:"rights"`
	ServerTime       float64 `json:"server_time"`
	TransactionCount int     `json:"transaction_count"`
	Error            string  `json:"error"`
}

AccountInfo stores the account information for a user

type ActiveOrders

type ActiveOrders struct {
	Pair             string  `json:"pair"`
	Type             string  `json:"sell"`
	Amount           float64 `json:"amount"`
	Rate             float64 `json:"rate"`
	TimestampCreated float64 `json:"time_created"`
	Status           int     `json:"status"`
}

ActiveOrders stores active order information

type CancelOrder

type CancelOrder struct {
	OrderID float64            `json:"order_id"`
	Funds   map[string]float64 `json:"funds"`
	Error   string             `json:"error"`
}

CancelOrder is used for the CancelOrder API request response

type CoinDepositAddress

type CoinDepositAddress struct {
	Address string `json:"address"`
	Error   string `json:"error"`
}

CoinDepositAddress stores a curency deposit address

type CreateCoupon

type CreateCoupon struct {
	Coupon  string             `json:"coupon"`
	TransID int64              `json:"transID"`
	Funds   map[string]float64 `json:"funds"`
	Error   string             `json:"error"`
}

CreateCoupon stores information coupon information

type Info

type Info struct {
	ServerTime int64           `json:"server_time"`
	Pairs      map[string]Pair `json:"pairs"`
}

Info holds server time and pair information

type OrderInfo

type OrderInfo struct {
	Pair             string  `json:"pair"`
	Type             string  `json:"sell"`
	StartAmount      float64 `json:"start_amount"`
	Amount           float64 `json:"amount"`
	Rate             float64 `json:"rate"`
	TimestampCreated float64 `json:"time_created"`
	Status           int     `json:"status"`
}

OrderInfo stores order information

type Orderbook

type Orderbook struct {
	Asks [][]float64 `json:"asks"`
	Bids [][]float64 `json:"bids"`
}

Orderbook stores the asks and bids orderbook information

type Pair

type Pair struct {
	DecimalPlaces int     `json:"decimal_places"`
	MinPrice      float64 `json:"min_price"`
	MaxPrice      float64 `json:"max_price"`
	MinAmount     float64 `json:"min_amount"`
	Hidden        int     `json:"hidden"`
	Fee           float64 `json:"fee"`
}

Pair holds pair information

type RedeemCoupon

type RedeemCoupon struct {
	CouponAmount   float64 `json:"couponAmount,string"`
	CouponCurrency string  `json:"couponCurrency"`
	TransID        int64   `json:"transID"`
	Error          string  `json:"error"`
}

RedeemCoupon stores redeem coupon information

type Response

type Response struct {
	Return  interface{} `json:"return"`
	Success int         `json:"success"`
	Error   string      `json:"error"`
}

Response is a generic struct used for exchange API request result

type Ticker

type Ticker struct {
	High          float64
	Low           float64
	Avg           float64
	Vol           float64
	VolumeCurrent float64 `json:"vol_cur"`
	Last          float64
	Buy           float64
	Sell          float64
	Updated       int64
}

Ticker stores the ticker information

type Trade

type Trade struct {
	Received float64            `json:"received"`
	Remains  float64            `json:"remains"`
	OrderID  float64            `json:"order_id"`
	Funds    map[string]float64 `json:"funds"`
	Error    string             `json:"error"`
}

Trade stores the trade information

type TradeHistory

type TradeHistory struct {
	Pair      string  `json:"pair"`
	Type      string  `json:"type"`
	Amount    float64 `json:"amount"`
	Rate      float64 `json:"rate"`
	OrderID   float64 `json:"order_id"`
	MyOrder   int     `json:"is_your_order"`
	Timestamp float64 `json:"timestamp"`
}

TradeHistory stores trade history

type Trades

type Trades struct {
	Type      string  `json:"type"`
	Price     float64 `json:"bid"`
	Amount    float64 `json:"amount"`
	TID       int64   `json:"tid"`
	Timestamp int64   `json:"timestamp"`
}

Trades stores trade information

type TransHistory

type TransHistory struct {
	Type        int     `json:"type"`
	Amount      float64 `json:"amount"`
	Currency    string  `json:"currency"`
	Description string  `json:"desc"`
	Status      int     `json:"status"`
	Timestamp   float64 `json:"timestamp"`
}

TransHistory stores transaction history

type WEX

type WEX struct {
	exchange.Base
	Ticker map[string]Ticker
}

WEX is the overarching type across the wex package

func (*WEX) CancelAllExchangeOrders

func (w *WEX) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*WEX) CancelExchangeOrder

func (w *WEX) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*WEX) CancelOrder

func (w *WEX) CancelOrder(OrderID int64) (bool, error)

CancelOrder cancels an order for a specific order ID

func (*WEX) CoinDepositAddress

func (w *WEX) CoinDepositAddress(coin string) (string, error)

CoinDepositAddress returns the deposit address for a specific currency

func (*WEX) CreateCoupon

func (w *WEX) CreateCoupon(currency string, amount float64) (CreateCoupon, error)

CreateCoupon creates an exchange coupon for a sepcific currency

func (*WEX) GetAccountInfo

func (w *WEX) GetAccountInfo() (AccountInfo, error)

GetAccountInfo returns a users account info

func (*WEX) GetActiveOrders

func (w *WEX) GetActiveOrders(pair string) (map[string]ActiveOrders, error)

GetActiveOrders returns the active orders for a specific currency

func (*WEX) GetDepth

func (w *WEX) GetDepth(symbol string) (Orderbook, error)

GetDepth returns the depth for a specific currency

func (*WEX) GetExchangeAccountInfo

func (w *WEX) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the WEX exchange

func (*WEX) GetExchangeDepositAddress

func (w *WEX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*WEX) GetExchangeFundTransferHistory

func (w *WEX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*WEX) GetExchangeHistory

func (w *WEX) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*WEX) GetExchangeOrderInfo

func (w *WEX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*WEX) GetFee

func (w *WEX) GetFee() float64

GetFee returns the exchange fee

func (*WEX) GetInfo

func (w *WEX) GetInfo() (Info, error)

GetInfo returns the WEX info

func (*WEX) GetOrderInfo

func (w *WEX) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error)

GetOrderInfo returns the order info for a specific order ID

func (*WEX) GetOrderbookEx

func (w *WEX) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns the orderbook for a currency pair

func (*WEX) GetTicker

func (w *WEX) GetTicker(symbol string) (map[string]Ticker, error)

GetTicker returns a ticker for a specific currency

func (*WEX) GetTickerPrice

func (w *WEX) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*WEX) GetTradablePairs

func (w *WEX) GetTradablePairs() ([]string, error)

GetTradablePairs returns a list of available pairs from the exchange

func (*WEX) GetTradeHistory

func (w *WEX) GetTradeHistory(TIDFrom, Count, TIDEnd int64, order, since, end, pair string) (map[string]TradeHistory, error)

GetTradeHistory returns the trade history

func (*WEX) GetTrades

func (w *WEX) GetTrades(symbol string) ([]Trades, error)

GetTrades returns the trades for a specific currency

func (*WEX) GetTransactionHistory

func (w *WEX) GetTransactionHistory(TIDFrom, Count, TIDEnd int64, order, since, end string) (map[string]TransHistory, error)

GetTransactionHistory returns the transaction history

func (*WEX) ModifyExchangeOrder

func (w *WEX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

ModifyExchangeOrder will allow of changing orderbook placement and limit to market conversion

func (*WEX) RedeemCoupon

func (w *WEX) RedeemCoupon(coupon string) (RedeemCoupon, error)

RedeemCoupon redeems an exchange coupon

func (*WEX) Run

func (w *WEX) Run()

Run implements the WEX wrapper

func (*WEX) SendAuthenticatedHTTPRequest

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

SendAuthenticatedHTTPRequest sends an authenticated HTTP request to WEX

func (*WEX) SendHTTPRequest

func (w *WEX) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*WEX) SetDefaults

func (w *WEX) SetDefaults()

SetDefaults sets current default value for WEX

func (*WEX) Setup

func (w *WEX) Setup(exch config.ExchangeConfig)

Setup sets exchange configuration parameters for WEX

func (*WEX) Start

func (w *WEX) Start(wg *sync.WaitGroup)

Start starts the WEX go routine

func (*WEX) SubmitExchangeOrder

func (w *WEX) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error)

SubmitExchangeOrder submits a new order

func (*WEX) Trade

func (w *WEX) Trade(pair, orderType string, amount, price float64) (int64, error)

Trade places an order and returns the order ID if successful or an error

func (*WEX) UpdateOrderbook

func (w *WEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*WEX) UpdateTicker

func (w *WEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*WEX) WithdrawCoins

func (w *WEX) WithdrawCoins(coin string, amount float64, address string) (WithdrawCoins, error)

WithdrawCoins withdraws coins for a specific coin

func (*WEX) WithdrawCryptoExchangeFunds

func (w *WEX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*WEX) WithdrawFiatExchangeFunds

func (w *WEX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*WEX) WithdrawFiatExchangeFundsToInternationalBank

func (w *WEX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type WithdrawCoins

type WithdrawCoins struct {
	TID        int64              `json:"tId"`
	AmountSent float64            `json:"amountSent"`
	Funds      map[string]float64 `json:"funds"`
	Error      string             `json:"error"`
}

WithdrawCoins stores information for a withdrawcoins request

Jump to

Keyboard shortcuts

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