bitfinex

package
v0.0.0-...-eb07c7e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 18 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 progresss 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.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.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 := 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:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeIntervalMinute         = TimeInterval("1m")
	TimeIntervalFiveMinutes    = TimeInterval("5m")
	TimeIntervalFifteenMinutes = TimeInterval("15m")
	TimeIntervalThirtyMinutes  = TimeInterval("30m")
	TimeIntervalHour           = TimeInterval("1h")
	TimeIntervalThreeHours     = TimeInterval("3h")
	TimeIntervalSixHours       = TimeInterval("6h")
	TimeIntervalTwelveHours    = TimeInterval("12h")
	TimeIntervalDay            = TimeInterval("1d")
	TimeIntervalSevenDays      = TimeInterval("7d")
	TimeIntervalFourteenDays   = TimeInterval("14d")
	TimeIntervalMonth          = TimeInterval("1M")
)

TimeInvterval vars

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 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
	WebsocketConn         *websocket.Conn
	WebsocketSubdChannels map[int]WebsocketChanInfo
	// contains filtered or unexported fields
}

Bitfinex is the overarching type across the bitfinex package Notes: Bitfinex has added a rate limit to the number of REST requests. Rate limit policy can vary in a range of 10 to 90 requests per minute depending on some factors (e.g. servers load, endpoint, etc.).

func (*Bitfinex) AuthenticateWebsocket

func (b *Bitfinex) AuthenticateWebsocket() error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Bitfinex) CalculateTradingFee

func (b *Bitfinex) CalculateTradingFee(accountInfos []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() (string, error)

CancelAllExistingOrders cancels all active and open orders

func (*Bitfinex) CancelAllOrders

CancelAllOrders cancels all orders associated with a currency pair

func (*Bitfinex) CancelExistingOrder

func (b *Bitfinex) CancelExistingOrder(orderID int64) (Order, error)

CancelExistingOrder cancels a single order by OrderID

func (*Bitfinex) CancelMultipleOrders

func (b *Bitfinex) CancelMultipleOrders(orderIDs []int64) (string, error)

CancelMultipleOrders cancels multiple orders

func (*Bitfinex) CancelOffer

func (b *Bitfinex) CancelOffer(offerID int64) (Offer, error)

CancelOffer cancels offer by offerID

func (*Bitfinex) CancelOrder

func (b *Bitfinex) CancelOrder(order *exchange.OrderCancellation) error

CancelOrder cancels an order by its corresponding ID number

func (*Bitfinex) ClaimPosition

func (b *Bitfinex) ClaimPosition(positionID int) (Position, error)

ClaimPosition allows positions to be claimed

func (*Bitfinex) CloseMarginFunding

func (b *Bitfinex) CloseMarginFunding(swapID int64) (Offer, error)

CloseMarginFunding closes an unused or used taken fund

func (*Bitfinex) ConvertSymbolToDepositMethod

func (b *Bitfinex) ConvertSymbolToDepositMethod(c currency.Code) (method string, err error)

ConvertSymbolToDepositMethod returns a converted currency deposit method

func (*Bitfinex) ConvertSymbolToWithdrawalType

func (b *Bitfinex) ConvertSymbolToWithdrawalType(c currency.Code) string

ConvertSymbolToWithdrawalType You need to have specific withdrawal types to withdraw from Bitfinex

func (*Bitfinex) GenerateDefaultSubscriptions

func (b *Bitfinex) GenerateDefaultSubscriptions()

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

func (*Bitfinex) GetAccountBalance

func (b *Bitfinex) GetAccountBalance() ([]Balance, error)

GetAccountBalance returns full wallet balance information

func (*Bitfinex) GetAccountFees

func (b *Bitfinex) GetAccountFees() (AccountFees, error)

GetAccountFees - Gets all fee rates for all currencies

func (*Bitfinex) GetAccountInfo

func (b *Bitfinex) GetAccountInfo() (exchange.AccountInfo, error)

GetAccountInfo retrieves balances for all enabled currencies on the Bitfinex exchange

func (*Bitfinex) GetAccountInformation

func (b *Bitfinex) GetAccountInformation() ([]AccountInfo, error)

GetAccountInformation returns information about your account incl. trading fees

func (*Bitfinex) GetAccountSummary

func (b *Bitfinex) GetAccountSummary() (AccountSummary, error)

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

func (*Bitfinex) GetActiveCredits

func (b *Bitfinex) GetActiveCredits() ([]Offer, error)

GetActiveCredits returns all available credits

func (*Bitfinex) GetActiveMarginFunding

func (b *Bitfinex) GetActiveMarginFunding() ([]MarginFunds, error)

GetActiveMarginFunding returns an array of active margin funds

func (*Bitfinex) GetActiveOffers

func (b *Bitfinex) GetActiveOffers() ([]Offer, error)

GetActiveOffers returns all current active offers

func (*Bitfinex) GetActiveOrders

func (b *Bitfinex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Bitfinex) GetActivePositions

func (b *Bitfinex) GetActivePositions() ([]Position, error)

GetActivePositions returns an array of active positions

func (*Bitfinex) GetBalanceHistory

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

GetBalanceHistory returns balance history for the account

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) GetDepositAddress

