bitfinex

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 43 Imported by: 0

README

GoCryptoTrader package Bitfinex

Build Status Software License GoDoc Coverage Status Go Report Card

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

Bitfinex 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() == "Bitfinex" {
		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
}
How to do Websocket 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:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

View Source
const (

	// CandlesTimeframeKey configures the timeframe in subscription.Subscription.Params
	CandlesTimeframeKey = "_timeframe"
	// CandlesPeriodKey configures the aggregated period in subscription.Subscription.Params
	CandlesPeriodKey = "_period"
)
View Source
const (
	LeaderboardUnrealisedProfitPeriodDelta = "plu_diff"
	LeaderboardUnrealisedProfitInception   = "plu"
	LeaderboardVolume                      = "vol"
	LeaderbookRealisedProfit               = "plr"
)

Leaderboard keys

Variables

View Source
var AcceptedOrderType = []string{"market", "limit", "stop", "trailing-stop",
	"fill-or-kill", "exchange market", "exchange limit", "exchange stop",
	"exchange trailing-stop", "exchange fill-or-kill"}

AcceptedOrderType defines the accepted market types, exchange strings denote non-contract order types.

View Source
var AcceptedWalletNames = []string{"trading", "exchange", "deposit", "margin",
	"funding"}

AcceptedWalletNames defines different wallets supported by the exchange

Functions

This section is empty.

Types

type AccountFees

type AccountFees struct {
	Withdraw map[string]interface{} `json:"withdraw"`
}

AccountFees stores withdrawal account fee data from Bitfinex

type AccountInfo

type AccountInfo struct {
	MakerFees float64           `json:"maker_fees,string"`
	TakerFees float64           `json:"taker_fees,string"`
	Fees      []AccountInfoFees `json:"fees"`
	Message   string            `json:"message"`
}

AccountInfo general account information with fees

type AccountInfoFees

type AccountInfoFees struct {
	Pairs     string  `json:"pairs"`
	MakerFees float64 `json:"maker_fees,string"`
	TakerFees float64 `json:"taker_fees,string"`
}

AccountInfoFees general account information with fees

type AccountInfoFull

type AccountInfoFull struct {
	Info    []AccountInfo
	Message string `json:"message"`
}

AccountInfoFull adds the error message to Account info

type AccountSummary

type AccountSummary struct {
	TradeVolumePer30D []Currency `json:"trade_vol_30d"`
	FundingProfit30D  []Currency `json:"funding_profit_30d"`
	MakerFee          float64    `json:"maker_fee"`
	TakerFee          float64    `json:"taker_fee"`
}

AccountSummary holds account summary data

type AccountV2Data

type AccountV2Data struct {
	ID               int64
	Email            string
	Username         string
	MTSAccountCreate int64
	Verified         int64
	Timezone         string
}

AccountV2Data stores account v2 data

type Balance

type Balance struct {
	Type      string  `json:"type"`
	Currency  string  `json:"currency"`
	Amount    float64 `json:"amount,string"`
	Available float64 `json:"available,string"`
}

Balance holds current balance data

type BalanceHistory

type BalanceHistory struct {
	Currency    string  `json:"currency"`
	Amount      float64 `json:"amount,string"`
	Balance     float64 `json:"balance,string"`
	Description string  `json:"description"`
	Timestamp   string  `json:"timestamp"`
}

BalanceHistory holds balance history information

type Bitfinex

type Bitfinex struct {
	exchange.Base
}

Bitfinex is the overarching type across the bitfinex package

func (*Bitfinex) AuthenticateWebsocket

func (b *Bitfinex) AuthenticateWebsocket(ctx context.Context) error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Bitfinex) CalculateTradingFee

func (b *Bitfinex) CalculateTradingFee(i []AccountInfo, purchasePrice, amount float64, c currency.Code, isMaker bool) (fee float64, err error)

CalculateTradingFee returns an estimate of fee based on type of whether is maker or taker fee

func (*Bitfinex) CancelAllExistingOrders

func (b *Bitfinex) CancelAllExistingOrders(ctx context.Context) (string, error)

CancelAllExistingOrders cancels all active and open orders

func (*Bitfinex) CancelAllOrders

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

CancelAllOrders cancels all orders associated with a currency pair

func (*Bitfinex) CancelBatchOrders

func (b *Bitfinex) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*Bitfinex) CancelExistingOrder

func (b *Bitfinex) CancelExistingOrder(ctx context.Context, orderID int64) (Order, error)

CancelExistingOrder cancels a single order by OrderID

func (*Bitfinex) CancelMultipleOrders

func (b *Bitfinex) CancelMultipleOrders(ctx context.Context, orderIDs []int64) (string, error)

CancelMultipleOrders cancels multiple orders

func (*Bitfinex) CancelMultipleOrdersV2

func (b *Bitfinex) CancelMultipleOrdersV2(ctx context.Context, orderID, clientOrderID, groupOrderID int64, clientOrderIDDate time.Time, allOrders bool) ([]CancelMultiOrderResponse, error)

CancelMultipleOrdersV2 cancels multiple orders

func (*Bitfinex) CancelOffer

func (b *Bitfinex) CancelOffer(ctx context.Context, offerID int64) (Offer, error)

CancelOffer cancels offer by offerID

func (*Bitfinex) CancelOrder

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

CancelOrder cancels an order by its corresponding ID number

func (*Bitfinex) ClaimPosition

func (b *Bitfinex) ClaimPosition(ctx context.Context, positionID int) (Position, error)

ClaimPosition allows positions to be claimed

func (*Bitfinex) CloseMarginFunding

func (b *Bitfinex) CloseMarginFunding(ctx context.Context, swapID int64) (Offer, error)

CloseMarginFunding closes an unused or used taken fund

func (*Bitfinex) ConfigureWS

func (b *Bitfinex) ConfigureWS() error

ConfigureWS to send checksums and sequence numbers

func (*Bitfinex) FetchAccountInfo

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

FetchAccountInfo retrieves balances for all enabled currencies

func (*Bitfinex) FetchOrderbook

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

FetchOrderbook returns the orderbook for a currency pair

func (*Bitfinex) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*Bitfinex) FetchTradablePairs

func (b *Bitfinex) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Bitfinex) FormatExchangeKlineInterval

func (b *Bitfinex) FormatExchangeKlineInterval(in kline.Interval) (string, error)

FormatExchangeKlineInterval returns Interval to exchange formatted string

func (*Bitfinex) GenerateDefaultSubscriptions

