exmo

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 24 Imported by: 0

README

GoCryptoTrader package Exmo

Build Status Software License GoDoc Coverage Status Go Report Card

This exmo package is part of the GoCryptoTrader codebase.

This is still in active development

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

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

Exmo 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 e exchange.IBotExchange

for i := range bot.Exchanges {
  if bot.Exchanges[i].GetName() == "Exmo" {
    e = bot.Exchanges[i]
  }
}

// Public calls - wrapper functions

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

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

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

// Fetches current orderbook information
ob, err := e.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 := e.GetUserInfo(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := e.Trade(...)
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:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithdrawalFees = map[currency.Code]float64{
	currency.BTC:   0.0005,
	currency.LTC:   0.01,
	currency.DOGE:  1,
	currency.DASH:  0.01,
	currency.ETH:   0.01,
	currency.WAVES: 0.001,
	currency.ZEC:   0.001,
	currency.USDT:  5,
	currency.XMR:   0.05,
	currency.XRP:   0.02,
	currency.KICK:  50,
	currency.ETC:   0.01,
	currency.BCH:   0.001,
	currency.BTG:   0.001,
	currency.HBZ:   65,
	currency.BTCZ:  5,
	currency.DXT:   20,
	currency.STQ:   100,
	currency.XLM:   0.001,
	currency.OMG:   0.5,
	currency.TRX:   1,
	currency.ADA:   1,
	currency.INK:   50,
	currency.ZRX:   1,
	currency.GNT:   1,
}

WithdrawalFees the large list of predefined withdrawal fees Prone to change

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	Result bool   `json:"bool"`
	Error  string `json:"error"`
}

AuthResponse stores the auth response

type CancelledOrder

type CancelledOrder struct {
	Date     int64   `json:"date"`
	OrderID  int64   `json:"order_id,string"`
	Type     string  `json:"type"`
	Pair     string  `json:"pair"`
	Price    float64 `json:"price,string"`
	Quantity float64 `json:"quantity,string"`
	Amount   float64 `json:"amount,string"`
}

CancelledOrder stores cancelled order data

type EXMO

type EXMO struct {
	exchange.Base
}

EXMO exchange struct

func (*EXMO) CancelAllOrders

func (e *EXMO) CancelAllOrders(_ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*EXMO) CancelExistingOrder

func (e *EXMO) CancelExistingOrder(orderID int64) error

CancelExistingOrder cancels an order by the orderID

func (*EXMO) CancelOrder

func (e *EXMO) CancelOrder(order *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*EXMO) CreateOrder

func (e *EXMO) CreateOrder(pair, orderType string, price, amount float64) (int64, error)

CreateOrder creates an order Params: pair, quantity, price and type Type can be buy, sell, market_buy, market_sell, market_buy_total and market_sell_total

func (*EXMO) ExcodeCreate

func (e *EXMO) ExcodeCreate(currency string, amount float64) (ExcodeCreate, error)

ExcodeCreate creates an EXMO coupon

func (*EXMO) ExcodeLoad

func (e *EXMO) ExcodeLoad(excode string) (ExcodeLoad, error)

ExcodeLoad loads an EXMO coupon

func (*EXMO) FetchAccountInfo

func (e *EXMO) FetchAccountInfo() (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*EXMO) FetchOrderbook

func (e *EXMO) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns the orderbook for a currency pair

func (*EXMO) FetchTicker

func (e *EXMO) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*EXMO) FetchTradablePairs

func (e *EXMO) FetchTradablePairs(asset asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*EXMO) GetActiveOrders

func (e *EXMO) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*EXMO) GetCancelledOrders

func (e *EXMO) GetCancelledOrders(offset, limit string) ([]CancelledOrder, error)

GetCancelledOrders returns a list of cancelled orders

func (*EXMO) GetCryptoDepositAddress

func (e *EXMO) GetCryptoDepositAddress() (map[string]string, error)

GetCryptoDepositAddress returns a list of addresses for cryptocurrency deposits

func (*EXMO) GetCurrency

func (e *EXMO) GetCurrency() ([]string, error)

GetCurrency returns a list of currencies

func (*EXMO) GetDefaultConfig

func (e *EXMO) GetDefaultConfig() (*config.ExchangeConfig, error)

GetDefaultConfig returns a default exchange config

func (*EXMO) GetDepositAddress

func (e *EXMO) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*EXMO) GetExchangeHistory

func (e *EXMO) GetExchangeHistory(p currency.Pair, assetType asset.Item, timestampStart, timestampEnd time.Time) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data within the timeframe provided.

func (*EXMO) GetFee

func (e *EXMO) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*EXMO) GetFeeByType

