anx

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

README

GoCryptoTrader package Anx

Build Status Software License GoDoc Coverage Status Go Report Card

This anx 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

ANX Exchange

Current Features
  • REST functions
Features not yet included
  • Long polling streaming
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 a exchange.IBotExchange

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

// Public calls - wrapper functions

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

// Fetches current orderbook information
ob, err := a.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 := a.GetExchangeAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

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

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

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

// GetUserInfo returns account info
accountInfo, err := a.GetUserInfo(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := a.Trade(...)
if err != nil {
  // Handle error
}
How to do LongPolling public/private calls
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
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 ANX

type ANX struct {
	exchange.Base
}

ANX is the overarching type across the alphapoint package

func (*ANX) CancelAllExchangeOrders

func (a *ANX) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*ANX) CancelExchangeOrder

func (a *ANX) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*ANX) CreateNewSubAccount

func (a *ANX) CreateNewSubAccount(currency, name string) (string, error)

CreateNewSubAccount generates a new sub account

func (*ANX) GetAPIKey

func (a *ANX) GetAPIKey(username, password, otp, deviceID string) (string, string, error)

GetAPIKey returns a new generated API key set.

func (*ANX) GetCurrencies

func (a *ANX) GetCurrencies() (CurrenciesStore, error)

GetCurrencies returns a list of supported currencies (both fiat and cryptocurrencies)

func (*ANX) GetDataToken

func (a *ANX) GetDataToken() (string, error)

GetDataToken returns token data

func (*ANX) GetDepositAddress

func (a *ANX) GetDepositAddress(currency, name string, new bool) (string, error)

GetDepositAddress returns a deposit address for a specific currency

func (*ANX) GetDepth

func (a *ANX) GetDepth(currency string) (Depth, error)

GetDepth returns current orderbook depth.

func (*ANX) GetExchangeAccountInfo

func (a *ANX) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the ANX exchange

func (*ANX) GetExchangeDepositAddress

func (a *ANX) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*ANX) GetExchangeFundTransferHistory

func (a *ANX) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*ANX) GetExchangeHistory

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

GetExchangeHistory returns historic trade data since exchange opening.

func (*ANX) GetExchangeOrderInfo

func (a *ANX) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*ANX) GetFee

func (a *ANX) GetFee(maker bool) float64

GetFee returns maker or taker fees

func (*ANX) GetOrderbookEx

func (a *ANX) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns the orderbook for a currency pair

func (*ANX) GetTicker

func (a *ANX) GetTicker(currency string) (Ticker, error)

GetTicker returns the current ticker

func (*ANX) GetTickerPrice

func (a *ANX) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*ANX) GetTradablePairs

func (a *ANX) GetTradablePairs() ([]string, error)

GetTradablePairs returns a list of available

func (*ANX) ModifyExchangeOrder

func (a *ANX) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

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

func (*ANX) NewOrder

func (a *ANX) NewOrder(orderType string, buy bool, tradedCurrency, tradedCurrencyAmount, settlementCurrency, settlementCurrencyAmount, limitPriceSettlement string,
	replace bool, replaceUUID string, replaceIfActive bool) error

NewOrder sends a new order request to the exchange.

func (*ANX) OrderInfo

func (a *ANX) OrderInfo(orderID string) (OrderResponse, error)

OrderInfo returns information about a specific order

func (*ANX) Run

func (a *ANX) Run()

Run implements the ANX wrapper

func (*ANX) Send

func (a *ANX) Send(currency, address, otp, amount string) (string, error)

Send withdraws a currency to an address

func (*ANX) SendAuthenticatedHTTPRequest

func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interface{}, result interface{}) error

SendAuthenticatedHTTPRequest sends a authenticated HTTP request

func (*ANX) SendHTTPRequest

func (a *ANX) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*ANX) SetDefaults

func (a *ANX) SetDefaults()

SetDefaults sets current default settings

func (*ANX) Setup

func (a *ANX) Setup(exch config.ExchangeConfig)

Setup is run on startup to setup exchange with config values

func (*ANX) Start

func (a *ANX) Start(wg *sync.WaitGroup)

Start starts the ANX go routine

func (*ANX) SubmitExchangeOrder

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

SubmitExchangeOrder submits a new order

func (*ANX) UpdateOrderbook

func (a *ANX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*ANX) UpdateTicker

func (a *ANX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*ANX) WithdrawCryptoExchangeFunds

func (a *ANX) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*ANX) WithdrawFiatExchangeFunds

func (a *ANX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*ANX) WithdrawFiatExchangeFundsToInternationalBank

