fxt

package
v0.0.0-...-0e8b5bb Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const URL = "https://ftx.com/api/"

Variables

This section is empty.

Functions

This section is empty.

Types

type FtxClient

type FtxClient struct {
	Client     *http.Client
	Api        string
	Secret     []byte
	Subaccount string
}

func New

func New(api string, secret string, subaccount string) *FtxClient

func (*FtxClient) CancelAllOrders

func (client *FtxClient) CancelAllOrders() (Response, error)

func (*FtxClient) CancelOrder

func (client *FtxClient) CancelOrder(orderId int64) (Response, error)

func (*FtxClient) CancelTriggerOrder

func (client *FtxClient) CancelTriggerOrder(orderId int64) (Response, error)

func (*FtxClient) GetHistoricalPrices

func (client *FtxClient) GetHistoricalPrices(market string, resolution int64, limit int64, startTime int64, endTime int64) (HistoricalPrices, error)

func (*FtxClient) GetOpenOrders

func (client *FtxClient) GetOpenOrders(market string) (OpenOrders, error)

func (*FtxClient) GetOpenTriggerOrders

func (client *FtxClient) GetOpenTriggerOrders(market string, _type string) (OpenTriggerOrders, error)

func (*FtxClient) GetOrderHistory

func (client *FtxClient) GetOrderHistory(market string, startTime float64, endTime float64, limit int64) (OrderHistory, error)

func (*FtxClient) GetPositions

func (client *FtxClient) GetPositions(showAvgPrice bool) (Positions, error)

func (*FtxClient) GetTrades

func (client *FtxClient) GetTrades(market string, limit int64, startTime int64, endTime int64) (Trades, error)

func (*FtxClient) GetTriggerOrdersHistory

func (client *FtxClient) GetTriggerOrdersHistory(market string, startTime float64, endTime float64, limit int64) (TriggerOrderHistory, error)

func (*FtxClient) GetTriggers

func (client *FtxClient) GetTriggers(orderId string) (Triggers, error)

func (*FtxClient) PlaceOrder

func (client *FtxClient) PlaceOrder(
	market string,
	side string,
	price float64,
	_type string,
	size float64,
	reduceOnly bool,
	ioc bool,
	postOnly bool) (NewOrderResponse, error)

func (*FtxClient) PlaceTriggerOrder

func (client *FtxClient) PlaceTriggerOrder(market string, side string, size float64,
	_type string, reduceOnly bool, retryUntilFilled bool, triggerPrice float64,
	orderPrice float64, trailValue float64) (NewTriggerOrderResponse, error)

type HistoricalPrices

type HistoricalPrices struct {
	Success bool `json:"success"`
	Result  []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"`
	} `json:"result"`
}

type NewOrder

type NewOrder struct {
	Market                  string  `json:"market"`
	Side                    string  `json:"side"`
	Price                   float64 `json:"price"`
	Type                    string  `json:"type"`
	Size                    float64 `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             float64 `json:"size"`
	Type             string  `json:"type"`
	ReduceOnly       bool    `json:"reduceOnly"`
	RetryUntilFilled bool    `json:"retryUntilFilled"`
	TriggerPrice     float64 `json:"triggerPrice,omitempty"`
	OrderPrice       float64 `json:"orderPrice,omitempty"`
	TrailValue       float64 `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    float64   `json:"filledSize"`
	Future        string    `json:"future"`
	ID            int64     `json:"id"`
	Market        string    `json:"market"`
	Price         float64   `json:"price"`
	AvgFillPrice  float64   `json:"avgFillPrice"`
	RemainingSize float64   `json:"remainingSize"`
	Side          string    `json:"side"`
	Size          float64   `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                         float64 `json:"cost"`
		EntryPrice                   float64 `json:"entryPrice"`
		EstimatedLiquidationPrice    float64 `json:"estimatedLiquidationPrice"`
		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"`
	} `json:"result"`
}

type Response

type Response struct {
	Success bool        `json:"success"`
	Result  interface{} `json:"result"`
}

type Trades

type Trades struct {
	Success bool `json:"success"`
	Result  []struct {
		ID          int64     `json:"id"`
		Liquidation bool      `json:"liquidation"`
		Price       float64   `json:"price"`
		Side        string    `json:"side"`
		Size        float64   `json:"size"`
		Time        time.Time `json:"time"`
	} `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       float64   `json:"orderPrice"`
	ReduceOnly       bool      `json:"reduceOnly"`
	Side             string    `json:"side"`
	Size             float64   `json:"size"`
	Status           string    `json:"status"`
	TrailStart       float64   `json:"trailStart"`
	TrailValue       float64   `json:"trailValue"`
	TriggerPrice     float64   `json:"triggerPrice"`
	TriggeredAt      string    `json:"triggeredAt"`
	Type             string    `json:"type"`
	OrderType        string    `json:"orderType"`
	FilledSize       float64   `json:"filledSize"`
	AvgFillPrice     float64   `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 float64   `json:"filledSize"`
		OrderSize  float64   `json:"orderSize"`
		OrderID    int64     `json:"orderId"`
		Time       time.Time `json:"time"`
	} `json:"result"`
}

Jump to

Keyboard shortcuts

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