func (e *EXMO) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*EXMO) GetFundingHistory

func (e *EXMO) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*EXMO) GetHistoricCandles

func (e *EXMO) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*EXMO) GetHistoricCandlesExtended

func (e *EXMO) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*EXMO) GetOpenOrders

func (e *EXMO) GetOpenOrders() (map[string]OpenOrders, error)

GetOpenOrders returns the users open orders

func (*EXMO) GetOrderHistory

func (e *EXMO) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*EXMO) GetOrderHistoryById

func (b *EXMO) GetOrderHistoryById(getOrdersRequest string) ([]order.Detail, error)

GetOrderHistoryById retrieves specified closed order information Can Limit response to specific order status

func (*EXMO) GetOrderInfo

func (e *EXMO) GetOrderInfo(orderID string) (order.Detail, error)

GetOrderInfo returns information on a current open order

func (*EXMO) GetOrderTrades

func (e *EXMO) GetOrderTrades(orderID int64) (OrderTrades, error)

GetOrderTrades returns a history of order trade details for the specific orderID

func (*EXMO) GetOrderbook

func (e *EXMO) GetOrderbook(symbol string) (map[string]Orderbook, error)

GetOrderbook returns the orderbook for a symbol or symbols

func (*EXMO) GetPairSettings

func (e *EXMO) GetPairSettings() (map[string]PairSettings, error)

GetPairSettings returns the pair settings for a symbol or symbols

func (*EXMO) GetRequiredAmount

func (e *EXMO) GetRequiredAmount(pair string, amount float64) (RequiredAmount, error)

GetRequiredAmount calculates the sum of buying a certain amount of currency for the particular currency pair

func (*EXMO) GetTicker

func (e *EXMO) GetTicker() (map[string]Ticker, error)

GetTicker returns the ticker for a symbol or symbols

func (*EXMO) GetTrades

func (e *EXMO) GetTrades(symbol string) (map[string][]Trades, error)

GetTrades returns the trades for a symbol or symbols

func (*EXMO) GetUserInfo

func (e *EXMO) GetUserInfo() (UserInfo, error)

GetUserInfo returns the user info

func (*EXMO) GetUserTrades

func (e *EXMO) GetUserTrades(pair, offset, limit string) (map[string][]UserTrades, error)

GetUserTrades returns the user trades

func (*EXMO) GetWalletHistory

func (e *EXMO) GetWalletHistory(date int64) (WalletHistory, error)

GetWalletHistory returns the users deposit/withdrawal history

func (*EXMO) GetWithdrawTXID

func (e *EXMO) GetWithdrawTXID(taskID int64) (string, error)

GetWithdrawTXID gets the result of a withdrawal request

func (*EXMO) ModifyOrder

func (e *EXMO) ModifyOrder(action *order.Modify) (string, error)

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

func (*EXMO) Run

func (e *EXMO) Run()

Run implements the EXMO wrapper

func (*EXMO) SendAuthenticatedHTTPRequest

func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Values, result interface{}) error

SendAuthenticatedHTTPRequest sends an authenticated HTTP request

func (*EXMO) SendHTTPRequest

func (e *EXMO) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*EXMO) SetDefaults

func (e *EXMO) SetDefaults()

SetDefaults sets the basic defaults for exmo

func (*EXMO) Setup

func (e *EXMO) Setup(exch *config.ExchangeConfig) error

Setup takes in the supplied exchange configuration details and sets params

func (*EXMO) Start

func (e *EXMO) Start(wg *sync.WaitGroup)

Start starts the EXMO go routine

func (*EXMO) SubmitOrder

func (e *EXMO) SubmitOrder(s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*EXMO) UpdateAccountInfo

func (e *EXMO) UpdateAccountInfo() (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the Exmo exchange

func (*EXMO) UpdateOrderbook

func (e *EXMO) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*EXMO) UpdateTicker

func (e *EXMO) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*EXMO) UpdateTradablePairs

func (e *EXMO) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*EXMO) ValidateCredentials

func (e *EXMO) ValidateCredentials() error

ValidateCredentials validates current credentials used for wrapper functionality

func (*EXMO) WithdrawCryptocurrency

func (e *EXMO) WithdrawCryptocurrency(currency, address, invoice string, amount float64) (int64, error)

WithdrawCryptocurrency withdraws a cryptocurrency from the exchange to the desired address NOTE: This API function is available only after request to their tech support team

func (*EXMO) WithdrawCryptocurrencyFunds

func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*EXMO) WithdrawFiatFunds

func (e *EXMO) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*EXMO) WithdrawFiatFundsToInternationalBank

func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type ExcodeCreate

