ftx

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CandlesLimit = 1000
)

Variables

This section is empty.

Functions

func Init added in v0.5.1

func Init(ctx context.Context) error

func NewFillChannel added in v0.5.1

func NewFillChannel(sym exchange.Symbol) exchange.Channel

func NewMarketsChannel added in v0.5.4

func NewMarketsChannel(sym exchange.Symbol) exchange.Channel

func NewOrderBookChannel added in v0.5.1

func NewOrderBookChannel(sym exchange.Symbol) exchange.Channel

func NewOrderChannel added in v0.5.1

func NewOrderChannel(sym exchange.Symbol) exchange.Channel

func NewOrederbookGroupedChannel added in v0.5.4

func NewOrederbookGroupedChannel(sym exchange.Symbol) exchange.Channel

func NewTickersChannel added in v0.5.4

func NewTickersChannel(sym exchange.Symbol) exchange.Channel

func NewTradesChannel added in v0.5.4

func NewTradesChannel(sym exchange.Symbol) exchange.Channel

func ParseSymbol added in v0.5.1

func ParseSymbol(symbol string) (exchange.Symbol, error)

Types

type Balance

type Balance struct {
	Coin  string  `json:"coin"`
	Free  float64 `json:"free"`
	Total float64 `json:"total"`
}

type BookReq added in v0.5.4

type BookReq struct {
	Market string
	Depth  int
}

func NewBookReq added in v0.5.4

func NewBookReq(market string, depth int) *BookReq

type Candle added in v0.5.1

type Candle struct {
	Open      float64
	Close     float64
	High      float64
	Low       float64
	Volume    float64
	Time      float64
	StartTime string `json:"startTime"`
}

func (*Candle) Transform added in v0.5.1

func (c *Candle) Transform(symbol exchange.Symbol) *exchange.Kline

type CandleReq added in v0.5.1

type CandleReq struct {
	// contains filtered or unexported fields
}

func NewCandelReq added in v0.5.1

func NewCandelReq(name string, resolution int) *CandleReq

func (*CandleReq) EndTime added in v0.5.1

func (cr *CandleReq) EndTime(secs int64) *CandleReq

func (*CandleReq) Limit added in v0.5.1

func (cr *CandleReq) Limit(l int) *CandleReq

func (*CandleReq) StartTime added in v0.5.1

func (cr *CandleReq) StartTime(secs int64) *CandleReq

type CodeC

type CodeC struct {
	*exchange.CodeC
	// contains filtered or unexported fields
}

func NewCodeC

func NewCodeC() *CodeC

func (*CodeC) Decode

func (cc *CodeC) Decode(raw []byte) (rpc.Response, error)

type Depth added in v0.5.4

type Depth struct {
	Asks [][2]float64
	Bids [][2]float64
}

type Fill

type Fill struct {
	ID      exchange.OrderID
	Symbol  exchange.Symbol
	OrderID exchange.OrderID
	TradeID exchange.OrderID
	Side    exchange.OrderSide
	Price   decimal.Decimal
	Size    decimal.Decimal
	Time    time.Time
	Fee     decimal.Decimal
	FeeRate decimal.Decimal
}

type FillChannel added in v0.5.1

type FillChannel struct {
	// contains filtered or unexported fields
}

func (*FillChannel) String added in v0.5.1

func (fc *FillChannel) String() string

type FillNotify

type FillNotify struct {
	Fee       decimal.Decimal `json:"fee"`
	FeeRate   decimal.Decimal `json:"feeRate"`
	Future    string          `json:"future"`
	ID        int64           `json:"id"`
	Liquidity string          `json:"liquidity"`
	Market    string          `json:"market"`
	OrderID   int64           `json:"orderId"`
	TradeID   int64           `json:"tradeId"`
	Price     decimal.Decimal `json:"price"`
	Side      string          `json:"side"`
	Size      decimal.Decimal `json:"size"`
	Time      string          `json:"time"`
	Type      string          `json:"type"`
}

type FutureInfo