func (b *Bitfinex) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Bitfinex) GetExchangeHistory

func (b *Bitfinex) GetExchangeHistory(p currency.Pair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Bitfinex) GetFee

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

GetFee returns an estimate of fee based on type of transaction

func (*Bitfinex) GetFeeByType

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

GetFeeByType returns an estimate of fee based on type of transaction

func (*Bitfinex) GetFundingBook

func (b *Bitfinex) GetFundingBook(symbol string) (FundingBook, error)

GetFundingBook the entire margin funding book for both bids and asks sides per currency string symbol - example "USD"

func (*Bitfinex) GetFundingHistory

func (b *Bitfinex) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Bitfinex) GetInactiveOrders

func (b *Bitfinex) GetInactiveOrders() ([]Order, error)

GetInactiveOrders returns order status information

func (*Bitfinex) GetKeyPermissions

func (b *Bitfinex) GetKeyPermissions() (KeyPermissions, error)

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

func (*Bitfinex) GetLatestSpotPrice

func (b *Bitfinex) GetLatestSpotPrice(symbol string) (float64, error)

GetLatestSpotPrice returns latest spot price of symbol

symbol: string of currency pair

func (*Bitfinex) GetLendbook

func (b *Bitfinex) GetLendbook(symbol string, values url.Values) (Lendbook, error)

GetLendbook 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) GetLends

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

func (b *Bitfinex) GetMarginInfo() ([]MarginInfo, error)

GetMarginInfo shows your trading wallet information for margin trading

func (*Bitfinex) GetMarginTotalTakenFunds

func (b *Bitfinex) GetMarginTotalTakenFunds() ([]MarginTotalTakenFunds, error)

GetMarginTotalTakenFunds returns an array of active funding used in a position

func (*Bitfinex) GetMovementHistory

