btcmarkets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 34 Imported by: 0

README

GoCryptoTrader package Btcmarkets

Build Status Software License GoDoc Coverage Status Go Report Card

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

BTCMarkets Exchange

Current Features
  • REST Support
  • Websocket 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 b exchange.IBotExchange

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

// Public calls - wrapper functions

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

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

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

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

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

This section is empty.

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	AssetName string  `json:"assetName"`
	Balance   float64 `json:"balance,string"`
	Available float64 `json:"available,string"`
	Locked    float64 `json:"locked,string"`
}

AccountData stores account data

type AssetData

type AssetData struct {
	AssetName           string  `json:"assetName"`
	MinDepositAmount    float64 `json:"minDepositAmount,string"`
	MaxDepositAmount    float64 `json:"maxDepositAmount,string"`
	DepositDecimals     float64 `json:"depositDecimals,string"`
	MinWithdrawalAmount float64 `json:"minWithdrawalAmount,string"`
	MaxWithdrawalAmount float64 `json:"maxWithdrawalAmount,string"`
	WithdrawalDecimals  float64 `json:"withdrawalDecimals,string"`
	WithdrawalFee       float64 `json:"withdrawalFee,string"`
	DepositFee          float64 `json:"depositFee,string"`
}

AssetData stores data for given asset

type BTCMarkets

type BTCMarkets struct {
	exchange.Base
}

BTCMarkets is the overarching type across the BTCMarkets package

func (*BTCMarkets) BatchPlaceCancelOrders

func (b *BTCMarkets) BatchPlaceCancelOrders(ctx context.Context, cancelOrders []CancelBatch, placeOrders []PlaceBatch) (BatchPlaceCancelResponse, error)

BatchPlaceCancelOrders places and cancels batch orders

func (*BTCMarkets) CancelAllOpenOrdersByPairs

func (b *BTCMarkets) CancelAllOpenOrdersByPairs(ctx context.Context, marketIDs []string) ([]CancelOrderResp, error)

CancelAllOpenOrdersByPairs cancels all open orders unless pairs are specified

func (*BTCMarkets) CancelAllOrders

func (b *BTCMarkets) CancelAllOrders(ctx context.Context, _ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*BTCMarkets) CancelBatch

func (b *BTCMarkets) CancelBatch(ctx context.Context, ids []string) (BatchCancelResponse, error)

CancelBatch cancels given ids

func (*BTCMarkets) CancelBatchOrders

func (b *BTCMarkets) CancelBatchOrders(ctx context.Context, o []order.Cancel) (order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*BTCMarkets) CancelOrder

func (b *BTCMarkets) CancelOrder(ctx context.Context, o *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*BTCMarkets) CreateNewReport

func (b *BTCMarkets) CreateNewReport(ctx context.Context, reportType, format string) (CreateReportResp, error)

CreateNewReport creates a new report

func (*BTCMarkets) FetchAccountInfo

func (b *BTCMarkets) FetchAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*BTCMarkets) FetchDepositAddress

func (b *BTCMarkets) FetchDepositAddress(ctx context.Context, curr currency.Code, before, after, limit int64) (*DepositAddress, error)

FetchDepositAddress gets deposit address for the given asset

func (*BTCMarkets) FetchOrder

func (b *BTCMarkets) FetchOrder(ctx context.Context, id string) (OrderData, error)

FetchOrder finds order based on the provided id

func (*BTCMarkets) FetchOrderbook

func (b *BTCMarkets) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*BTCMarkets) FetchTicker

func (b *BTCMarkets) FetchTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*BTCMarkets) FetchTradablePairs

func (b *BTCMarkets) FetchTradablePairs(ctx context.Context, a asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*BTCMarkets) FormatExchangeKlineInterval

func (b *BTCMarkets) FormatExchangeKlineInterval(in kline.Interval) string

FormatExchangeKlineInterval returns Interval to exchange formatted string

func (*BTCMarkets) GetAccountBalance

func (b *BTCMarkets) GetAccountBalance(ctx context.Context) ([]AccountData, error)

GetAccountBalance returns the full account balance

func (*BTCMarkets) GetActiveOrders