type FutureInfo struct {
	Ask                 float64 `json:"ask"`
	Bid                 float64 `json:"bid"`
	Change1H            float64 `json:"change1h"`
	Change24H           float64 `json:"change24h"`
	ChangeBod           float64 `json:"changeBod"`
	VolumeUsd24h        float64 `json:"volumeUsd24h"`
	Volume              float64 `json:"volume"`
	Description         string  `json:"description"`
	Enabled             bool    `json:"enabled"`
	Expired             bool    `json:"expired"`
	Expiry              string  `json:"expiry"`
	Index               float64 `json:"index"`
	ImfFactor           float64 `json:"imfFactor"`
	Last                float64 `json:"last"`
	LowerBound          float64 `json:"lowerBound"`
	Mark                float64 `json:"mark"`
	Name                string  `json:"name"`
	Perpetual           bool    `json:"perpetual"`
	PositionLimitWtight float64 `json:"positionLimitWeight"`
	PostOnly            bool    `json:"postOnly"`
	PriceIncrement      float64 `json:"priceIncrement"`
	SizeIncrement       float64 `json:"sizeIncrement"`
	Underlying          string  `json:"underlying"`
	UpperBound          float64 `json:"upperBound"`
	Type                string  `json:"type"`
}

func (*FutureInfo) ToSymbol added in v0.5.1

func (info *FutureInfo) ToSymbol() (exchange.Symbol, error)

type FuturesSymbol

type FuturesSymbol struct {
	*exchange.BaseFutureSymbol
}

func (*FuturesSymbol) String

func (fs *FuturesSymbol) String() string

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"`
	MinProvideSize float64 `json:"minProvideSize"`
	Restricted     bool    `json:"restricted"`
}

func (*Market) ToSymbol added in v0.5.1

func (m *Market) ToSymbol() (exchange.Symbol, error)

type MarketChannel added in v0.5.4

type MarketChannel struct {
	// contains filtered or unexported fields
}

func (*MarketChannel) String added in v0.5.4

func (m *MarketChannel) String() string

type Markets added in v0.5.4

type Markets struct{}

type Order

type Order struct {
	CreatedAt     string          `json:"createdAt"`
	FilledSize    decimal.Decimal `json:"filledSize"`
	Future        string          `json:"future"`
	ID            int64           `json:"id"`
	Market        string          `json:"market"`
	Price         decimal.Decimal `json:"price"`
	AvgFillPrice  decimal.Decimal `json:"avgFillPrice"`
	RemainingSize decimal.Decimal `json:"remainingSize"`
	Side          string          `json:"side"`
	Size          decimal.Decimal `json:"size"`
	Status        string          `json:"status"`
	Type          string          `json:"type"`
	ReduceOnly    bool            `json:"reduceOnly"`
	IOC           bool            `json:"ioc"`
	PostOnly      bool            `json:"postOnly"`
	ClientID      string          `json:"clientId"`
}

type OrderBook

type OrderBook struct {
	*exchange.OrderBookDS
	// contains filtered or unexported fields
}

func NewOrderBook

func NewOrderBook(sym exchange.Symbol) *OrderBook

func (*OrderBook) Init

func (ob *OrderBook) Init(cr *callResponse) (*exchange.OrderBook, error)

func (*OrderBook) Update

func (ob *OrderBook) Update(cr *callResponse) (*exchange.OrderBook, error)

type OrderBookChannel added in v0.5.1

type OrderBookChannel struct {
	// contains filtered or unexported fields
}

func (*OrderBookChannel) String added in v0.5.1

func (obc *OrderBookChannel) String() string

type OrderBookData

type OrderBookData struct {
	Action    string       `json:"action"`
	Bids      [][2]float64 `json:"bids"`
	Asks      [][2]float64 `json:"asks"`
	Timestamp int64        `json:"timestamp"`
}

func (*OrderBookData) Transfer

type OrderChannel added in v0.5.1

type OrderChannel struct {
	// contains filtered or unexported fields
}

func (*OrderChannel) String added in v0.5.1

func (oc *OrderChannel) String() string

type OrderReq

type OrderReq struct {
	Market   string  `json:"market"`
	Side     string  `json:"side"`
	Price    float64 `json:"price"`
	Type     string  `json:"type"`
	Size     float64 `json:"size"`
	ClientID string  `json:"clientId,omitempty"`
}

type OrderbookGrouped added in v0.5.4

type OrderbookGrouped struct{}

type OrderbookGroupedChannel added in v0.5.4

type OrderbookGroupedChannel struct {
	// contains filtered or unexported fields
}

func (*OrderbookGroupedChannel) String added in v0.5.4

func (o *OrderbookGroupedChannel) String() string

type OrdersHistoryReq added in v0.5.4

type OrdersHistoryReq struct {
	Market    string `json:"market"`
	Side      string `json:"side"`
	OrderType string `json:"orderType"`
	StartTime int    `json:"startTime"`
	EndTime   int    `json:"endTime"`
}