func (b *Bitfinex) GetMovementHistory(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(offerID int64) (Offer, error)

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

func (*Bitfinex) GetOpenOrders

func (b *Bitfinex) GetOpenOrders() ([]Order, error)

GetOpenOrders returns all active orders and statuses

func (*Bitfinex) GetOrderHistory

func (b *Bitfinex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

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

func (*Bitfinex) GetOrderInfo

func (b *Bitfinex) GetOrderInfo(orderID string) (exchange.OrderDetail, error)

GetOrderInfo returns information on a current open order

func (*Bitfinex) GetOrderStatus

func (b *Bitfinex) GetOrderStatus(orderID int64) (Order, error)

GetOrderStatus returns order status information

func (*Bitfinex) GetOrderbook

func (b *Bitfinex) GetOrderbook(currencyPair string, values url.Values) (Orderbook, error)

GetOrderbook retieves the orderbook bid and ask price points for a currency pair - By default the response will return 25 bid and 25 ask price points. CurrencyPair - Example "BTCUSD" Values can contain limit amounts for both the asks and bids - Example "limit_bids" = 1000

func (*Bitfinex) GetOrderbookEx

func (b *Bitfinex) GetOrderbookEx(p currency.Pair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns the orderbook for a currency pair

func (*Bitfinex) GetOrderbookV2

func (b *Bitfinex) GetOrderbookV2(symbol, precision string, values url.Values) (OrderbookV2, error)

GetOrderbookV2 retieves 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" = 1000

func (*Bitfinex) GetPlatformStatus

func (b *Bitfinex) GetPlatformStatus() (int, error)

GetPlatformStatus returns the Bifinex platform status

func (*Bitfinex) GetStats

func (b *Bitfinex) GetStats(symbol string) ([]Stat, error)

GetStats returns various statistics about the requested pair

func (*Bitfinex) GetSubscriptions

func (b *Bitfinex) GetSubscriptions() ([]exchange.WebsocketChannelSubscription, error)

GetSubscriptions returns a copied list of subscriptions

func (*Bitfinex) GetSymbols

func (b *Bitfinex) GetSymbols() ([]string, error)

GetSymbols returns the available currency pairs on the exchange

func (*Bitfinex) GetSymbolsDetails

func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error)

GetSymbolsDetails a list of valid symbol IDs and the pair details

func (*Bitfinex) GetTicker

func (b *Bitfinex) GetTicker(symbol string) (Ticker, error)

GetTicker returns ticker information

func (*Bitfinex) GetTickerPrice

func (b *Bitfinex) GetTickerPrice(p currency.Pair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Bitfinex) GetTickerV2

func (b *Bitfinex) GetTickerV2(symb string) (Tickerv2, error)

GetTickerV2 returns ticker information

func (*Bitfinex) GetTickersV2

func (b *Bitfinex) GetTickersV2(symbols string) ([]Tickersv2, error)

GetTickersV2 returns ticker information for multiple symbols

func (*Bitfinex) GetTradeHistory

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

GetTradeHistory returns past executed trades

func (*Bitfinex) GetTrades

func (b *Bitfinex) GetTrades(currencyPair string, values url.Values) ([]TradeStructure, error)

GetTrades returns a list of the most recent trades for the given curencyPair By default the response will return 100 trades CurrencyPair - Example "BTCUSD" Values can contain limit amounts for the number of trades returned - Example "limit_trades" = 1000

func (*Bitfinex) GetTradesV2

func (b *Bitfinex) GetTradesV2(currencyPair string, timestampStart, timestampEnd int64, reOrderResp bool) ([]TradeStructureV2, error)

GetTradesV2 uses the V2 API to get historic trades that occurred on the exchange

currencyPair e.g. "tBTCUSD" v2 prefixes currency pairs with t. (?) timestampStart is an int64 unix epoch time timestampEnd is an int64 unix epoch time, make sure this is always there or you will get the most recent trades. reOrderResp reorders the returned data.

func (*Bitfinex) GetUnusedMarginFunds

func (b *Bitfinex) GetUnusedMarginFunds() ([]MarginFunds, error)

GetUnusedMarginFunds returns an array of funding borrowed but not currently used

func (*Bitfinex) GetWebsocket

func (b *Bitfinex) GetWebsocket() (*exchange.Websocket, error)

GetWebsocket returns a pointer to the exchange websocket

func (*Bitfinex) ModifyOrder

func (b *Bitfinex) ModifyOrder(action *exchange.ModifyOrder) (string, error)

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

func (*Bitfinex) NewDeposit

func (b *Bitfinex) NewDeposit(method, walletName string, renew int) (DepositResponse, error)

NewDeposit returns a new deposit address Method - Example methods accepted: “bitcoin”, “litecoin”, “ethereum”, “tethers", "ethereumc", "zcash", "monero", "iota", "bcash" WalletName - accepted: “trading”, “exchange”, “deposit” renew - Default is 0. If set to 1, will return a new unused deposit address

func (*Bitfinex) NewOffer

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

NewOffer submits a new offer

func (*Bitfinex) NewOrder

func (b *Bitfinex) NewOrder(currencyPair string, amount, price float64, buy bool, orderType string, 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(orders []PlaceOrder) (OrderMultiResponse, error)

NewOrderMulti allows several new orders at once

func (*Bitfinex) ReplaceOrder

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

func (b *Bitfinex) Run()

Run implements the Bitfinex wrapper

func (*Bitfinex) SendAuthenticatedHTTPRequest

func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[string]interface{}, result interface{}) error

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

func (*Bitfinex) SendHTTPRequest

func (b *Bitfinex) SendHTTPRequest(path string, result interface{}, verbose bool) 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.ExchangeConfig)

Setup takes in the supplied exchange configuration details and sets params

func (*Bitfinex) Start

func (b *Bitfinex) Start(wg *sync.WaitGroup)

Start starts the Bitfinex go routine

func (*Bitfinex) SubmitOrder

func (b *Bitfinex) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error)