func (b *BTCMarkets) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*BTCMarkets) GetBatchTrades

func (b *BTCMarkets) GetBatchTrades(ctx context.Context, ids []string) (BatchTradeResponse, error)

GetBatchTrades gets batch trades

func (*BTCMarkets) GetDefaultConfig

func (b *BTCMarkets) GetDefaultConfig() (*config.Exchange, error)

GetDefaultConfig returns a default exchange config

func (*BTCMarkets) GetDeposit

func (b *BTCMarkets) GetDeposit(ctx context.Context, id string) (TransferData, error)

GetDeposit gets deposit info for a given ID

func (*BTCMarkets) GetDepositAddress

func (b *BTCMarkets) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, accountID, _ string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*BTCMarkets) GetFee

func (b *BTCMarkets) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*BTCMarkets) GetFeeByType

func (b *BTCMarkets) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*BTCMarkets) GetFundingHistory

func (b *BTCMarkets) GetFundingHistory(ctx context.Context) ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*BTCMarkets) GetHistoricCandles

func (b *BTCMarkets) GetHistoricCandles(ctx context.Context, 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 (*BTCMarkets) GetHistoricCandlesExtended

func (b *BTCMarkets) GetHistoricCandlesExtended(ctx context.Context, p 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 (*BTCMarkets) GetHistoricTrades

func (b *BTCMarkets) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*BTCMarkets) GetKlines

func (b *BTCMarkets) GetKlines(arg interface{}) ([]*kline.Kline, error)

GetKlines checks and returns a requested kline if it exists

func (*BTCMarkets) GetMarketCandles

func (b *BTCMarkets) GetMarketCandles(ctx context.Context, marketID, timeWindow string, from, to time.Time, before, after, limit int64) (out CandleResponse, err error)

GetMarketCandles gets candles for specified currency pair

func (*BTCMarkets) GetMarkets

func (b *BTCMarkets) GetMarkets(ctx context.Context) ([]Market, error)

GetMarkets returns the BTCMarkets instruments

func (*BTCMarkets) GetMultipleOrderbooks

func (b *BTCMarkets) GetMultipleOrderbooks(ctx context.Context, marketIDs []string) ([]Orderbook, error)

GetMultipleOrderbooks gets orderbooks

func (*BTCMarkets) GetOrderHistory

func (b *BTCMarkets) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error)

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

func (*BTCMarkets) GetOrderInfo

func (b *BTCMarkets) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)

GetOrderInfo returns order information based on order ID

func (*BTCMarkets) GetOrderbook

func (b *BTCMarkets) GetOrderbook(ctx context.Context, marketID string, level int64) (Orderbook, error)

GetOrderbook returns current orderbook

func (*BTCMarkets) GetOrders

func (b *BTCMarkets) GetOrders(ctx context.Context, marketID string, before, after, limit int64, openOnly bool) ([]OrderData, error)

GetOrders returns current order information on the exchange

func (*BTCMarkets) GetRecentTrades

func (b *BTCMarkets) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error)

GetRecentTrades returns the most recent trades for a currency and asset

func (*BTCMarkets) GetReport

func (b *BTCMarkets) GetReport(ctx context.Context, reportID string) (ReportData, error)

GetReport finds details bout a past report

func (*BTCMarkets) GetServerTime

func (b *BTCMarkets) GetServerTime(ctx context.Context) (time.Time, error)

GetServerTime gets time from btcmarkets

func (*BTCMarkets) GetTicker

func (b *BTCMarkets) GetTicker(ctx context.Context, marketID string) (Ticker, error)

GetTicker returns a ticker symbol - example "btc" or "ltc"

func (*BTCMarkets) GetTickers

func (b *BTCMarkets) GetTickers(ctx context.Context, marketIDs currency.Pairs) ([]Ticker, error)

GetTickers gets multiple tickers

func (*BTCMarkets) GetTradeByID

func (b *BTCMarkets) GetTradeByID(ctx context.Context, id string) (TradeHistoryData, error)

GetTradeByID returns the singular trade of the ID given

func (*BTCMarkets) GetTradeHistory

