liqui

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 Liqui

Build Status Software License GoDoc Coverage Status Go Report Card

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

Liqui 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 l exchange.IBotExchange

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

// Public calls - wrapper functions

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

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

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

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

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

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"`
	Rights struct {
		Info     bool `json:"info"`
		Trade    bool `json:"trade"`
		Withdraw bool `json:"withdraw"`
	} `json:"rights"`
	ServerTime       float64 `json:"server_time"`
	TransactionCount int     `json:"transaction_count"`
	OpenOrders       int     `json:"open_orders"`
	Success          int     `json:"success"`
	Error            string  `json:"error"`
}

AccountInfo contains full account details information

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"`
	Success          int     `json:"success"`
	Error            string  `json:"error"`
}

ActiveOrders holds active order information

type CancelOrder

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

CancelOrder holds cancelled order information

type Info

type Info struct {
	ServerTime int64               `json:"server_time"`
	Pairs      map[string]PairData `json:"pairs"`
	Success    int                 `json:"success"`
	Error      string              `json:"error"`
}

Info holds the current pair information as well as server time

type Liqui

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

Liqui is the overarching type across the liqui package

func (*Liqui) CancelAllExchangeOrders

func (l *Liqui) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*Liqui) CancelExchangeOrder

func (l *Liqui) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*Liqui) CancelOrder

func (l *Liqui) CancelOrder(OrderID int64) (bool, error)

CancelOrder method is used for order cancelation.

func (*Liqui) GetAccountInfo

func (l *Liqui) GetAccountInfo() (AccountInfo, error)

GetAccountInfo returns information about the user’s current balance, API-key privileges, the number of open orders and Server Time. To use this method you need a privilege of the key info.

func (*Liqui) GetActiveOrders

func (l *Liqui) GetActiveOrders(pair string) (map[string]ActiveOrders, error)

GetActiveOrders returns the list of your active orders.

func (*Liqui) GetAvailablePairs

func (l *Liqui) GetAvailablePairs(nonHidden bool) []string

GetAvailablePairs returns all available pairs

func (*Liqui) GetDepth

func (l *Liqui) GetDepth(currencyPair string) (Orderbook, error)

GetDepth information about active orders on the pair. Additionally it accepts an optional GET-parameter limit, which indicates how many orders should be displayed (150 by default). Is set to less than 2000.

func (*Liqui) GetExchangeAccountInfo

func (l *Liqui) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the Liqui exchange

func (*Liqui) GetExchangeDepositAddress

func (l *Liqui) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*Liqui) GetExchangeFundTransferHistory

func (l *Liqui) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*Liqui) GetExchangeHistory

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

GetExchangeHistory returns historic trade data since exchange opening.

func (*Liqui) GetExchangeOrderInfo

func (l *Liqui) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*Liqui) GetFee

func (l *Liqui) GetFee(currency string) (float64, error)

GetFee returns a fee for a specific currency

func (*Liqui) GetInfo

func (l *Liqui) GetInfo() (Info, error)

GetInfo provides all the information about currently active pairs, such as the maximum number of digits after the decimal point, the minimum price, the maximum price, the minimum transaction size, whether the pair is hidden, the commission for each pair.

func (*Liqui) GetOrderInfo

func (l *Liqui) GetOrderInfo(OrderID int64) (map[string]OrderInfo, error)

GetOrderInfo returns the information on particular order.

func (*Liqui) GetOrderbookEx

func (l *Liqui) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*Liqui) GetTicker

func (l *Liqui) GetTicker(currencyPair string) (map[string]Ticker, error)

GetTicker returns information about currently active pairs, such as: the maximum price, the minimum price, average price, trade volume, trade volume in currency, the last trade, Buy and Sell price. All information is provided over the past 24 hours.

currencyPair - example "eth_btc"

func (*Liqui) GetTickerPrice

func (l *Liqui) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Liqui) GetTradeHistory

func (l *Liqui) GetTradeHistory(vals url.Values, pair string) (map[string]TradeHistory, error)

GetTradeHistory returns trade history

func (*Liqui) GetTrades

func (l *Liqui) GetTrades(currencyPair string) ([]Trades, error)

GetTrades returns information about the last trades. Additionally it accepts an optional GET-parameter limit, which indicates how many orders should be displayed (150 by default). The maximum allowable value is 2000.

func (*Liqui) ModifyExchangeOrder

func (l *Liqui) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

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

func (*Liqui) Run

func (l *Liqui) Run()

Run implements the Liqui wrapper

func (*Liqui) SendAuthenticatedHTTPRequest

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

SendAuthenticatedHTTPRequest sends an authenticated http request to liqui

func (*Liqui) SendHTTPRequest

func (l *Liqui) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Liqui) SetDefaults

func (l *Liqui) SetDefaults()

SetDefaults sets current default values for liqui

func (*Liqui) Setup

func (l *Liqui) Setup(exch config.ExchangeConfig)

Setup sets exchange configuration parameters for liqui

func (*Liqui) Start

func (l *Liqui) Start(wg *sync.WaitGroup)

Start starts the Liqui go routine

func (*Liqui) SubmitExchangeOrder

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

SubmitExchangeOrder submits a new order

func (*Liqui) Trade

func (l *Liqui) Trade(pair, orderType string, amount, price float64) (float64, error)

Trade creates orders on the exchange. to-do: convert orderid to int64

func (*Liqui) UpdateOrderbook

func (l *Liqui) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Liqui) UpdateTicker

func (l *Liqui) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Liqui) WithdrawCoins

func (l *Liqui) WithdrawCoins(coin string, amount float64, address string) (WithdrawCoins, error)

WithdrawCoins is designed for cryptocurrency withdrawals. API mentions that this isn't active now, but will be soon - you must provide the first 8 characters of the key in your ticket to support.

func (*Liqui) WithdrawCryptoExchangeFunds

func (l *Liqui) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Liqui) WithdrawFiatExchangeFunds

func (l *Liqui) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Liqui) WithdrawFiatExchangeFundsToInternationalBank

func (l *Liqui) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

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"`
	Success          int     `json:"success"`
	Error            string  `json:"error"`
}

OrderInfo holds specific order information

type Orderbook

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

Orderbook references both ask and bid sides

type PairData

type PairData 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"`
}

PairData is a sub-type for Info

type Response

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

Response is a generalized return type

type Ticker

type Ticker struct {
	High           float64
	Low            float64
	Avg            float64
	Vol            float64
	VolumeCurrency float64
	Last           float64
	Buy            float64
	Sell           float64
	Updated        int64
}

Ticker contains 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"`
	Success  int                `json:"success"`
	Error    string             `json:"error"`
}

Trade holds trading 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"`
	Success   int     `json:"success"`
	Error     string  `json:"error"`
}

TradeHistory contains trade history data

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 contains trade information

type WithdrawCoins

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

WithdrawCoins shows the amount of coins withdrawn from liqui not yet available

Jump to

Keyboard shortcuts

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