func (b *Bitfinex) GenerateDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*Bitfinex) GetAccountBalance

func (b *Bitfinex) GetAccountBalance(ctx context.Context) ([]Balance, error)

GetAccountBalance returns full wallet balance information

func (*Bitfinex) GetAccountFees

func (b *Bitfinex) GetAccountFees(ctx context.Context) ([]AccountInfo, error)

GetAccountFees returns information about your account trading fees

func (*Bitfinex) GetAccountFundingHistory

func (b *Bitfinex) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory returns funding history, deposits and withdrawals

func (*Bitfinex) GetAccountInfoV2

func (b *Bitfinex) GetAccountInfoV2(ctx context.Context) (AccountV2Data, error)

GetAccountInfoV2 gets V2 account data

func (*Bitfinex) GetAccountSummary

func (b *Bitfinex) GetAccountSummary(ctx context.Context) (AccountSummary, error)

GetAccountSummary returns a 30-day summary of your trading volume and return on margin funding

func (*Bitfinex) GetActiveCredits

func (b *Bitfinex) GetActiveCredits(ctx context.Context) ([]Offer, error)

GetActiveCredits returns all available credits

func (*Bitfinex) GetActiveMarginFunding

func (b *Bitfinex) GetActiveMarginFunding(ctx context.Context) ([]MarginFunds, error)

GetActiveMarginFunding returns an array of active margin funds

func (*Bitfinex) GetActiveOffers

func (b *Bitfinex) GetActiveOffers(ctx context.Context) ([]Offer, error)

GetActiveOffers returns all current active offers

func (*Bitfinex) GetActiveOrders

func (b *Bitfinex) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetActiveOrders retrieves any orders that are active/open

func (*Bitfinex) GetActivePositions

func (b *Bitfinex) GetActivePositions(ctx context.Context) ([]Position, error)

GetActivePositions returns an array of active positions

func (*Bitfinex) GetAvailableTransferChains

func (b *Bitfinex) GetAvailableTransferChains(ctx context.Context, cryptocurrency currency.Code) ([]string, error)

GetAvailableTransferChains returns the available transfer blockchains for the specific cryptocurrency

func (*Bitfinex) GetBalanceHistory

func (b *Bitfinex) GetBalanceHistory(ctx context.Context, symbol string, timeSince, timeUntil time.Time, limit int, wallet string) ([]BalanceHistory, error)

GetBalanceHistory returns balance history for the account

func (*Bitfinex) GetCandles

func (b *Bitfinex) GetCandles(ctx context.Context, symbol, timeFrame string, start, end int64, limit uint32, historic bool) ([]Candle, error)

GetCandles returns candle chart data timeFrame values: '1m', '5m', '15m', '30m', '1h', '3h', '6h', '12h', '1D', '1W', '14D', '1M' section values: last or hist

func (*Bitfinex) GetConfigurations

func (b *Bitfinex) GetConfigurations() error

GetConfigurations fetches currency and symbol site configuration data.

func (*Bitfinex) GetCryptocurrencyWithdrawalFee

func (b *Bitfinex) GetCryptocurrencyWithdrawalFee(c currency.Code, accountFees AccountFees) (fee float64, err error)

GetCryptocurrencyWithdrawalFee returns an estimate of fee based on type of transaction

func (*Bitfinex) GetCurrencyTradeURL

func (b *Bitfinex) GetCurrencyTradeURL(_ context.Context, a asset.Item, cp currency.Pair) (string, error)

GetCurrencyTradeURL returns the URL to the exchange's trade page for the given asset and currency pair

func (*Bitfinex) GetDepositAddress

func (b *Bitfinex) GetDepositAddress(ctx context.Context, c currency.Code, accountID, chain string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Bitfinex) GetDerivativeStatusInfo

func (b *Bitfinex) GetDerivativeStatusInfo(ctx context.Context, keys, startTime, endTime string, sort, limit int64) ([]DerivativeDataResponse, error)

GetDerivativeStatusInfo gets status data for the queried derivative

func (*Bitfinex) GetFee

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

GetFee returns an estimate of fee based on type of transaction

func (*Bitfinex) GetFeeByType

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

GetFeeByType returns an estimate of fee based on type of transaction

func (*Bitfinex) GetForeignExchangeRate

func (b *Bitfinex) GetForeignExchangeRate() error

GetForeignExchangeRate calculates the exchange rate between two currencies

func (*Bitfinex) GetFundingBook

func (b *Bitfinex) GetFundingBook(ctx context.Context, symbol string) (FundingBook, error)

GetFundingBook the entire margin funding book for both bids and asks sides per currency string symbol - example "USD" WARNING: Orderbook now has this support, will be deprecated once a full conversion to full V2 API update is done.

func (*Bitfinex) GetFuturesContractDetails

func (b *Bitfinex) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error)

GetFuturesContractDetails returns all contracts from the exchange by asset type

func (*Bitfinex) GetHistoricCandles

func (b *Bitfinex) GetHistoricCandles(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)

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

func (*Bitfinex) GetHistoricCandlesExtended

func (b *Bitfinex) GetHistoricCandlesExtended(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)

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

func (*Bitfinex) GetHistoricTrades

func (b *Bitfinex) GetHistoricTrades(ctx context.Context, p currency.Pair, a asset.Item, timestampStart, timestampEnd time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*Bitfinex) GetInactiveOrders

func (b *Bitfinex) GetInactiveOrders(ctx context.Context, symbol string, ids ...int64) ([]Order, error)

GetInactiveOrders returns order status information

func (*Bitfinex) GetKeyPermissions

func (b *Bitfinex) GetKeyPermissions(ctx context.Context) (KeyPermissions, error)

GetKeyPermissions checks the permissions of the key being used to generate this request.

func (*Bitfinex) GetLatestFundingRates

GetLatestFundingRates returns the latest funding rates data

func (*Bitfinex) GetLeaderboard

func (b *Bitfinex) GetLeaderboard(ctx context.Context, key, timeframe, symbol string, sort, limit int, start, end string) ([]LeaderboardEntry, error)

GetLeaderboard returns leaderboard standings for unrealized profit (period delta), unrealized profit (inception), volume, and realized profit. Allowed key values: "plu_diff" for unrealized profit (period delta), "plu" for unrealized profit (inception); "vol" for volume; "plr" for realized profit Allowed time frames are 3h, 1w and 1M Allowed symbols are trading pairs (e.g. tBTCUSD, tETHUSD and tGLOBAL:USD)

func (*Bitfinex) GetLends