func (b *BTCMarkets) GetTradeHistory(ctx context.Context, marketID, orderID string, before, after, limit int64) ([]TradeHistoryData, error)

GetTradeHistory returns trade history

func (*BTCMarkets) GetTrades

func (b *BTCMarkets) GetTrades(ctx context.Context, marketID string, before, after, limit int64) ([]Trade, error)

GetTrades returns executed trades on the exchange

func (*BTCMarkets) GetTradingFees

func (b *BTCMarkets) GetTradingFees(ctx context.Context) (TradingFeeResponse, error)

GetTradingFees returns trading fees for all pairs based on trading activity

func (*BTCMarkets) GetTransactions

func (b *BTCMarkets) GetTransactions(ctx context.Context, assetName string, before, after, limit int64) ([]TransactionData, error)

GetTransactions gets trading fees

func (*BTCMarkets) GetTransfer

func (b *BTCMarkets) GetTransfer(ctx context.Context, id string) (TransferData, error)

GetTransfer gets asset transfer info for a given ID

func (*BTCMarkets) GetWithdrawal

func (b *BTCMarkets) GetWithdrawal(ctx context.Context, id string) (TransferData, error)

GetWithdrawal gets withdrawawl info for a given id

func (*BTCMarkets) GetWithdrawalFees

func (b *BTCMarkets) GetWithdrawalFees(ctx context.Context) ([]WithdrawalFeeData, error)

GetWithdrawalFees gets withdrawal fees for all assets

func (*BTCMarkets) GetWithdrawalsHistory

func (b *BTCMarkets) GetWithdrawalsHistory(ctx context.Context, c currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*BTCMarkets) ListAssets

func (b *BTCMarkets) ListAssets(ctx context.Context) ([]AssetData, error)

ListAssets lists all available assets

func (*BTCMarkets) ListDeposits

func (b *BTCMarkets) ListDeposits(ctx context.Context, before, after, limit int64) ([]TransferData, error)

ListDeposits lists the deposit history

func (*BTCMarkets) ListTransfers

func (b *BTCMarkets) ListTransfers(ctx context.Context, before, after, limit int64) ([]TransferData, error)

ListTransfers lists the past asset transfers

func (*BTCMarkets) ListWithdrawals

func (b *BTCMarkets) ListWithdrawals(ctx context.Context, before, after, limit int64) ([]TransferData, error)

ListWithdrawals lists the withdrawal history

func (*BTCMarkets) ModifyOrder

func (b *BTCMarkets) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error)

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

func (*BTCMarkets) NewOrder

func (b *BTCMarkets) NewOrder(ctx context.Context, marketID string, price, amount float64, orderType, side string, triggerPrice,
	targetAmount float64, timeInForce string, postOnly bool, selfTrade, clientOrderID string) (OrderData, error)

NewOrder requests a new order and returns an ID

func (*BTCMarkets) RemoveOrder

func (b *BTCMarkets) RemoveOrder(ctx context.Context, id string) (CancelOrderResp, error)

RemoveOrder removes a given order

func (*BTCMarkets) RequestWithdraw

func (b *BTCMarkets) RequestWithdraw(ctx context.Context, assetName string, amount float64,
	toAddress, accountName, accountNumber, bsbNumber, bankName string) (TransferData, error)

RequestWithdraw requests withdrawals

func (*BTCMarkets) Run

func (b *BTCMarkets) Run()

Run implements the BTC Markets wrapper

func (*BTCMarkets) SendAuthenticatedRequest

func (b *BTCMarkets) SendAuthenticatedRequest(ctx context.Context, method, path string, data, result interface{}, f request.EndpointLimit) (err error)

SendAuthenticatedRequest sends an authenticated HTTP request

func (*BTCMarkets) SendHTTPRequest

func (b *BTCMarkets) SendHTTPRequest(ctx context.Context, path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*BTCMarkets) SetDefaults

func (b *BTCMarkets) SetDefaults()

SetDefaults sets basic defaults

func (*BTCMarkets) Setup

func (b *BTCMarkets) Setup(exch *config.Exchange) error

Setup takes in an exchange configuration and sets all parameters

func (*BTCMarkets) Start

