rest

package
v0.0.0-...-5d5b4e6 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DERIV_TYPE = "deriv"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BookService

type BookService struct {
	Synchronous
}

func (*BookService) All

func (b *BookService) All(symbol string, precision bitfinex.BookPrecision, priceLevels int) (*bitfinex.BookUpdateSnapshot, error)

type CandleService

type CandleService struct {
	Synchronous
}

CandleService manages the Candles endpoint.

func (*CandleService) History

func (c *CandleService) History(symbol string, resolution bitfinex.CandleResolution) (*bitfinex.CandleSnapshot, error)

Return Candles for the public account.

func (*CandleService) HistoryWithQuery

func (c *CandleService) HistoryWithQuery(
	symbol string,
	resolution bitfinex.CandleResolution,
	start bitfinex.Mts,
	end bitfinex.Mts,
	limit bitfinex.QueryLimit,
	sort bitfinex.SortOrder,
) (*bitfinex.CandleSnapshot, error)

Return Candles for the public account.

func (*CandleService) Last

func (c *CandleService) Last(symbol string, resolution bitfinex.CandleResolution) (*bitfinex.Candle, error)

Return Candles for the public account.

type Client

type Client struct {

	// service providers
	Candles     CandleService
	Orders      OrderService
	Positions   PositionService
	Trades      TradeService
	Tickers     TickerService
	Currencies  CurrenciesService
	Platform    PlatformService
	Book        BookService
	Wallet      WalletService
	Ledgers     LedgerService
	Stats       StatsService
	Status      StatusService
	Derivatives DerivativesService

	Synchronous
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func NewClientWithHttpDo

func NewClientWithHttpDo(httpDo func(c *http.Client, r *http.Request) (*http.Response, error)) *Client

func NewClientWithSynchronousNonce

func NewClientWithSynchronousNonce(sync Synchronous, nonce utils.NonceGenerator) *Client

func NewClientWithSynchronousURLNonce

func NewClientWithSynchronousURLNonce(sync Synchronous, url string, nonce utils.NonceGenerator) *Client

mock me in tests

func NewClientWithURL

func NewClientWithURL(url string) *Client

func NewClientWithURLHttpDo

func NewClientWithURLHttpDo(base string, httpDo func(c *http.Client, r *http.Request) (*http.Response, error)) *Client

func NewClientWithURLHttpDoNonce

func NewClientWithURLHttpDoNonce(base string, httpDo func(c *http.Client, r *http.Request) (*http.Response, error), nonce utils.NonceGenerator) *Client

func NewClientWithURLNonce

func NewClientWithURLNonce(url string, nonce utils.NonceGenerator) *Client

func (*Client) Credentials

func (c *Client) Credentials(key string, secret string) *Client

func (*Client) NewAuthenticatedRequest

func (c *Client) NewAuthenticatedRequest(permissionType bitfinex.PermissionType, refURL string) (Request, error)

func (*Client) NewAuthenticatedRequestWithData

func (c *Client) NewAuthenticatedRequestWithData(permissionType bitfinex.PermissionType, refURL string, data map[string]interface{}) (Request, error)

type CurrenciesService

type CurrenciesService struct {
	Synchronous
	// contains filtered or unexported fields
}

TradeService manages the Trade endpoint.

func (*CurrenciesService) Conf

func (cs *CurrenciesService) Conf(label, symbol, unit, explorer, pairs bool) ([]bitfinex.CurrencyConf, error)

All returns all orders for the authenticated account.

type DerivativesService

type DerivativesService struct {
	Synchronous
	// contains filtered or unexported fields
}

OrderService manages data flow for the Order API endpoint

type ErrorResponse

type ErrorResponse struct {
	Response *Response
	Message  string `json:"message"`
	Code     int    `json:"code"`
}

In case if API will wrong response code ErrorResponse will be returned to caller

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HttpTransport

type HttpTransport struct {
	BaseURL    *url.URL
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func (HttpTransport) Request

func (h HttpTransport) Request(req Request) ([]interface{}, error)

type LedgerService

type LedgerService struct {
	Synchronous
	// contains filtered or unexported fields
}

LedgerService manages the Ledgers endpoint.

func (*LedgerService) Ledgers

func (s *LedgerService) Ledgers(currency string, start int64, end int64, max int32) (*bitfinex.LedgerSnapshot, error)

All returns all ledgers for the authenticated account.

type OrderService

type OrderService struct {
	Synchronous
	// contains filtered or unexported fields
}

OrderService manages data flow for the Order API endpoint

func (*OrderService) All

func (s *OrderService) All() (*bitfinex.OrderSnapshot, error)

Get all active orders

func (*OrderService) AllHistory

func (s *OrderService) AllHistory() (*bitfinex.OrderSnapshot, error)

Get all historical orders

func (*OrderService) GetByOrderId

func (s *OrderService) GetByOrderId(orderID int64) (o *bitfinex.Order, err error)

Get an active order using its order id

func (*OrderService) GetBySymbol

func (s *OrderService) GetBySymbol(symbol string) (*bitfinex.OrderSnapshot, error)

Get all active orders with the given symbol

func (*OrderService) GetHistoryByOrderId

func (s *OrderService) GetHistoryByOrderId(orderID int64) (o *bitfinex.Order, err error)

Get a historical order using its order id

func (*OrderService) GetHistoryBySymbol

func (s *OrderService) GetHistoryBySymbol(symbol string) (*bitfinex.OrderSnapshot, error)

Get all historical orders with the given symbol

func (*OrderService) OrderTrades

func (s *OrderService) OrderTrades(symbol string, orderID int64) (*bitfinex.TradeExecutionUpdateSnapshot, error)

OrderTrades returns a set of executed trades related to an order.

type PlatformService

type PlatformService struct {
	Synchronous
}

func (*PlatformService) Status

func (p *PlatformService) Status() (bool, error)

Status indicates whether the platform is currently operative or not.

type PositionService

type PositionService struct {
	Synchronous
	// contains filtered or unexported fields
}

PositionService manages the Position endpoint.

func (*PositionService) All

func (s *PositionService) All() (*bitfinex.PositionSnapshot, error)

All returns all positions for the authenticated account.

type Request

type Request struct {
	RefURL  string                 // ref url
	Data    map[string]interface{} // body data
	Method  string                 // http method
	Params  url.Values             // query parameters
	Headers map[string]string
}

Request is a wrapper for standard http.Request. Default method is POST with no data.

func NewRequest

func NewRequest(refURL string) Request

func NewRequestWithData

func NewRequestWithData(refURL string, data map[string]interface{}) Request

func NewRequestWithDataMethod

func NewRequestWithDataMethod(refURL string, data map[string]interface{}, method string) Request

func NewRequestWithMethod

func NewRequestWithMethod(refURL string, method string) Request

type Response

type Response struct {
	Response *http.Response
	Body     []byte
}

Response is a wrapper for standard http.Response and provides more methods.

func (*Response) String

func (r *Response) String() string

String converts response body to string. An empty string will be returned if error.

type StatsService

type StatsService struct {
	Synchronous
	// contains filtered or unexported fields
}

TradeService manages the Trade endpoint.

func (*StatsService) CreditSizeHistory

func (ss *StatsService) CreditSizeHistory(symbol string, side bitfinex.OrderSide) ([]bitfinex.Stat, error)

func (*StatsService) CreditSizeLast

func (ss *StatsService) CreditSizeLast(symbol string, side bitfinex.OrderSide) (*bitfinex.Stat, error)

func (*StatsService) FundingHistory

func (ss *StatsService) FundingHistory(symbol string) ([]bitfinex.Stat, error)

func (*StatsService) FundingLast

func (ss *StatsService) FundingLast(symbol string) (*bitfinex.Stat, error)

func (*StatsService) PositionHistory

func (ss *StatsService) PositionHistory(symbol string, side bitfinex.OrderSide) ([]bitfinex.Stat, error)

func (*StatsService) PositionLast

func (ss *StatsService) PositionLast(symbol string, side bitfinex.OrderSide) (*bitfinex.Stat, error)

func (*StatsService) SymbolCreditSizeHistory

func (ss *StatsService) SymbolCreditSizeHistory(fundingSymbol string, tradingSymbol string) ([]bitfinex.Stat, error)

func (*StatsService) SymbolCreditSizeLast

func (ss *StatsService) SymbolCreditSizeLast(fundingSymbol string, tradingSymbol string) (*bitfinex.Stat, error)

type StatusService

type StatusService struct {
	Synchronous
	// contains filtered or unexported fields
}

TradeService manages the Trade endpoint.

func (*StatusService) DerivativeStatus

func (ss *StatusService) DerivativeStatus(symbol string) (*bitfinex.DerivativeStatus, error)

func (*StatusService) DerivativeStatusAll

func (ss *StatusService) DerivativeStatusAll() ([]*bitfinex.DerivativeStatus, error)

func (*StatusService) DerivativeStatusMulti

func (ss *StatusService) DerivativeStatusMulti(symbols []string) ([]*bitfinex.DerivativeStatus, error)

type Synchronous

type Synchronous interface {
	Request(request Request) ([]interface{}, error)
}

type TickerService

type TickerService struct {
	Synchronous
	// contains filtered or unexported fields
}

TradeService manages the Trade endpoint.

func (*TickerService) All

func (s *TickerService) All() (*[]bitfinex.Ticker, error)

func (*TickerService) Get

func (s *TickerService) Get(symbol string) (*bitfinex.Ticker, error)

All returns all orders for the authenticated account.

func (*TickerService) GetMulti

func (s *TickerService) GetMulti(symbols []string) (*[]bitfinex.Ticker, error)

type TradeService

type TradeService struct {
	Synchronous
	// contains filtered or unexported fields
}

TradeService manages the Trade endpoint.

func (*TradeService) AccountAll

func (s *TradeService) AccountAll() (*bitfinex.TradeExecutionUpdateSnapshot, error)

func (*TradeService) AccountAllWithSymbol

func (s *TradeService) AccountAllWithSymbol(symbol string) (*bitfinex.TradeExecutionUpdateSnapshot, error)

func (*TradeService) AccountHistoryWithQuery

func (s *TradeService) AccountHistoryWithQuery(
	symbol string,
	start bitfinex.Mts,
	end bitfinex.Mts,
	limit bitfinex.QueryLimit,
	sort bitfinex.SortOrder,
) (*bitfinex.TradeExecutionUpdateSnapshot, error)

return account trades that fit the given conditions

func (*TradeService) PublicHistoryWithQuery

func (s *TradeService) PublicHistoryWithQuery(
	symbol string,
	start bitfinex.Mts,
	end bitfinex.Mts,
	limit bitfinex.QueryLimit,
	sort bitfinex.SortOrder,
) (*bitfinex.TradeSnapshot, error)

return publicly executed trades that fit the given query conditions

type WalletService

type WalletService struct {
	Synchronous
	// contains filtered or unexported fields
}

WalletService manages data flow for the Wallet API endpoint

func (*WalletService) SetCollateral

func (s *WalletService) SetCollateral(symbol string, amount float64) (bool, error)

All returns all orders for the authenticated account.

func (*WalletService) Wallet

func (s *WalletService) Wallet() (*bitfinex.WalletSnapshot, error)

All returns all orders for the authenticated account.

Jump to

Keyboard shortcuts

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