func (b *Bitfinex) GetLends(ctx context.Context, symbol string, values url.Values) ([]Lends, error)

GetLends returns a list of the most recent funding data for the given currency: total amount provided and Flash Return Rate (in % by 365 days) over time Symbol - example "USD"

func (*Bitfinex) GetLiquidationFeed

func (b *Bitfinex) GetLiquidationFeed() error

GetLiquidationFeed returns liquidations. By default it will retrieve the most recent liquidations, but time-specific data can be retrieved using timestamps.

func (*Bitfinex) GetMarginInfo

func (b *Bitfinex) GetMarginInfo(ctx context.Context) ([]MarginInfo, error)

GetMarginInfo shows your trading wallet information for margin trading

func (*Bitfinex) GetMarginTotalTakenFunds

func (b *Bitfinex) GetMarginTotalTakenFunds(ctx context.Context) ([]MarginTotalTakenFunds, error)

GetMarginTotalTakenFunds returns an array of active funding used in a position

func (*Bitfinex) GetMarketAveragePrice

func (b *Bitfinex) GetMarketAveragePrice() error

GetMarketAveragePrice calculates the average execution price for Trading or rate for Margin funding

func (*Bitfinex) GetMovementHistory

func (b *Bitfinex) GetMovementHistory(ctx context.Context, symbol, method string, timeSince, timeUntil time.Time, limit int) ([]MovementHistory, error)

GetMovementHistory returns an array of past deposits and withdrawals

func (*Bitfinex) GetOfferStatus

func (b *Bitfinex) GetOfferStatus(ctx context.Context, offerID int64) (Offer, error)

GetOfferStatus checks offer status whether it has been cancelled, execute or is still active

func (*Bitfinex) GetOpenInterest

func (b *Bitfinex) GetOpenInterest(context.Context, ...key.PairAsset) ([]futures.OpenInterest, error)

GetOpenInterest returns the open interest rate for a given asset pair

func (*Bitfinex) GetOpenOrders

func (b *Bitfinex) GetOpenOrders(ctx context.Context, ids ...int64) ([]Order, error)

GetOpenOrders returns all active orders and statuses

func (*Bitfinex) GetOrderHistory

func (b *Bitfinex) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

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

func (*Bitfinex) GetOrderInfo

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

GetOrderInfo returns order information based on order ID

func (*Bitfinex) GetOrderStatus

func (b *Bitfinex) GetOrderStatus(ctx context.Context, orderID int64) (Order, error)

GetOrderStatus returns order status information

func (*Bitfinex) GetOrderbook

func (b *Bitfinex) GetOrderbook(ctx context.Context, symbol, precision string, limit int64) (Orderbook, error)

GetOrderbook retrieves the orderbook bid and ask price points for a currency pair - By default the response will return 25 bid and 25 ask price points. symbol - Example "tBTCUSD" precision - P0,P1,P2,P3,R0 Values can contain limit amounts for both the asks and bids - Example "len" = 100

func (*Bitfinex) GetPairs

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

GetPairs gets pairs for different assets

func (*Bitfinex) GetPlatformStatus

func (b *Bitfinex) GetPlatformStatus(ctx context.Context) (int, error)

GetPlatformStatus returns the Bifinex platform status

func (*Bitfinex) GetRecentTrades

func (b *Bitfinex) 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 (*Bitfinex) GetServerTime

func (b *Bitfinex) GetServerTime(_ context.Context, _ asset.Item) (time.Time, error)

GetServerTime returns the current exchange server time.

func (*Bitfinex) GetSiteInfoConfigData

func (b *Bitfinex) GetSiteInfoConfigData(ctx context.Context, assetType asset.Item) ([]order.MinMaxLevel, error)

GetSiteInfoConfigData returns site configuration data by pub:info:{AssetType} as a map path should be bitfinexInfoPairs or bitfinexInfoPairsFuture??? NOTE: See https://docs.bitfinex.com/reference/rest-public-conf

func (*Bitfinex) GetSiteListConfigData

func (b *Bitfinex) GetSiteListConfigData(ctx context.Context, set string) ([]string, error)

GetSiteListConfigData returns site configuration data by pub:list:{Object}:{Detail} string sets. NOTE: See https://docs.bitfinex.com/reference/rest-public-conf

func (*Bitfinex) GetStats

func (b *Bitfinex) GetStats(ctx context.Context, symbol string) ([]Stat, error)

GetStats returns various statistics about the requested pair

func (*Bitfinex) GetStatus

func (b *Bitfinex) GetStatus() error

GetStatus returns different types of platform information - currently supports derivatives pair status only.

func (*Bitfinex) GetTicker

func (b *Bitfinex) GetTicker(ctx context.Context, symbol string) (*Ticker, error)

GetTicker returns ticker information for one symbol

func (*Bitfinex) GetTickerBatch

func (b *Bitfinex) GetTickerBatch(ctx context.Context) (map[string]*Ticker, error)

GetTickerBatch returns all supported ticker information

func (*Bitfinex) GetTradeHistory

func (b *Bitfinex) GetTradeHistory(ctx context.Context, currencyPair string, timestamp, until time.Time, limit, reverse int) ([]TradeHistory, error)

GetTradeHistory returns past executed trades

func (*Bitfinex) GetTrades

func (b *Bitfinex) GetTrades(ctx context.Context, currencyPair string, limit, timestampStart, timestampEnd int64, reOrderResp bool) ([]Trade, error)

GetTrades gets historic trades that occurred on the exchange

currencyPair e.g. "tBTCUSD" timestampStart is a millisecond timestamp timestampEnd is a millisecond timestamp reOrderResp reorders the returned data.

func (*Bitfinex) GetUnusedMarginFunds

func (b *Bitfinex) GetUnusedMarginFunds(ctx context.Context) ([]MarginFunds, error)

GetUnusedMarginFunds returns an array of funding borrowed but not currently used

func (*Bitfinex) GetV2Balances

func (b *Bitfinex) GetV2Balances(ctx context.Context) ([]WalletDataV2, error)

GetV2Balances gets v2 balances

func (*Bitfinex) GetV2FundingInfo

func (b *Bitfinex) GetV2FundingInfo(ctx context.Context, key string) (MarginFundingDataV2, error)

GetV2FundingInfo gets funding info for margin pairs

func (*Bitfinex) GetV2MarginFunding

func (b *Bitfinex) GetV2MarginFunding(ctx context.Context, symbol, amount string, period int32) (MarginV2FundingData, error)

GetV2MarginFunding gets borrowing rates for margin trading