SubmitOrder submits a new order

func (*Bitfinex) Subscribe

func (b *Bitfinex) Subscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Bitfinex) SubscribeToWebsocketChannels

func (b *Bitfinex) SubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

SubscribeToWebsocketChannels appends to ChannelsToSubscribe which lets websocket.manageSubscriptions handle subscribing

func (*Bitfinex) Unsubscribe

func (b *Bitfinex) Unsubscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*Bitfinex) UnsubscribeToWebsocketChannels

func (b *Bitfinex) UnsubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

UnsubscribeToWebsocketChannels removes from ChannelsToSubscribe which lets websocket.manageSubscriptions handle unsubscribing

func (*Bitfinex) UpdateOrderbook

func (b *Bitfinex) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bitfinex) UpdateTicker

func (b *Bitfinex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Bitfinex) WalletTransfer

func (b *Bitfinex) WalletTransfer(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(withdrawType, wallet, address, paymentID string, amount float64, c currency.Code) ([]Withdrawal, error)

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

func (*Bitfinex) WithdrawCryptocurrencyFunds

func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bitfinex) WithdrawFIAT

func (b *Bitfinex) WithdrawFIAT(withdrawalType, walletType string, withdrawRequest *exchange.WithdrawRequest) ([]Withdrawal, error)

WithdrawFIAT Sends an authenticated request to withdraw FIAT currency

func (*Bitfinex) WithdrawFiatFunds

func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

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

func (*Bitfinex) WithdrawFiatFundsToInternationalBank

func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error)

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

func (*Bitfinex) WsAddSubscriptionChannel

func (b *Bitfinex) WsAddSubscriptionChannel(chanID int, channel, pair string)

WsAddSubscriptionChannel adds a new subscription channel to the WebsocketSubdChannels map in bitfinex.go (Bitfinex struct)

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 string, books []WebsocketBook) error

WsInsertSnapshot add the initial orderbook snapshot when subscribed to a channel

func (*Bitfinex) WsPingHandler

func (b *Bitfinex) WsPingHandler() error

WsPingHandler sends a ping request to the websocket server

func (*Bitfinex) WsReadData

func (b *Bitfinex) WsReadData() (exchange.WebsocketResponse, error)

WsReadData reads and handles websocket stream data

func (*Bitfinex) WsSendAuth

func (b *Bitfinex) WsSendAuth() error

WsSendAuth sends a autheticated event payload

func (*Bitfinex) WsSendUnauth

func (b *Bitfinex) WsSendUnauth() error

WsSendUnauth sends an unauthenticated payload

func (*Bitfinex) WsUpdateOrderbook

func (b *Bitfinex) WsUpdateOrderbook(p currency.Pair, assetType string, book WebsocketBook) error

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

type Book

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