func (b *BTCMarkets) Start(wg *sync.WaitGroup) error

Start starts the BTC Markets go routine

func (*BTCMarkets) SubmitOrder

func (b *BTCMarkets) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*BTCMarkets) Subscribe

func (b *BTCMarkets) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*BTCMarkets) UpdateAccountInfo

func (b *BTCMarkets) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies

func (*BTCMarkets) UpdateOrderbook

func (b *BTCMarkets) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*BTCMarkets) UpdateTicker

func (b *BTCMarkets) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*BTCMarkets) UpdateTickers

func (b *BTCMarkets) UpdateTickers(ctx context.Context, a asset.Item) error

UpdateTickers updates the ticker for all currency pairs of a given asset type

func (*BTCMarkets) UpdateTradablePairs

func (b *BTCMarkets) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

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

func (*BTCMarkets) ValidateCredentials

func (b *BTCMarkets) ValidateCredentials(ctx context.Context, assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*BTCMarkets) WithdrawCryptocurrencyFunds

func (b *BTCMarkets) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTCMarkets) WithdrawFiatFunds

func (b *BTCMarkets) WithdrawFiatFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTCMarkets) WithdrawFiatFundsToInternationalBank

func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*BTCMarkets) WsConnect

func (b *BTCMarkets) WsConnect() error

WsConnect connects to a websocket feed

type BatchCancelResponse

type BatchCancelResponse struct {
	CancelOrders        []CancelOrderResp      `json:"cancelOrders"`
	UnprocessedRequests []UnprocessedBatchResp `json:"unprocessedRequests"`
}

BatchCancelResponse stores the cancellation details from batch cancels

type BatchPlaceCancelResponse

type BatchPlaceCancelResponse struct {
	PlacedOrders      []BatchPlaceData       `json:"placeOrders"`
	CancelledOrders   []CancelOrderResp      `json:"cancelOrders"`
	UnprocessedOrders []UnprocessedBatchResp `json:"unprocessedRequests"`
}

BatchPlaceCancelResponse stores place and cancel batch data

type BatchPlaceData

type BatchPlaceData struct {
	OrderID       string    `json:"orderId"`
	MarketID      string    `json:"marketId"`
	Side          string    `json:"side"`
	Type          string    `json:"type"`
	CreationTime  time.Time `json:"creationTime"`
	Price         float64   `json:"price,string"`
	Amount        float64   `json:"amount,string"`
	OpenAmount    float64   `json:"openAmount,string"`
	Status        string    `json:"status"`
	ClientOrderID string    `json:"clientOrderId"`
}

BatchPlaceData stores data for placed batch orders

type BatchTradeResponse

type BatchTradeResponse struct {
	Orders              []BatchPlaceData       `json:"orders"`
	UnprocessedRequests []UnprocessedBatchResp `json:"unprocessedRequests"`
}

BatchTradeResponse stores the trades from batchtrades

type CancelBatch

type CancelBatch struct {
	OrderID       string `json:"orderId,omitempty"`
	ClientOrderID string `json:"clientOrderId,omitempty"`
}

CancelBatch stores data for batch cancel request

type CancelOrderMethod

type CancelOrderMethod struct {
	CancelOrder CancelBatch `json:"cancelOrder,omitempty"`
}

CancelOrderMethod stores data for Cancel request

type CancelOrderResp

type CancelOrderResp struct {
	OrderID       string `json:"orderId"`
	ClientOrderID string `json:"clientOrderId"`
}

CancelOrderResp stores data for cancelled orders

type CandleResponse

type CandleResponse [][6]string

CandleResponse holds OHLCV data for exchange

type CreateReportResp

type CreateReportResp struct {
	ReportID string `json:"reportId"`
}

CreateReportResp stores data for created report

type DepositAddress

type DepositAddress struct {
	Address   string `json:"address"`
	AssetName string `json:"assetName"`
	Tag       string // custom field we populate
}

DepositAddress stores deposit address data

type Market