type ExcodeCreate struct {
	TaskID   int64             `json:"task_id"`
	Code     string            `json:"code"`
	Amount   float64           `json:"amount,string"`
	Currency string            `json:"currency"`
	Balances map[string]string `json:"balances"`
}

ExcodeCreate stores the excode create coupon info

type ExcodeLoad

type ExcodeLoad struct {
	TaskID   int64             `json:"task_id"`
	Amount   float64           `json:"amount,string"`
	Currency string            `json:"currency"`
	Balances map[string]string `json:"balances"`
}

ExcodeLoad stores the excode load coupon info

type OpenOrders

type OpenOrders struct {
	OrderID  int64   `json:"order_id,string"`
	Created  int64   `json:"created,string"`
	Type     string  `json:"type"`
	Pair     string  `json:"pair"`
	Price    float64 `json:"price,string"`
	Quantity float64 `json:"quantity,string"`
	Amount   float64 `json:"amount,string"`
}

OpenOrders stores the order info

type OrderTrades

type OrderTrades struct {
	Type        string       `json:"type"`
	InCurrency  string       `json:"in_currency"`
	InAmount    float64      `json:"in_amount,string"`
	OutCurrency string       `json:"out_currency"`
	OutAmount   float64      `json:"out_amount,string"`
	Trades      []UserTrades `json:"trades"`
}

OrderTrades stores order trade information

type Orderbook

type Orderbook struct {
	AskQuantity float64    `json:"ask_quantity,string"`
	AskAmount   float64    `json:"ask_amount,string"`
	AskTop      float64    `json:"ask_top,string"`
	BidQuantity float64    `json:"bid_quantity,string"`
	BidTop      float64    `json:"bid_top,string"`
	Ask         [][]string `json:"ask"`
	Bid         [][]string `json:"bid"`
}

Orderbook holds the orderbook data

type PairSettings

type PairSettings struct {
	MinQuantity float64 `json:"min_quantity,string"`
	MaxQuantity float64 `json:"max_quantity,string"`
	MinPrice    float64 `json:"min_price,string"`
	MaxPrice    float64 `json:"max_price,string"`
	MaxAmount   float64 `json:"max_amount,string"`
	MinAmount   float64 `json:"min_amount,string"`
}

PairSettings holds the pair settings

type RequiredAmount

type RequiredAmount struct {
	Quantity float64 `json:"quantity,string"`
	Amount   float64 `json:"amount,string"`
	AvgPrice float64 `json:"avg_price,string"`
}

RequiredAmount stores the calculation for buying a certain amount of currency for a particular currency

type Ticker

type Ticker struct {
	Buy           float64 `json:"buy_price,string"`
	Sell          float64 `json:"sell_price,string"`
	Last          float64 `json:"last_trade,string"`
	High          float64 `json:"high,string"`
	Low           float64 `json:"low,string"`
	Average       float64 `json:"average,string"`
	Volume        float64 `json:"vol,string"`
	VolumeCurrent float64 `json:"vol_curr,string"`
	Updated       int64   `json:"updated"`
}

Ticker holds the ticker data

type Trades

type Trades struct {
	TradeID  int64   `json:"trade_id"`
	Type     string  `json:"string"`
	Quantity float64 `json:"quantity,string"`
	Price    float64 `json:"price,string"`
	Amount   float64 `json:"amount,string"`
	Date     int64   `json:"date"`
	Pair     string  `json:"pair"`
}

Trades holds trade data

type UserInfo

type UserInfo struct {
	AuthResponse
	UID        int               `json:"uid"`
	ServerDate int               `json:"server_date"`
	Balances   map[string]string `json:"balances"`
	Reserved   map[string]string `json:"reserved"`
}

UserInfo stores the user info

type UserTrades

type UserTrades struct {
	TradeID  int64   `json:"trade_id"`
	Date     int64   `json:"date"`
	Type     string  `json:"type"`
	Pair     string  `json:"pair"`
	OrderID  int64   `json:"order_id"`
	Quantity float64 `json:"quantity"`
	Price    float64 `json:"price"`
	Amount   float64 `json:"amount"`
}

UserTrades stores the users trade info

type WalletHistory

type WalletHistory struct {
	Begin   int64 `json:"begin,string"`
	End     int64 `json:"end,string"`
	History []struct {
		Timestamp int64   `json:"dt"`
		Type      string  `json:"string"`
		Currency  string  `json:"curr"`
		Status    string  `json:"status"`
		Provider  string  `json:"provider"`
		Amount    float64 `json:"amount,string"`
		Account   string  `json:"account,string"`
	}
}

WalletHistory stores the users wallet history

Jump to

Keyboard shortcuts

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