func (*Bitfinex) GetV2MarginInfo

func (b *Bitfinex) GetV2MarginInfo(ctx context.Context, symbol string) ([]MarginInfoV2, error)

GetV2MarginInfo gets v2 margin info for a symbol provided symbol: base, sym_all, any other trading symbol example tBTCUSD

func (*Bitfinex) GetWithdrawalFees

func (b *Bitfinex) GetWithdrawalFees(ctx context.Context) (AccountFees, error)

GetWithdrawalFees - Gets all fee rates for withdrawals

func (*Bitfinex) GetWithdrawalsHistory

func (b *Bitfinex) GetWithdrawalsHistory(ctx context.Context, c currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Bitfinex) ModifyOrder

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

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

func (*Bitfinex) NewDeposit

func (b *Bitfinex) NewDeposit(ctx context.Context, method, walletName string, renew uint8) (*Deposit, error)

NewDeposit returns a new deposit address Method - Example methods accepted: “bitcoin”, “litecoin”, “ethereum”, “tethers", "ethereumc", "zcash", "monero", "iota", "bcash" WalletName - accepted: "exchange", "margin", "funding" (can also use the old labels which are "exchange", "trading" and "deposit" respectively). If none is set, "funding" will be used by default renew - Default is 0. If set to 1, will return a new unused deposit address

func (*Bitfinex) NewOffer

func (b *Bitfinex) NewOffer(ctx context.Context, symbol string, amount, rate float64, period int64, direction string) (Offer, error)

NewOffer submits a new offer

func (*Bitfinex) NewOrder

func (b *Bitfinex) NewOrder(ctx context.Context, currencyPair, orderType string, amount, price float64, buy, hidden bool) (Order, error)

NewOrder submits a new order and returns a order information Major Upgrade needed on this function to include all query params

func (*Bitfinex) NewOrderMulti

func (b *Bitfinex) NewOrderMulti(ctx context.Context, orders []PlaceOrder) (OrderMultiResponse, error)

NewOrderMulti allows several new orders at once

func (*Bitfinex) OrderUpdate

func (b *Bitfinex) OrderUpdate(ctx context.Context, orderID, groupID, clientOrderID string, amount, price, leverage float64) (*Order, error)

OrderUpdate will send an update signal for an existing order and attempt to modify it

func (*Bitfinex) PopulateAcceptableMethods

func (b *Bitfinex) PopulateAcceptableMethods(ctx context.Context) error

PopulateAcceptableMethods retrieves all accepted currency strings and populates a map to check

func (*Bitfinex) ReplaceOrder

func (b *Bitfinex) ReplaceOrder(ctx context.Context, orderID int64, symbol string, amount, price float64, buy bool, orderType string, hidden bool) (Order, error)

ReplaceOrder replaces an older order with a new order

func (*Bitfinex) SendAuthenticatedHTTPRequest

func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, path string, params map[string]interface{}, result interface{}, endpoint request.EndpointLimit) error

SendAuthenticatedHTTPRequest sends an authenticated http request and json unmarshals result to a supplied variable

func (*Bitfinex) SendAuthenticatedHTTPRequestV2

func (b *Bitfinex) SendAuthenticatedHTTPRequestV2(ctx context.Context, ep exchange.URL, method, path string, params map[string]interface{}, result interface{}, endpoint request.EndpointLimit) error

SendAuthenticatedHTTPRequestV2 sends an authenticated http request and json unmarshals result to a supplied variable

func (*Bitfinex) SendHTTPRequest

func (b *Bitfinex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}, e request.EndpointLimit) error

SendHTTPRequest sends an unauthenticated request

func (*Bitfinex) SetDefaults

func (b *Bitfinex) SetDefaults()

SetDefaults sets the basic defaults for bitfinex

func (*Bitfinex) Setup

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

Setup takes in the supplied exchange configuration details and sets params

func (*Bitfinex) SubmitOrder

func (b *Bitfinex) SubmitOrder(ctx context.Context, o *order.Submit) (*order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Bitfinex) Subscribe

func (b *Bitfinex) Subscribe(channels []subscription.Subscription) error

Subscribe sends a websocket message to receive data from channels

func (*Bitfinex) Unsubscribe

func (b *Bitfinex) Unsubscribe(channels []subscription.Subscription) error

Unsubscribe sends a websocket message to stop receiving data from channels

func (*Bitfinex) UpdateAccountInfo

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

UpdateAccountInfo retrieves balances for all enabled currencies on the Bitfinex exchange

func (*Bitfinex) UpdateOrderExecutionLimits

func (b *Bitfinex) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) error

UpdateOrderExecutionLimits sets exchange execution order limits for an asset type

func (*Bitfinex) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bitfinex) UpdateTicker

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

UpdateTicker updates and returns the ticker for a currency pair

func (*Bitfinex) UpdateTickers

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

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

func (*Bitfinex) UpdateTradablePairs

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

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

func (*Bitfinex) ValidateAPICredentials

func (b *Bitfinex) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error

ValidateAPICredentials validates current credentials used for wrapper functionality

func (*Bitfinex) WalletTransfer

func (b *Bitfinex) WalletTransfer(ctx context.Context, amount float64, currency, walletFrom, walletTo string) (WalletTransfer, error)

WalletTransfer move available balances between your wallets Amount - Amount to move Currency - example "BTC" WalletFrom - example "exchange" WalletTo - example "deposit"

func (*Bitfinex) WithdrawCryptocurrency

func (b *Bitfinex) WithdrawCryptocurrency(ctx context.Context, wallet, address, paymentID, curr string, amount float64) (Withdrawal, error)

WithdrawCryptocurrency requests a withdrawal from one of your wallets. For FIAT, use WithdrawFIAT

func (*Bitfinex) WithdrawCryptocurrencyFunds

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

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bitfinex) WithdrawFIAT

func (b *Bitfinex) WithdrawFIAT(ctx context.Context, withdrawalType, walletType string, withdrawRequest *withdraw.Request) (Withdrawal, error)

WithdrawFIAT Sends an authenticated request to withdraw FIAT currency

func (*Bitfinex) WithdrawFiatFunds

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

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted Returns comma delimited withdrawal IDs

func (*Bitfinex) WithdrawFiatFundsToInternationalBank

func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted Returns comma delimited withdrawal IDs

func (*Bitfinex) WsCancelAllOrders

func (b *Bitfinex) WsCancelAllOrders() error

WsCancelAllOrders authenticated cancel all orders request

func (*Bitfinex) WsCancelMultiOrders