func (a *ANX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type Currencies

type Currencies map[string]Currency

Currencies stores a list of currencies

type CurrenciesStaticResponse

type CurrenciesStaticResponse struct {
	CurrenciesResponse CurrenciesStore `json:"CurrencyStatic"`
}

CurrenciesStaticResponse stores the currencyStatic response

type CurrenciesStore

type CurrenciesStore struct {
	Currencies    Currencies    `json:"currencies"`
	CurrencyPairs CurrencyPairs `json:"currencyPairs"`
	Timestamp     string        `json:"timestamp"`
	ResultCode    string        `json:"resultCode"`
}

CurrenciesStore stores the available cryptocurrencies and fiat currencies

type Currency

type Currency struct {
	Decimals               int     `json:"decimals"`
	MinOrderSize           float64 `json:"minOrderSize"`
	MaxOrderSize           float64 `json:"maxOrderSize"`
	DisplayDenominator     float64 `json:"displayDenominator"`
	SummaryDecimals        int     `json:"summaryDecimals"`
	DisplayUnit            string  `json:"displayUnit"`
	Symbol                 string  `json:"symbol"`
	Type                   string  `json:"type"`
	ConfirmationThresholds []struct {
		ConfosRequired int `json:"confosRequired"`
	} `json:"confirmationThresholds"`
	NetworkFee     float64 `json:"networkFee"`
	EngineSettings struct {
		DepositsEnabled     bool `json:"depositsEnabled"`
		WithdrawalsEnabled  bool `json:"withdrawalsEnabled"`
		DisplayEnabled      bool `json:"displayEnabled"`
		MobileAccessEnabled bool `json:"mobileAccessEnabled"`
	} `json:"engineSettings"`
	MinOrderValue       float64 `json:"minOrderValue"`
	MaxOrderValue       float64 `json:"maxOrderValue"`
	MaxMarketOrderValue float64 `json:"maxMarketOrderValue"`
	MaxMarketOrderSize  float64 `json:"maxMarketOrderSize"`
	DigitalCurrencyType string  `json:"digitalCurrencyType"`
	AssetName           string  `json:"assetName"`
	AssetDivisibility   int     `json:"assetDivisibility"`
	AssetIcon           string  `json:"assetIcon"`
	AssetIssueQuantity  string  `json:"assetIssueQuantity"`
}

Currency holds the currency information

type CurrencyPair

type CurrencyPair struct {
	PriceDecimals  int `json:"priceDecimals"`
	EngineSettings struct {
		TradingEnabled bool `json:"tradingEnabled"`
		DisplayEnabled bool `json:"displayEnabled"`
		CancelOnly     bool `json:"cancelOnly"`
		VerifyRequired bool `json:"verifyRequired"`
		RestrictedBuy  bool `json:"restrictedBuy"`
		RestrictedSell bool `json:"restrictedSell"`
	} `json:"engineSettings"`
	MinOrderRate         float64 `json:"minOrderRate"`
	MaxOrderRate         float64 `json:"maxOrderRate"`
	DisplayPriceDecimals int     `json:"displayPriceDecimals"`
	TradedCcy            string  `json:"tradedCcy"`
	SettlementCcy        string  `json:"settlementCcy"`
	PreferredMarket      string  `json:"preferredMarket"`
	ChartEnabled         bool    `json:"chartEnabled"`
	SimpleTradeEnabled   bool    `json:"simpleTradeEnabled"`
}

CurrencyPair holds the currency information

type CurrencyPairs

type CurrencyPairs map[string]CurrencyPair

CurrencyPairs stores currency pair info

type Depth

type Depth struct {
	Result string `json:"result"`
	Data   struct {
		Now            string      `json:"now"`
		DataUpdateTime string      `json:"dataUpdateTime"`
		Asks           []DepthItem `json:"asks"`
		Bids           []DepthItem `json:"bids"`
	} `json:"data"`
}

Depth contains full depth information

type DepthItem

type DepthItem struct {
	Price     float64 `json:"price,string"`
	PriceInt  float64 `json:"price_int,string"`
	Amount    float64 `json:"amount,string"`
	AmountInt int64   `json:"amount_int,string"`
}

DepthItem contains depth information

type Order

type Order struct {
	OrderType                      string `json:"orderType"`
	BuyTradedCurrency              bool   `json:"buyTradedCurrency"`
	TradedCurrency                 string `json:"tradedCurrency"`
	SettlementCurrency             string `json:"settlementCurrency"`
	TradedCurrencyAmount           string `json:"tradedCurrencyAmount"`
	SettlementCurrencyAmount       string `json:"settlementCurrencyAmount"`
	LimitPriceInSettlementCurrency string `json:"limitPriceInSettlementCurrency"`
	ReplaceExistingOrderUUID       string `json:"replaceExistingOrderUuid"`
	ReplaceOnlyIfActive            bool   `json:"replaceOnlyIfActive"`
}

Order holds order information

type OrderResponse

type OrderResponse struct {
	BuyTradedCurrency              bool   `json:"buyTradedCurrency"`
	ExecutedAverageRate            string `json:"executedAverageRate"`
	LimitPriceInSettlementCurrency string `json:"limitPriceInSettlementCurrency"`
	OrderID                        string `json:"orderId"`
	OrderStatus                    string `json:"orderStatus"`
	OrderType                      string `json:"orderType"`
	ReplaceExistingOrderUUID       string `json:"replaceExistingOrderId"`
	SettlementCurrency             string `json:"settlementCurrency"`
	SettlementCurrencyAmount       string `json:"settlementCurrencyAmount"`
	SettlementCurrencyOutstanding  string `json:"settlementCurrencyOutstanding"`
	Timestamp                      int64  `json:"timestamp"`
	TradedCurrency                 string `json:"tradedCurrency"`
	TradedCurrencyAmount           string `json:"tradedCurrencyAmount"`
	TradedCurrencyOutstanding      string `json:"tradedCurrencyOutstanding"`
}

OrderResponse holds order response data

type Ticker

type Ticker struct {
	Result string `json:"result"`
	Data   struct {
		High       TickerComponent `json:"high"`
		Low        TickerComponent `json:"low"`
		Avg        TickerComponent `json:"avg"`
		Vwap       TickerComponent `json:"vwap"`
		Vol        TickerComponent `json:"vol"`
		Last       TickerComponent `json:"last"`
		Buy        TickerComponent `json:"buy"`
		Sell       TickerComponent `json:"sell"`
		Now        string          `json:"now"`
		UpdateTime string          `json:"dataUpdateTime"`
	} `json:"data"`
}

Ticker contains ticker data

type TickerComponent

type TickerComponent struct {
	Currency     string `json:"currency"`
	Display      string `json:"display"`
	DisplayShort string `json:"display_short"`
	Value        string `json:"value"`
}

TickerComponent is a sub-type for ticker

Jump to

Keyboard shortcuts

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