ftx

package module
v0.0.0-...-2080ae5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 13 Imported by: 0

README

go-ftx

Golang bindings for ftx api

This is based on the golang code provided by ftx here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubscribeTicker

func SubscribeTicker(ctx context.Context, endpoint, market, channel string, outputChan chan<- *ChannelResponse[TickerChannelUpdate]) error

Types

type ChannelRequest

type ChannelRequest struct {
	Op      string `json:"op"`
	Channel string `json:"channel"`
	Market  string `json:"market"`
}

type ChannelResponse

type ChannelResponse[T any] struct {
	ChannelResponseHeader
	Data *T `json:"data,omitempty"`
}

type ChannelResponseHeader

type ChannelResponseHeader struct {
	Channel string `json:"channel"`
	Market  string `json:"market"`
	Type    string `json:"type"`
	Code    string `json:"code"`
	Msg     string `json:"msg"`
}

type Client

type Client struct {
	Api        string
	Secret     []byte
	Subaccount string
}

Client is the client to ftx api.

func NewClient

func NewClient(api, secret, subaccount string) (*Client, error)

NewClient creates a new client

type HistoricalPrices

type HistoricalPrices struct {
	Success bool `json:"success"`
	Result  []struct {
		Close     decimal.Decimal `json:"close"`
		High      decimal.Decimal `json:"high"`
		Low       decimal.Decimal `json:"low"`
		Open      decimal.Decimal `json:"open"`
		StartTime time.Time       `json:"startTime"`
		Volume    decimal.Decimal `json:"volume"`
	} `json:"result"`
}

type Logger

type Logger interface {
	Debugf(string, ...any)
	Infof(string, ...any)
	Warnf(string, ...any)
	Errorf(string, ...any)
	Fatalf(string, ...any)
}

Logger defines an interface to log. By default this is uber's zap.

func SetupLogger

func SetupLogger(defaultLevel, envName string) Logger

type NewOrder

type NewOrder struct {
	Market                  string          `json:"market"`
	Side                    string          `json:"side"`
	Price                   decimal.Decimal `json:"price"`
	Type                    string          `json:"type"`
	Size                    decimal.Decimal `json:"size"`
	ReduceOnly              bool            `json:"reduceOnly"`
	Ioc                     bool            `json:"ioc"`
	PostOnly                bool            `json:"postOnly"`
	ExternalReferralProgram string          `json:"externalReferralProgram"`
}

type NewOrderResponse

type NewOrderResponse struct {
	Success bool  `json:"success"`
	Result  Order `json:"result"`
}

type NewTriggerOrder

type NewTriggerOrder struct {
	Market           string          `json:"market"`
	Side             string          `json:"side"`
	Size             decimal.Decimal `json:"size"`
	Type             string          `json:"type"`
	ReduceOnly       bool            `json:"reduceOnly"`
	RetryUntilFilled bool            `json:"retryUntilFilled"`
	TriggerPrice     decimal.Decimal `json:"triggerPrice,omitempty"`
	OrderPrice       decimal.Decimal `json:"orderPrice,omitempty"`
	TrailValue       decimal.Decimal `json:"trailValue,omitempty"`
}

type NewTriggerOrderResponse

type NewTriggerOrderResponse struct {
	Success bool         `json:"success"`
	Result  TriggerOrder `json:"result"`
}

type OpenOrders

type OpenOrders struct {
	Success bool    `json:"success"`
	Result  []Order `json:"result"`
}

type OpenTriggerOrders

type OpenTriggerOrders struct {
	Success bool           `json:"success"`
	Result  []TriggerOrder `json:"result"`
}

type Order