func (b *Bitfinex) WsCancelMultiOrders(orderIDs []int64) error

WsCancelMultiOrders authenticated cancel multi order request

func (*Bitfinex) WsCancelOffer

func (b *Bitfinex) WsCancelOffer(orderID int64) error

WsCancelOffer authenticated cancel offer request

func (*Bitfinex) WsCancelOrder

func (b *Bitfinex) WsCancelOrder(orderID int64) error

WsCancelOrder authenticated cancel order request

func (*Bitfinex) WsConnect

func (b *Bitfinex) WsConnect() error

WsConnect starts a new websocket connection

func (*Bitfinex) WsDataHandler

func (b *Bitfinex) WsDataHandler()

WsDataHandler handles data from wsReadData

func (*Bitfinex) WsInsertSnapshot

func (b *Bitfinex) WsInsertSnapshot(p currency.Pair, assetType asset.Item, books []WebsocketBook, fundingRate bool) error

WsInsertSnapshot add the initial orderbook snapshot when subscribed to a channel

func (*Bitfinex) WsModifyOrder

func (b *Bitfinex) WsModifyOrder(data *WsUpdateOrderRequest) error

WsModifyOrder authenticated modify order request

func (*Bitfinex) WsNewOffer

func (b *Bitfinex) WsNewOffer(data *WsNewOfferRequest) error

WsNewOffer authenticated new offer request

func (*Bitfinex) WsNewOrder

func (b *Bitfinex) WsNewOrder(data *WsNewOrderRequest) (string, error)

WsNewOrder authenticated new order request

func (*Bitfinex) WsSendAuth

func (b *Bitfinex) WsSendAuth(ctx context.Context) error

WsSendAuth sends a authenticated event payload

func (*Bitfinex) WsUpdateOrderbook

func (b *Bitfinex) WsUpdateOrderbook(c *subscription.Subscription, p currency.Pair, assetType asset.Item, book []WebsocketBook, sequenceNo int64, fundingRate bool) error

WsUpdateOrderbook updates the orderbook list, removing and adding to the orderbook sides

type Book

type Book struct {
	OrderID int64
	Price   float64
	Rate    float64
	Period  float64
	Count   int64
	Amount  float64
}

Book holds the orderbook item

type CancelMultiOrderResponse

type CancelMultiOrderResponse struct {
	OrderID           string
	ClientOrderID     string
	GroupOrderID      string
	Symbol            string
	CreatedTime       time.Time
	UpdatedTime       time.Time
	Amount            float64
	OriginalAmount    float64
	OrderType         string
	OriginalOrderType string
	OrderFlags        string
	OrderStatus       string
	Price             float64
	AveragePrice      float64
	TrailingPrice     float64
	AuxLimitPrice     float64
}

CancelMultiOrderResponse holds v2 cancelled order data

type Candle

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

Candle holds OHLC data

type Currency

type Currency struct {
	Currency string  `json:"curr"`
	Volume   float64 `json:"vol,string"`
	Amount   float64 `json:"amount,string"`
}

Currency is a sub-type for AccountSummary data

type Deposit

type Deposit struct {
	Method       string
	CurrencyCode string
	Address      string // Deposit address (instead of the address, this field will show Tag/Memo/Payment_ID for currencies that require it)
	PoolAddress  string // Pool address (for currencies that require a Tag/Memo/Payment_ID)
}

Deposit holds the deposit address info

type DerivativeDataResponse

type DerivativeDataResponse struct {
	Key                  string
	MTS                  float64
	DerivPrice           float64
	SpotPrice            float64
	MarkPrice            float64
	InsuranceFundBalance float64
	NextFundingEventTS   float64
	NextFundingAccrued   float64
	NextFundingStep      float64
	CurrentFunding       float64
	OpenInterest         float64
}

DerivativeDataResponse stores data for queried derivative

type ErrorCapture

type ErrorCapture struct {
	Message string `json:"message"`
}

ErrorCapture is a simple type for returned errors from Bitfinex

type Fee

type Fee struct {
	Currency  string
	TakerFees float64
	MakerFees float64
}

Fee holds fee data for a specified currency

type FundingBook

type FundingBook struct {
	Bids []FundingBookItem `json:"bids"`
	Asks []FundingBookItem `json:"asks"`
}

FundingBook holds current the full margin funding book

type FundingBookItem

type FundingBookItem struct {
	Rate            float64 `json:"rate,string"`
	Amount          float64 `json:"amount,string"`
	Period          int     `json:"period"`
	Timestamp       string  `json:"timestamp"`
	FlashReturnRate string  `json:"frr"`
}

FundingBookItem is a generalised sub-type to hold book information

type GenericResponse

type GenericResponse struct {
	Result string `json:"result"`
}

GenericResponse holds the result for a generic response

type KeyPermissions

type KeyPermissions struct {
	Account   Permission `json:"account"`
	History   Permission `json:"history"`
	Orders    Permission `json:"orders"`
	Positions Permission `json:"positions"`
	Funding   Permission `json:"funding"`
	Wallets   Permission `json:"wallets"`
	Withdraw  Permission `json:"withdraw"`
}

KeyPermissions holds the key permissions for the API key set

type LeaderboardEntry

type LeaderboardEntry struct {
	Timestamp     time.Time
	Username      string
	Ranking       int
	Value         float64
	TwitterHandle string
}

LeaderboardEntry holds leaderboard data

type Lendbook

type Lendbook struct {
	Bids []Book `json:"bids"`
	Asks []Book `json:"asks"`
}

Lendbook holds most recent funding data for a relevant currency

type Lends

type Lends struct {
	Rate       float64 `json:"rate,string"`
	AmountLent float64 `json:"amount_lent,string"`
	AmountUsed float64 `json:"amount_used,string"`
	Timestamp  int64   `json:"timestamp"`
}

Lends holds the lent information by currency

type MarginData

type MarginData struct {
	MarginBalance     float64        `json:"margin_balance,string"`
	TradableBalance   float64        `json:"tradable_balance,string"`
	UnrealizedPL      int64          `json:"unrealized_pl"`
	UnrealizedSwap    int64          `json:"unrealized_swap"`
	NetValue          float64        `json:"net_value,string"`
	RequiredMargin    int64          `json:"required_margin"`
	Leverage          float64        `json:"leverage,string"`
	MarginRequirement float64        `json:"margin_requirement,string"`
	MarginLimits      []MarginLimits `json:"margin_limits"`
}

MarginData holds wallet information for margin trading

type MarginFundingData