type Market struct {
	MarketID       string  `json:"marketId"`
	BaseAsset      string  `json:"baseAsset"`
	QuoteAsset     string  `json:"quoteAsset"`
	MinOrderAmount float64 `json:"minOrderAmount,string"`
	MaxOrderAmount float64 `json:"maxOrderAmount,string"`
	AmountDecimals int64   `json:"amountDecimals,string"`
	PriceDecimals  int64   `json:"priceDecimals,string"`
}

Market holds a tradable market instrument

type MarketCandle

type MarketCandle struct {
	Time   time.Time
	Open   float64
	Close  float64
	Low    float64
	High   float64
	Volume float64
}

MarketCandle stores candle data for a given pair

type OBData

type OBData struct {
	Price  float64
	Volume float64
}

OBData stores orderbook data

type Order

type Order struct {
	ID              int64           `json:"id"`
	Currency        string          `json:"currency"`
	Instrument      string          `json:"instrument"`
	OrderSide       string          `json:"orderSide"`
	OrderType       string          `json:"ordertype"`
	CreationTime    time.Time       `json:"creationTime"`
	Status          string          `json:"status"`
	ErrorMessage    string          `json:"errorMessage"`
	Price           float64         `json:"price"`
	Volume          float64         `json:"volume"`
	OpenVolume      float64         `json:"openVolume"`
	ClientRequestID string          `json:"clientRequestId"`
	Trades          []TradeResponse `json:"trades"`
}

Order holds order information

type OrderData

type OrderData struct {
	OrderID      string    `json:"orderId"`
	MarketID     string    `json:"marketId"`
	Side         string    `json:"side"`
	Type         string    `json:"type"`
	CreationTime time.Time `json:"creationTime"`
	Price        float64   `json:"price,string"`
	Amount       float64   `json:"amount,string"`
	OpenAmount   float64   `json:"openAmount,string"`
	Status       string    `json:"status"`
}

OrderData stores data for new order created

type OrderToGo

type OrderToGo struct {
	Currency        string `json:"currency"`
	Instrument      string `json:"instrument"`
	Price           int64  `json:"price"`
	Volume          int64  `json:"volume"`
	OrderSide       string `json:"orderSide"`
	OrderType       string `json:"ordertype"`
	ClientRequestID string `json:"clientRequestId"`
}

OrderToGo holds order information to be sent to the exchange

type Orderbook

type Orderbook struct {
	MarketID   string
	SnapshotID int64
	Asks       []OBData
	Bids       []OBData
}

Orderbook holds current orderbook information returned from the exchange

type PaymentDetails

type PaymentDetails struct {
	Address string `json:"address"`
}

PaymentDetails stores payment address

type PlaceBatch

type PlaceBatch struct {
	MarketID      string  `json:"marketId"`
	Price         float64 `json:"price"`
	Amount        float64 `json:"amount"`
	OrderType     string  `json:"type"`
	Side          string  `json:"side"`
	TriggerPrice  float64 `json:"triggerPrice,omitempty"`
	TriggerAmount float64 `json:"triggerAmount,omitempty"`
	TimeInForce   string  `json:"timeInForce,omitempty"`
	PostOnly      bool    `json:"postOnly,omitempty"`
	SelfTrade     string  `json:"selfTrade,omitempty"`
	ClientOrderID string  `json:"clientOrderId,omitempty"`
}

PlaceBatch stores data for place batch request

type PlaceOrderMethod

type PlaceOrderMethod struct {
	PlaceOrder PlaceBatch `json:"placeOrder,omitempty"`
}

PlaceOrderMethod stores data for place request

type RateLimit

type RateLimit struct {
	Auth            *rate.Limiter
	UnAuth          *rate.Limiter
	OrderPlacement  *rate.Limiter
	BatchOrders     *rate.Limiter
	WithdrawRequest *rate.Limiter
	CreateNewReport *rate.Limiter
}

RateLimit implements the request.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

Limit limits the outbound requests

type ReportData

type ReportData struct {
	ID           string    `json:"id"`
	ContentURL   string    `json:"contentUrl"`
	CreationTime time.Time `json:"creationTime"`
	ReportType   string    `json:"reportType"`
	Status       string    `json:"status"`
	Format       string    `json:"format"`
}

ReportData gets data for a created report

type Ticker