Book is a generalised sub-type to hold book information

type BookV2

type BookV2 struct {
	Price  float64
	Rate   float64
	Period float64
	Count  int64
	Amount float64
}

BookV2 holds the orderbook item

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 DepositResponse

type DepositResponse struct {
	Result   string `json:"string"`
	Method   string `json:"method"`
	Currency string `json:"currency"`
	Address  string `json:"address"`
}

DepositResponse holds deposit address information

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    []Book `json:"bids"`
	Asks    []Book `json:"asks"`
	Message string `json:"message"`
}

FundingBook holds current the full margin funding book

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 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 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 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 MovementHistory

type MovementHistory struct {
	ID               int64   `json:"id"`
	TxID             int64   `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        string  `json:"timestamp"`
	TimestampCreated string  `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 OrderbookV2

type OrderbookV2 struct {
	Bids []BookV2
	Asks []BookV2
}

OrderbookV2 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 Stat

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

Stat holds individual statistics from exchange

type SymbolDetails

type SymbolDetails struct {
	Pair             string  `json:"pair"`
	PricePrecision   int     `json:"price_precision"`
	InitialMargin    float64 `json:"initial_margin,string"`
	MinimumMargin    float64 `json:"minimum_margin,string"`
	MaximumOrderSize float64 `json:"maximum_order_size,string"`
	MinimumOrderSize float64 `json:"minimum_order_size,string"`
	Expiration       string  `json:"expiration"`
}

SymbolDetails holds currency pair information

type Ticker

type Ticker struct {
	Mid       float64 `json:"mid,string"`
	Bid       float64 `json:"bid,string"`
	Ask       float64 `json:"ask,string"`
	Last      float64 `json:"last_price,string"`
	Low       float64 `json:"low,string"`
	High      float64 `json:"high,string"`
	Volume    float64 `json:"volume,string"`
	Timestamp string  `json:"timestamp"`
	Message   string  `json:"message"`
}

Ticker holds basic ticker information from the exchange

type Tickersv2

type Tickersv2 struct {
	Symbol string
	Tickerv2
}

Tickersv2 holds the version 2 tickers information

type Tickerv2

type Tickerv2 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
}

Tickerv2 holds the version 2 ticker information

type TimeInterval

type TimeInterval string

TimeInterval represents interval enum.

type TradeHistory

type TradeHistory struct {
	Price       float64 `json:"price,string"`
	Amount      float64 `json:"amount,string"`
	Timestamp   string  `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 TradeStructure

type TradeStructure struct {
	Timestamp int64   `json:"timestamp"`
	Tid       int64   `json:"tid"`
	Price     float64 `json:"price,string"`
	Amount    float64 `json:"amount,string"`
	Exchange  string  `json:"exchange"`
	Type      string  `json:"sell"`
}

TradeStructure holds executed trade information

type TradeStructureV2

type TradeStructureV2 struct {
	Timestamp int64
	TID       int64
	Price     float64
	Amount    float64
	Exchange  string
	Type      string
}

TradeStructureV2 holds resp information

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 {
	Price  float64
	Count  int
	Amount float64
}

WebsocketBook holds booking information

type WebsocketChanInfo

type WebsocketChanInfo struct {
	Channel string
	Pair    string
}

WebsocketChanInfo holds websocket channel 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  string
	Notify     int
}

WebsocketOrder holds order data

type WebsocketPosition

type WebsocketPosition struct {
	Pair              string
	Status            string
	Amount            float64
	Price             float64
	MarginFunding     float64
	MarginFundingType int
}

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
}

WebsocketTrade holds trade information

type WebsocketTradeData

type WebsocketTradeData struct {
	TradeID        int64
	Pair           string
	Timestamp      int64
	OrderID        int64
	AmountExecuted float64
	PriceExecuted  float64
	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,omitempty"`
	Fees         string `json:"fees,omitempty"`
}

Withdrawal holds withdrawal status information

Jump to

Keyboard shortcuts

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