type MarginFundingData struct {
	ID          int64
	Symbol      string
	MTSCreated  int64
	MTSUpdated  int64
	Amount      float64
	AmountOrig  float64
	OrderType   string
	OfferStatus string
	Active      string
	Rate        float64
	Period      float64
	Notify      bool
	Renew       bool
}

MarginFundingData stores data for margin funding

type MarginFundingDataV2

type MarginFundingDataV2 struct {
	Sym    string
	Symbol string
	Data   struct {
		YieldLoan    float64
		YieldLend    float64
		DurationLoan float64
		DurationLend float64
	}
}

MarginFundingDataV2 stores margin funding data

type MarginFunds

type MarginFunds struct {
	ID         int64   `json:"id"`
	PositionID int64   `json:"position_id"`
	Currency   string  `json:"currency"`
	Rate       float64 `json:"rate,string"`
	Period     int     `json:"period"`
	Amount     float64 `json:"amount,string"`
	Timestamp  string  `json:"timestamp"`
	AutoClose  bool    `json:"auto_close"`
}

MarginFunds holds active funding information used in a margin position

type MarginInfo

type MarginInfo struct {
	Info    MarginData
	Message string `json:"message"`
}

MarginInfo holds metadata for margin information from bitfinex

type MarginInfoV2

type MarginInfoV2 struct {
	Symbol          string
	UserPNL         float64
	UserSwaps       float64
	MarginBalance   float64
	MarginNet       float64
	MarginMin       float64
	TradableBalance float64
	GrossBalance    float64
	BestAskAmount   float64
	BestBidAmount   float64
}

MarginInfoV2 stores V2 margin data

type MarginLimits

type MarginLimits struct {
	OnPair            string  `json:"on_pair"`
	InitialMargin     float64 `json:"initial_margin,string"`
	MarginRequirement float64 `json:"margin_requirement,string"`
	TradableBalance   float64 `json:"tradable_balance,string"`
}

MarginLimits holds limit data per pair

type MarginTotalTakenFunds

type MarginTotalTakenFunds struct {
	PositionPair string  `json:"position_pair"`
	TotalSwaps   float64 `json:"total_swaps,string"`
}

MarginTotalTakenFunds holds position funding including sum of active backing as total swaps

type MarginV2FundingData

type MarginV2FundingData struct {
	Symbol        string
	RateAverage   float64
	AmountAverage float64
}

MarginV2FundingData stores margin funding data

type MovementHistory

type MovementHistory struct {
	ID               int64   `json:"id"`
	TxID             string  `json:"txid"`
	Currency         string  `json:"currency"`
	Method           string  `json:"method"`
	Type             string  `json:"withdrawal"`
	Amount           float64 `json:"amount,string"`
	Description      string  `json:"description"`
	Address          string  `json:"address"`
	Status           string  `json:"status"`
	Timestamp        float64 `json:"timestamp"`
	TimestampCreated float64 `json:"timestamp_created"`
	Fee              float64 `json:"fee"`
}

MovementHistory holds deposit and withdrawal history data

type Offer

type Offer struct {
	ID              int64   `json:"id"`
	Currency        string  `json:"currency"`
	Rate            float64 `json:"rate,string"`
	Period          int64   `json:"period"`
	Direction       string  `json:"direction"`
	Timestamp       string  `json:"timestamp"`
	Type            string  `json:"type"`
	IsLive          bool    `json:"is_live"`
	IsCancelled     bool    `json:"is_cancelled"`
	OriginalAmount  float64 `json:"original_amount,string"`
	RemainingAmount float64 `json:"remaining_amount,string"`
	ExecutedAmount  float64 `json:"executed_amount,string"`
}

Offer holds offer information

type Order

type Order struct {
	ID                    int64   `json:"id"`
	Symbol                string  `json:"symbol"`
	Exchange              string  `json:"exchange"`
	Price                 float64 `json:"price,string"`
	AverageExecutionPrice float64 `json:"avg_execution_price,string"`
	Side                  string  `json:"side"`
	Type                  string  `json:"type"`
	Timestamp             string  `json:"timestamp"`
	IsLive                bool    `json:"is_live"`
	IsCancelled           bool    `json:"is_cancelled"`
	IsHidden              bool    `json:"is_hidden"`
	WasForced             bool    `json:"was_forced"`
	OriginalAmount        float64 `json:"original_amount,string"`
	RemainingAmount       float64 `json:"remaining_amount,string"`
	ExecutedAmount        float64 `json:"executed_amount,string"`
	OrderID               int64   `json:"order_id,omitempty"`
}

Order holds order information when an order is in the market

type OrderMultiResponse

type OrderMultiResponse struct {
	Orders []Order `json:"order_ids"`
	Status string  `json:"status"`
}

OrderMultiResponse holds order information on the executed orders

type Orderbook

type Orderbook struct {
	Bids []Book
	Asks []Book
}

Orderbook holds orderbook information from bid and ask sides

type Permission

type Permission struct {
	Read  bool `json:"read"`
	Write bool `json:"write"`
}

Permission sub-type for KeyPermissions

type PlaceOrder

type PlaceOrder struct {
	Symbol   string  `json:"symbol"`
	Amount   float64 `json:"amount,string"`
	Price    float64 `json:"price,string"`
	Exchange string  `json:"exchange"`
	Side     string  `json:"side"`
	Type     string  `json:"type"`
}

PlaceOrder is used for order placement

type Position

type Position struct {
	ID        int64   `json:"id"`
	Symbol    string  `json:"string"`
	Status    string  `json:"active"`
	Base      float64 `json:"base,string"`
	Amount    float64 `json:"amount,string"`
	Timestamp string  `json:"timestamp"`
	Swap      float64 `json:"swap,string"`
	PL        float64 `json:"pl,string"`
}

Position holds position information

type RateLimit