func NewOrderHistoryReq added in v0.5.4

func NewOrderHistoryReq(market, side, orderType string, startTime, endTime int) *OrdersHistoryReq

type Position

type Position struct {
	Cost       float64 `json:"cost"`
	EntryPrice float64 `json:"entryPrice"`
}

type RestClient

type RestClient struct {
	// contains filtered or unexported fields
}

func NewClientWithSubAccount added in v0.5.4

func NewClientWithSubAccount(key, secret, subAccount string) *RestClient

func NewRestClient

func NewRestClient(key, secret string) *RestClient

func (*RestClient) Balances

func (rc *RestClient) Balances(ctx context.Context) ([]Balance, error)

func (*RestClient) Books added in v0.5.4

func (rc *RestClient) Books(ctx context.Context, req *BookReq) (*Depth, error)

func (*RestClient) Candles added in v0.5.1

func (rc *RestClient) Candles(ctx context.Context, cr *CandleReq) ([]Candle, error)

Candles fetch ftx candles in ascending order

func (*RestClient) Future

func (rc *RestClient) Future(ctx context.Context, sym string) (*FutureInfo, error)

func (*RestClient) Futures

func (rc *RestClient) Futures(ctx context.Context) ([]FutureInfo, error)

func (*RestClient) Klines added in v0.5.1

func (rc *RestClient) Klines(ctx context.Context, kr *exchange.KlineReq) ([]exchange.Kline, error)

Klines fetch klines in reverse orders

func (*RestClient) Markets

func (rc *RestClient) Markets(ctx context.Context) ([]Market, error)

func (*RestClient) OrderCancel

func (rc *RestClient) OrderCancel(ctx context.Context, order *exchange.Order) error

OrderCancel only ID field is required

func (*RestClient) OrderFetch

func (rc *RestClient) OrderFetch(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

OrderFetch only ID field is required

func (*RestClient) OrderNew

func (rc *RestClient) OrderNew(ctx context.Context, req *exchange.OrderRequest, options ...exchange.OrderReqOption) (*exchange.Order, error)

func (*RestClient) Orders

func (rc *RestClient) Orders(ctx context.Context, symbol exchange.Symbol) ([]*exchange.Order, error)

Orders return open orders

func (*RestClient) OrdersHistory added in v0.5.4

func (rc *RestClient) OrdersHistory(ctx context.Context, param *OrdersHistoryReq) ([]*Order, error)

func (*RestClient) Positions

func (client *RestClient) Positions(ctx context.Context) ([]Position, error)

type SpotSymbol

type SpotSymbol struct {
	*exchange.BaseSpotSymbol
}

func (*SpotSymbol) String

func (ss *SpotSymbol) String() string

type SwapSymbol

type SwapSymbol struct {
	*exchange.BaseSwapSymbol
}

func (*SwapSymbol) String

func (fs *SwapSymbol) String() string

type Ticker added in v0.5.4

type Ticker struct {
}

type TickerChannel added in v0.5.4

type TickerChannel struct {
	// contains filtered or unexported fields
}

func (*TickerChannel) String added in v0.5.4

func (t *TickerChannel) String() string

type Trade added in v0.5.4

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

type TradeChannel added in v0.5.4

type TradeChannel struct {
	// contains filtered or unexported fields
}

func (*TradeChannel) String added in v0.5.4

func (t *TradeChannel) String() string

type TradeNotify added in v0.5.4

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

type WSClient

type WSClient struct {
	*exchange.WSClient
	// contains filtered or unexported fields
}

func NewWSClient added in v0.5.1

func NewWSClient(key, secret string, data chan interface{}) *WSClient

func (*WSClient) Auth

func (ws *WSClient) Auth(ctx context.Context) error

func (*WSClient) Handle

func (ws *WSClient) Handle(ctx context.Context, notify *rpc.Notify)

func (*WSClient) Run

func (ws *WSClient) Run(ctx context.Context) error

func (*WSClient) Subscribe

func (ws *WSClient) Subscribe(ctx context.Context, channels ...exchange.Channel) error

func (*WSClient) UnSubscribe added in v0.5.4

func (ws *WSClient) UnSubscribe(ctx context.Context, channels ...exchange.Channel) error

type Wrap

type Wrap struct {
	Success bool            `json:"success"`
	Result  json.RawMessage `json:"result"`
	Error   string          `json:"error"`
}

Jump to

Keyboard shortcuts

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