type Ticker struct {
	MarketID  string    `json:"marketId"`
	BestBID   float64   `json:"bestBid,string"`
	BestAsk   float64   `json:"bestAsk,string"`
	LastPrice float64   `json:"lastPrice,string"`
	Volume    float64   `json:"volume24h,string"`
	Change24h float64   `json:"price24h,string"`
	Low24h    float64   `json:"low24h,string"`
	High24h   float64   `json:"high24h,string"`
	Timestamp time.Time `json:"timestamp"`
}

Ticker holds ticker information

type TimeResp

type TimeResp struct {
	Time time.Time `json:"timestamp"`
}

TimeResp stores server time

type Trade

type Trade struct {
	TradeID   string    `json:"id"`
	Amount    float64   `json:"amount,string"`
	Price     float64   `json:"price,string"`
	Timestamp time.Time `json:"timestamp"`
	Side      string    `json:"side"`
}

Trade holds trade information

type TradeHistoryData

type TradeHistoryData struct {
	ID            string    `json:"id"`
	MarketID      string    `json:"marketId"`
	Timestamp     time.Time `json:"timestamp"`
	Price         float64   `json:"price,string"`
	Amount        float64   `json:"amount,string"`
	Side          string    `json:"side"`
	Fee           float64   `json:"fee,string"`
	OrderID       string    `json:"orderId"`
	LiquidityType string    `json:"liquidityType"`
}

TradeHistoryData stores data of past trades

type TradeResponse

type TradeResponse struct {
	ID           int64     `json:"id"`
	CreationTime time.Time `json:"creationTime"`
	Description  string    `json:"description"`
	Price        float64   `json:"price"`
	Volume       float64   `json:"volume"`
	Fee          float64   `json:"fee"`
}

TradeResponse holds trade information

type TradingFee

type TradingFee struct {
	Success        bool    `json:"success"`
	ErrorCode      int     `json:"errorCode"`
	ErrorMessage   string  `json:"errorMessage"`
	TradingFeeRate float64 `json:"tradingfeerate"`
	Volume30Day    float64 `json:"volume30day"`
}

TradingFee 30 day trade volume

type TradingFeeData

type TradingFeeData struct {
	MakerFeeRate float64 `json:"makerFeeRate,string"`
	TakerFeeRate float64 `json:"takerFeeRate,string"`
	MarketID     string  `json:"marketId"`
}

TradingFeeData stores trading fee data

type TradingFeeResponse

type TradingFeeResponse struct {
	MonthlyVolume float64          `json:"volume30Day,string"`
	FeeByMarkets  []TradingFeeData `json:"FeeByMarkets"`
}

TradingFeeResponse stores trading fee data

type TransactionData

type TransactionData struct {
	ID           string    `json:"id"`
	CreationTime time.Time `json:"creationTime"`
	Description  string    `json:"description"`
	AssetName    string    `json:"assetName"`
	Amount       float64   `json:"amount,string"`
	Balance      float64   `json:"balance,string"`
	FeeType      string    `json:"type"`
	RecordType   string    `json:"recordType"`
	ReferrenceID string    `json:"referrenceId"`
}

TransactionData stores data from past transactions

type TransferData

type TransferData struct {
	ID             string         `json:"id"`
	AssetName      string         `json:"assetName"`
	Amount         float64        `json:"amount,string"`
	RequestType    string         `json:"type"`
	CreationTime   time.Time      `json:"creationTime"`
	Status         string         `json:"status"`
	Description    string         `json:"description"`
	Fee            float64        `json:"fee,string"`
	LastUpdate     string         `json:"lastUpdate"`
	PaymentDetails PaymentDetails `json:"paymentDetail"`
}

TransferData stores data from asset transfers

type UnprocessedBatchResp

type UnprocessedBatchResp struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	RequestID string `json:"requestId"`
}

UnprocessedBatchResp stores data for unprocessed response

type WithdrawRequestAUD

type WithdrawRequestAUD struct {
	Amount        int64  `json:"amount"`
	Currency      string `json:"currency"`
	AccountName   string `json:"accountName"`
	AccountNumber string `json:"accountNumber"`
	BankName      string `json:"bankName"`
	BSBNumber     string `json:"bsbNumber"`
}