type RateLimit struct {
	PlatformStatus       *rate.Limiter
	TickerBatch          *rate.Limiter
	Ticker               *rate.Limiter
	Trade                *rate.Limiter
	Orderbook            *rate.Limiter
	Stats                *rate.Limiter
	Candle               *rate.Limiter
	Configs              *rate.Limiter
	Status               *rate.Limiter
	Liquid               *rate.Limiter
	LeaderBoard          *rate.Limiter
	MarketAveragePrice   *rate.Limiter
	Fx                   *rate.Limiter
	AccountWalletBalance *rate.Limiter
	AccountWalletHistory *rate.Limiter
	// Orders -
	RetrieveOrder  *rate.Limiter
	SubmitOrder    *rate.Limiter
	UpdateOrder    *rate.Limiter
	CancelOrder    *rate.Limiter
	OrderBatch     *rate.Limiter
	CancelBatch    *rate.Limiter
	OrderHistory   *rate.Limiter
	GetOrderTrades *rate.Limiter
	GetTrades      *rate.Limiter
	GetLedgers     *rate.Limiter
	// Positions -
	GetAccountMarginInfo       *rate.Limiter
	GetActivePositions         *rate.Limiter
	ClaimPosition              *rate.Limiter
	GetPositionHistory         *rate.Limiter
	GetPositionAudit           *rate.Limiter
	UpdateCollateralOnPosition *rate.Limiter
	// Margin funding -
	GetActiveFundingOffers   *rate.Limiter
	SubmitFundingOffer       *rate.Limiter
	CancelFundingOffer       *rate.Limiter
	CancelAllFundingOffer    *rate.Limiter
	CloseFunding             *rate.Limiter
	FundingAutoRenew         *rate.Limiter
	KeepFunding              *rate.Limiter
	GetOffersHistory         *rate.Limiter
	GetFundingLoans          *rate.Limiter
	GetFundingLoanHistory    *rate.Limiter
	GetFundingCredits        *rate.Limiter
	GetFundingCreditsHistory *rate.Limiter
	GetFundingTrades         *rate.Limiter
	GetFundingInfo           *rate.Limiter
	// Account actions
	GetUserInfo               *rate.Limiter
	TransferBetweenWallets    *rate.Limiter
	GetDepositAddress         *rate.Limiter
	Withdrawal                *rate.Limiter
	GetMovements              *rate.Limiter
	GetAlertList              *rate.Limiter
	SetPriceAlert             *rate.Limiter
	DeletePriceAlert          *rate.Limiter
	GetBalanceForOrdersOffers *rate.Limiter
	UserSettingsWrite         *rate.Limiter
	UserSettingsRead          *rate.Limiter
	UserSettingsDelete        *rate.Limiter
	// Account V1 endpoints
	GetAccountFees    *rate.Limiter
	GetWithdrawalFees *rate.Limiter
	GetAccountSummary *rate.Limiter
	NewDepositAddress *rate.Limiter
	GetKeyPermissions *rate.Limiter
	GetMarginInfo     *rate.Limiter
	GetAccountBalance *rate.Limiter
	WalletTransfer    *rate.Limiter
	WithdrawV1        *rate.Limiter
	OrderV1           *rate.Limiter
	OrderMulti        *rate.Limiter
	StatsV1           *rate.Limiter
	Fundingbook       *rate.Limiter
	Lends             *rate.Limiter
}

RateLimit implements the rate.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

Limit limits outbound requests

type Stat

type Stat struct {
	Period int64   `json:"period"`
	Volume float64 `json:"volume,string"`
}

Stat holds individual statistics from exchange

type Ticker

type Ticker struct {
	FlashReturnRate    float64
	Bid                float64
	BidPeriod          int64
	BidSize            float64
	Ask                float64
	AskPeriod          int64
	AskSize            float64
	DailyChange        float64
	DailyChangePerc    float64
	Last               float64
	Volume             float64
	High               float64
	Low                float64
	FFRAmountAvailable float64
}

Ticker holds ticker information

type Trade

type Trade struct {
	Timestamp int64
	TID       int64
	Price     float64
	Amount    float64
	Exchange  string
	Rate      float64
	Period    int64
	Type      string
	Side      order.Side
}

Trade holds resp information

type TradeHistory

type TradeHistory struct {
	Price       float64 `json:"price,string"`
	Amount      float64 `json:"amount,string"`
	Timestamp   int64   `json:"timestamp"`
	Exchange    string  `json:"exchange"`
	Type        string  `json:"type"`
	FeeCurrency string  `json:"fee_currency"`
	FeeAmount   float64 `json:"fee_amount,string"`
	TID         int64   `json:"tid"`
	OrderID     int64   `json:"order_id"`
}

TradeHistory holds trade history data

type WalletDataV2

type WalletDataV2 struct {
	WalletType        string
	Currency          string
	Balance           float64
	UnsettledInterest float64
}

WalletDataV2 stores wallet data for v2

type WalletTransfer

type WalletTransfer struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

WalletTransfer holds status of wallet to wallet content transfer on exchange

type WebsocketBook

type WebsocketBook struct {
	ID     int64
	Price  float64
	Amount float64
	Period int64
}

WebsocketBook holds booking information

type WebsocketHandshake

type WebsocketHandshake struct {
	Event   string  `json:"event"`
	Code    int64   `json:"code"`
	Version float64 `json:"version"`
}

WebsocketHandshake defines the communication between the websocket API for initial connection

type WebsocketOrder

type WebsocketOrder struct {
	OrderID    int64
	Pair       string
	Amount     float64
	OrigAmount float64
	OrderType  string
	Status     string
	Price      float64
	PriceAvg   float64
	Timestamp  int64
	Notify     int
}

WebsocketOrder holds order data

type WebsocketPosition

type WebsocketPosition struct {
	Pair              string
	Status            string
	Amount            float64
	Price             float64
	MarginFunding     float64
	MarginFundingType int64
	ProfitLoss        float64
	ProfitLossPercent float64
	LiquidationPrice  float64
	Leverage          float64
}

WebsocketPosition holds position information

type WebsocketTicker

type WebsocketTicker struct {
	Bid             float64
	BidSize         float64
	Ask             float64
	AskSize         float64
	DailyChange     float64
	DialyChangePerc float64
	LastPrice       float64
	Volume          float64
}

WebsocketTicker holds ticker information

type WebsocketTrade

type WebsocketTrade struct {
	ID        int64
	Timestamp int64
	Price     float64
	Amount    float64
	// Funding rate of the trade
	Rate float64
	// Funding offer period in days
	Period int64
}

WebsocketTrade holds trade information

type WebsocketTradeData

type WebsocketTradeData struct {
	TradeID        int64
	Pair           string
	Timestamp      int64
	OrderID        int64
	AmountExecuted float64
	PriceExecuted  float64
	OrderType      string
	OrderPrice     float64
	Maker          bool
	Fee            float64
	FeeCurrency    string
}

WebsocketTradeData holds executed trade data

type WebsocketTradeExecuted

type WebsocketTradeExecuted struct {
	TradeID        int64
	Pair           string
	Timestamp      int64
	OrderID        int64
	AmountExecuted float64
	PriceExecuted  float64
}

