ftx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Leverage1X   = 1
	Leverage3X   = 3
	Leverage5X   = 5
	Leverage10X  = 10
	Leverage20X  = 20
	Leverage50X  = 50
	Leverage100X = 100
	Leverage101X = 101
)
View Source
const (
	HeaderKey        = "FTX-KEY"
	HeaderSign       = "FTX-SIGN"
	HeaderTS         = "FTX-TS"
	HeaderSubaccount = "FTX-SUBACCOUNT"
)
View Source
const (
	Resolution15s = 15
	Resolution1m  = 60
	Resolution5m  = 300
	Resolution15m = 900
	Resolution1h  = 3600
	Resolution4h  = 14400
	Resolution1d  = 86400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	BackstopProvider             bool    `json:"backstopProvider"`
	Collateral                   float64 `json:"collateral"`
	FreeCollateral               float64 `json:"freeCollateral"`
	InitialMarginRequirement     float64 `json:"initialMarginRequirement"`
	Leverage                     float64 `json:"leverage"`
	Liquidating                  bool    `json:"liquidating"`
	MaintenanceMarginRequirement float64 `json:"maintenanceMarginRequirement"`
	MakerFee                     float64 `json:"makerFee"`
	MarginFraction               float64 `json:"marginFraction"`
	OpenMarginFraction           float64 `json:"openMarginFraction"`
	TakerFee                     float64 `json:"takerFee"`
	TotalAccountValue            float64 `json:"totalAccountValue"`
	TotalPositionSize            float64 `json:"totalPositionSize"`
	Username                     string  `json:"username"`
	Positions                    []Position
}

type AccountService

type AccountService service

func (*AccountService) GetInformation

func (s *AccountService) GetInformation() (*Account, error)

GetInformation FTX API docs: https://docs.ftx.com/#get-account-information

func (*AccountService) GetPositions

func (s *AccountService) GetPositions() ([]Position, error)

GetPositions FTX API docs: https://docs.ftx.com/#get-positions

func (*AccountService) SetLeverage

func (s *AccountService) SetLeverage(x int) error

SetLeverage FTX API docs: https://docs.ftx.com/#change-account-leverage

type Candle

type Candle struct {
	Close     float64   `json:"close"`
	High      float64   `json:"high"`
	Low       float64   `json:"low"`
	Open      float64   `json:"open"`
	StartTime time.Time `json:"startTime"`
	Volume    float64   `json:"volume"`
}

type Client

type Client struct {
	Accounts *AccountService
	Markets  *MarketService
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Client

func (*Client) Connect

func (c *Client) Connect() (*stream.Conn, error)

func (*Client) DoPrivate

func (c *Client) DoPrivate(uri string, method string, in, out interface{}) error

func (*Client) DoPublic

func (c *Client) DoPublic(uri string, method string, in, out interface{}) error

type GetHistoricalPrices

type GetHistoricalPrices struct {
	Resolution int   `url:"resolution"`
	Limit      int   `url:"limit"`
	StartTime  int64 `url:"start_time"`
	EndTime    int64 `url:"end_time"`
}

type GetOrderBookOptions

type GetOrderBookOptions struct {
	Depth int `url:"depth"`
}

type GetTradesOptions

type GetTradesOptions struct {
	Limit     int   `url:"limit"`
	StartTime int64 `url:"start_time"`
	EndTime   int64 `url:"end_time"`
}

type Market

type Market struct {
	Name           string  `json:"name"`
	BaseCurrency   string  `json:"baseCurrency"`
	QuoteCurrency  string  `json:"quoteCurrency"`
	Type           string  `json:"type"`
	Underlying     string  `json:"underlying"`
	Enabled        bool    `json:"enabled"`
	Ask            float64 `json:"ask"`
	Bid            float64 `json:"bid"`
	Last           float64 `json:"last"`
	PostOnly       bool    `json:"postOnly"`
	PriceIncrement float64 `json:"priceIncrement"`
	SizeIncrement  float64 `json:"sizeIncrement"`
	Restricted     bool    `json:"restricted"`
}

type MarketService

type MarketService service

func (*MarketService) All

func (s *MarketService) All() ([]Market, error)

All FTX API docs: https://docs.ftx.com/#get-markets

func (*MarketService) Get

func (s *MarketService) Get(name string) (*Market, error)

Get FTX API docs: https://docs.ftx.com/#get-single-market

func (*MarketService) GetHistoricalPrices

func (s *MarketService) GetHistoricalPrices(name string, opts *GetHistoricalPrices) ([]Candle, error)

GetHistoricalPrices FTX API docs: https://docs.ftx.com/#get-historical-prices

func (*MarketService) GetOrderBook

func (s *MarketService) GetOrderBook(name string, opts *GetOrderBookOptions) (*OrderBook, error)

GetOrderBook FTX API docs: https://docs.ftx.com/#get-orderbook

func (*MarketService) GetTrades

func (s *MarketService) GetTrades(name string, opts *GetTradesOptions) ([]Trade, error)

GetTrades FTX API docs: https://docs.ftx.com/#get-trades

type Option

type Option func(*Client)

func WithAuth

func WithAuth(key, secret string) Option

func WithSubaccount

func WithSubaccount(account string) Option

type OrderBook

type OrderBook struct {
	Asks [][]float64 `json:"asks"`
	Bids [][]float64 `json:"bids"`
}

type Position

type Position struct {
	Cost                         float64 `json:"cost"`
	EntryPrice                   float64 `json:"entryPrice"`
	EstimatedLiquidationPrice    float64 `json:"estimatedLiquidationPrice,omitempty"`
	Future                       string  `json:"future"`
	InitialMarginRequirement     float64 `json:"initialMarginRequirement"`
	LongOrderSize                float64 `json:"longOrderSize"`
	MaintenanceMarginRequirement float64 `json:"maintenanceMarginRequirement"`
	NetSize                      float64 `json:"netSize"`
	OpenSize                     float64 `json:"openSize"`
	RealizedPnl                  float64 `json:"realizedPnl"`
	ShortOrderSize               float64 `json:"shortOrderSize"`
	Side                         string  `json:"side"`
	Size                         float64 `json:"size"`
	UnrealizedPnl                float64 `json:"unrealizedPnl"`
	CollateralUsed               float64 `json:"collateralUsed,omitempty"`
}

type RequestLeverage

type RequestLeverage struct {
	Leverage int `json:"leverage"`
}

type Response

type Response struct {
	Success bool        `json:"success"`
	Result  interface{} `json:"result,omitempty"`
	Error   string      `json:"error,omitempty"`
}

type Trade

type Trade struct {
	ID          int       `json:"id"`
	Liquidation bool      `json:"liquidation"`
	Price       float64   `json:"price"`
	Side        string    `json:"side"`
	Size        float64   `json:"size"`
	Time        time.Time `json:"time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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