WithdrawRequestAUD is a generalized withdraw request type

type WithdrawRequestCrypto

type WithdrawRequestCrypto struct {
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`
	Address  string `json:"address"`
}

WithdrawRequestCrypto is a generalized withdraw request type

type WithdrawalFeeData

type WithdrawalFeeData struct {
	AssetName string  `json:"assetName"`
	Fee       float64 `json:"fee,string"`
}

WithdrawalFeeData stores data for fees

type WsError

type WsError struct {
	MessageType string `json:"messageType"`
	Code        int64  `json:"code"`
	Message     string `json:"message"`
}

WsError stores websocket error data

type WsFundTransfer

type WsFundTransfer struct {
	FundTransferID int64     `json:"fundtransferId"`
	TransferType   string    `json:"type"`
	Status         string    `json:"status"`
	Timestamp      time.Time `json:"timestamp"`
	Amount         float64   `json:"amount,string"`
	Currency       string    `json:"currency"`
	Fee            float64   `json:"fee,string"`
	MessageType    string    `json:"messageType"`
}

WsFundTransfer stores fund transfer data for websocket

type WsMessageType

type WsMessageType struct {
	MessageType string `json:"messageType"`
}

WsMessageType message sent via ws to determine type

type WsOrderChange

type WsOrderChange struct {
	OrderID       int64         `json:"orderId"`
	MarketID      string        `json:"marketId"`
	Side          string        `json:"side"`
	OrderType     string        `json:"type"`
	OpenVolume    float64       `json:"openVolume,string"`
	Status        string        `json:"status"`
	TriggerStatus string        `json:"triggerStatus"`
	Trades        []WsTradeData `json:"trades"`
	Timestamp     time.Time     `json:"timestamp"`
	MessageType   string        `json:"messageType"`
}

WsOrderChange stores order data

type WsOrderbook

type WsOrderbook struct {
	Currency    string          `json:"marketId"`
	Timestamp   time.Time       `json:"timestamp"`
	Bids        [][]interface{} `json:"bids"`
	Asks        [][]interface{} `json:"asks"`
	MessageType string          `json:"messageType"`
	Snapshot    bool            `json:"snapshot"`
}

WsOrderbook message received for orderbook data

type WsSubscribe

type WsSubscribe struct {
	MarketIDs   []string `json:"marketIds,omitempty"`
	Channels    []string `json:"channels,omitempty"`
	Key         string   `json:"key,omitempty"`
	Signature   string   `json:"signature,omitempty"`
	Timestamp   string   `json:"timestamp,omitempty"`
	MessageType string   `json:"messageType,omitempty"`
}

WsSubscribe defines a subscription message used in the Subscribe function

type WsTick

type WsTick struct {
	Currency    string    `json:"marketId"`
	Timestamp   time.Time `json:"timestamp"`
	Bid         float64   `json:"bestBid,string"`
	Ask         float64   `json:"bestAsk,string"`
	Last        float64   `json:"lastPrice,string"`
	Volume      float64   `json:"volume24h,string"`
	Price24h    float64   `json:"price24h,string"`
	Low24h      float64   `json:"low24h,string"`
	High24      float64   `json:"high24h,string"`
	MessageType string    `json:"messageType"`
}

WsTick message received for ticker data

type WsTrade

type WsTrade struct {
	Currency    string    `json:"marketId"`
	Timestamp   time.Time `json:"timestamp"`
	TradeID     int64     `json:"tradeId"`
	Price       float64   `json:"price,string"`
	Volume      float64   `json:"volume,string"`
	Side        string    `json:"side"`
	MessageType string    `json:"messageType"`
}

WsTrade message received for trade data

type WsTradeData

type WsTradeData struct {
	TradeID       int64   `json:"tradeId"`
	Price         float64 `json:"price,string"`
	Volume        float64 `json:"volume,string"`
	Fee           float64 `json:"fee,string"`
	LiquidityType string  `json:"liquidityType"`
}

WsTradeData stores trade data for websocket

Jump to

Keyboard shortcuts

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