WebsocketTradeExecuted holds executed trade data

type WebsocketWallet

type WebsocketWallet struct {
	Name              string
	Currency          string
	Balance           float64
	UnsettledInterest float64
}

WebsocketWallet holds wallet information

type Withdrawal

type Withdrawal struct {
	Status       string  `json:"status"`
	Message      string  `json:"message"`
	WithdrawalID int64   `json:"withdrawal_id"`
	Fees         string  `json:"fees"`
	WalletType   string  `json:"wallettype"`
	Method       string  `json:"method"`
	Address      string  `json:"address"`
	Invoice      string  `json:"invoice"`
	PaymentID    string  `json:"payment_id"`
	Amount       float64 `json:"amount,string"`
}

Withdrawal holds withdrawal status information

type WsAuthRequest

type WsAuthRequest struct {
	Event         string `json:"event"`
	APIKey        string `json:"apiKey"`
	AuthPayload   string `json:"authPayload"`
	AuthSig       string `json:"authSig"`
	AuthNonce     string `json:"authNonce"`
	DeadManSwitch int64  `json:"dms,omitempty"`
}

WsAuthRequest container for WS auth request

type WsBalanceInfo

type WsBalanceInfo struct {
	TotalAssetsUnderManagement float64
	NetAssetsUnderManagement   float64
}

WsBalanceInfo the total and net assets in your account received via websocket

type WsCancelAllOrdersRequest

type WsCancelAllOrdersRequest struct {
	All int64 `json:"all"`
}

WsCancelAllOrdersRequest cancel all orders request

type WsCancelGroupOrdersRequest

type WsCancelGroupOrdersRequest struct {
	OrderID      []int64   `json:"id,omitempty"`
	CustomID     [][]int64 `json:"cid,omitempty"`
	GroupOrderID []int64   `json:"gid,omitempty"`
}

WsCancelGroupOrdersRequest cancel orders request...

type WsCancelOfferRequest

type WsCancelOfferRequest struct {
	OrderID int64 `json:"id"`
}

WsCancelOfferRequest cancel offer request

type WsCancelOrderRequest

type WsCancelOrderRequest struct {
	OrderID      int64  `json:"id,omitempty"`
	CustomID     int64  `json:"cid,omitempty"`
	CustomIDDate string `json:"cid_date,omitempty"`
}

WsCancelOrderRequest cancel order request...

type WsCredit

type WsCredit struct {
	ID           int64
	Symbol       string
	Side         int8 // 1 if you are the lender, 0 if you are both the lender and borrower, -1 if you're the borrower
	Created      time.Time
	Updated      time.Time
	Amount       float64
	Flags        interface{} // Future params object (stay tuned)
	Status       string
	Rate         float64
	Period       int64
	Opened       time.Time
	LastPayout   time.Time
	Notify       bool
	Hidden       bool
	Renew        bool
	RateReal     float64
	NoClose      bool
	PositionPair string
}

WsCredit credit details received via websocket

type WsFundingInfo

type WsFundingInfo struct {
	Symbol       string
	YieldLoan    float64
	YieldLend    float64
	DurationLoan float64
	DurationLend float64
}

WsFundingInfo account funding info received via websocket

type WsFundingOffer

type WsFundingOffer struct {
	ID             int64
	Symbol         string
	Created        time.Time
	Updated        time.Time
	Amount         float64
	OriginalAmount float64
	Type           string
	Flags          interface{}
	Status         string
	Rate           float64
	Period         int64
	Notify         bool
	Hidden         bool
	Insure         bool
	Renew          bool
	RateReal       float64
}

WsFundingOffer funding offer received via websocket

type WsFundingTrade

type WsFundingTrade struct {
	ID         int64
	Symbol     string
	MTSCreated time.Time
	OfferID    int64
	Amount     float64
	Rate       float64
	Period     int64
	Maker      bool
}

WsFundingTrade recent funding trades received via websocket

type WsMarginInfoBase

type WsMarginInfoBase struct {
	UserProfitLoss float64
	UserSwaps      float64
	MarginBalance  float64
	MarginNet      float64
	MarginRequired float64
}

WsMarginInfoBase account margin info received via websocket

type WsNewOfferRequest

type WsNewOfferRequest struct {
	Type   string  `json:"type,omitempty"`
	Symbol string  `json:"symbol,omitempty"`
	Amount float64 `json:"amount,string,omitempty"`
	Rate   float64 `json:"rate,string,omitempty"`
	Period float64 `json:"period,omitempty"`
	Flags  int64   `json:"flags,omitempty"`
}

WsNewOfferRequest new offer request

type WsNewOrderRequest

type WsNewOrderRequest struct {
	GroupID             int64   `json:"gid,omitempty"`
	CustomID            int64   `json:"cid,omitempty"`
	Type                string  `json:"type"`
	Symbol              string  `json:"symbol"`
	Amount              float64 `json:"amount,string"`
	Price               float64 `json:"price,string"`
	Leverage            int64   `json:"lev,omitempty"`
	TrailingPrice       float64 `json:"price_trailing,string,omitempty"`
	AuxiliaryLimitPrice float64 `json:"price_aux_limit,string,omitempty"`
	StopPrice           float64 `json:"price_oco_stop,string,omitempty"`
	Flags               int64   `json:"flags,omitempty"`
	TimeInForce         string  `json:"tif,omitempty"`
}

WsNewOrderRequest new order request...

type WsUpdateOrderRequest

type WsUpdateOrderRequest struct {
	OrderID             int64   `json:"id,omitempty"`
	CustomID            int64   `json:"cid,omitempty"`
	CustomIDDate        string  `json:"cid_date,omitempty"`
	GroupID             int64   `json:"gid,omitempty"`
	Price               float64 `json:"price,string,omitempty"`
	Amount              float64 `json:"amount,string,omitempty"`
	Leverage            int64   `json:"lev,omitempty"`
	Delta               float64 `json:"delta,string,omitempty"`
	AuxiliaryLimitPrice float64 `json:"price_aux_limit,string,omitempty"`
	TrailingPrice       float64 `json:"price_trailing,string,omitempty"`
	Flags               int64   `json:"flags,omitempty"`
	TimeInForce         string  `json:"tif,omitempty"`
}

WsUpdateOrderRequest update order request...

type WsWallet

type WsWallet struct {
	Type              string
	Currency          string
	Balance           float64
	UnsettledInterest float64
	BalanceAvailable  float64
}

WsWallet wallet update details received via websocket

Jump to

Keyboard shortcuts

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