rest

package
v0.0.0-...-2ffb769 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

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
	Platform  PlatformService
	Book      BookService
	Wallet    WalletService

	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(refURL string) (Request, error)

func (*Client) NewAuthenticatedRequestWithData

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

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 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(symbol string) (*bitfinex.OrderSnapshot, error)

All returns all orders for the authenticated account.

func (*OrderService) History

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

All returns all orders for the authenticated account.

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.

func (*OrderService) Status

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

Status retrieves the given order from the API. This is just a wrapper around the All() method, since the API does not provide lookup for a single 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 Synchronous

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

type TradeService

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

TradeService manages the Trade endpoint.

func (*TradeService) All

func (s *TradeService) All(symbol string) (*bitfinex.TradeSnapshot, error)

All returns all orders for the authenticated account.

type WalletService

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

WalletService manages data flow for the Wallet API endpoint

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