type Order struct {
	CreatedAt     time.Time       `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 OrderHistory

type OrderHistory struct {
	Success     bool    `json:"success"`
	Result      []Order `json:"result"`
	HasMoreData bool    `json:"hasMoreData"`
}

type Positions

type Positions struct {
	Success bool `json:"success"`
	Result  []struct {
		Cost                         decimal.Decimal `json:"cost"`
		EntryPrice                   decimal.Decimal `json:"entryPrice"`
		EstimatedLiquidationPrice    decimal.Decimal `json:"estimatedLiquidationPrice"`
		Future                       string          `json:"future"`
		InitialMarginRequirement     decimal.Decimal `json:"initialMarginRequirement"`
		LongOrderSize                decimal.Decimal `json:"longOrderSize"`
		MaintenanceMarginRequirement decimal.Decimal `json:"maintenanceMarginRequirement"`
		NetSize                      decimal.Decimal `json:"netSize"`
		OpenSize                     decimal.Decimal `json:"openSize"`
		RealizedPnl                  decimal.Decimal `json:"realizedPnl"`
		ShortOrderSize               decimal.Decimal `json:"shortOrderSize"`
		Side                         string          `json:"side"`
		Size                         decimal.Decimal `json:"size"`
		UnrealizedPnl                decimal.Decimal `json:"unrealizedPnl"`
	} `json:"result"`
}

type Subaccount

type Subaccount struct {
	Success bool `json:"success"`
	Result  struct {
		Nickname  string `json:"nickname"`
		Deletable bool   `json:"deletable"`
		Editable  bool   `json:"editable"`
	} `json:"result"`
}

type SubaccountBalances

type SubaccountBalances struct {
	Success bool `json:"success"`
	Result  []struct {
		Coin  string  `json:"coin"`
		Free  float64 `json:"free"`
		Total float64 `json:"total"`
	} `json:"result"`
}

type SubaccountsList

type SubaccountsList struct {
	Success bool `json:"success"`
	Result  []struct {
		Nickname  string `json:"nickname"`
		Deletable bool   `json:"deletable"`
		Editable  bool   `json:"editable"`
	} `json:"result"`
}

type TickerChannelUpdate

type TickerChannelUpdate struct {
	Bid  *decimal.Decimal `json:"bid,omitempty"`
	Ask  *decimal.Decimal `json:"ask,omitempty"`
	Last *decimal.Decimal `json:"last,omitempty"`
	Time decimal.Decimal  `json:"time"`
}

type Trades

type Trades struct {
	Success bool `json:"success"`
	Result  []struct {
		ID          int64           `json:"id"`
		Liquidation bool            `json:"liquidation"`
		Price       decimal.Decimal `json:"price"`
		Side        string          `json:"side"`
		Size        decimal.Decimal `json:"size"`
		Time        time.Time       `json:"time"`
	} `json:"result"`
}

type TransferSubaccounts

type TransferSubaccounts struct {
	Success bool `json:"success"`
	Result  struct {
		ID     int       `json:"id"`
		Coin   string    `json:"coin"`
		Size   float64   `json:"size"`
		Time   time.Time `json:"time"`
		Notes  string    `json:"notes"`
		Status string    `json:"status"`
	} `json:"result"`
}

type TriggerOrder

type TriggerOrder struct {
	CreatedAt        time.Time       `json:"createdAt"`
	Error            string          `json:"error"`
	Future           string          `json:"future"`
	ID               int64           `json:"id"`
	Market           string          `json:"market"`
	OrderID          int64           `json:"orderId"`
	OrderPrice       decimal.Decimal `json:"orderPrice"`
	ReduceOnly       bool            `json:"reduceOnly"`
	Side             string          `json:"side"`
	Size             decimal.Decimal `json:"size"`
	Status           string          `json:"status"`
	TrailStart       decimal.Decimal `json:"trailStart"`
	TrailValue       decimal.Decimal `json:"trailValue"`
	TriggerPrice     decimal.Decimal `json:"triggerPrice"`
	TriggeredAt      string          `json:"triggeredAt"`
	Type             string          `json:"type"`
	OrderType        string          `json:"orderType"`
	FilledSize       decimal.Decimal `json:"filledSize"`
	AvgFillPrice     decimal.Decimal `json:"avgFillPrice"`
	OrderStatus      string          `json:"orderStatus"`
	RetryUntilFilled bool            `json:"retryUntilFilled"`
}

type TriggerOrderHistory

type TriggerOrderHistory struct {
	Success     bool           `json:"success"`
	Result      []TriggerOrder `json:"result"`
	HasMoreData bool           `json:"hasMoreData"`
}

type Triggers

type Triggers struct {
	Success bool `json:"success"`
	Result  []struct {
		Error      string          `json:"error"`
		FilledSize decimal.Decimal `json:"filledSize"`
		OrderSize  decimal.Decimal `json:"orderSize"`
		OrderID    int64           `json:"orderId"`
		Time       time.Time       `json:"time"`
	} `json:"result"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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