ftx

package
v0.0.0-...-5439e55 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 62
	DEFAULT_TAKER_FEE    = 0.0007
	DEFAULT_MAKER_FEE    = 0.0002
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001
	DEFAULT_TXFEE        = 0.005
	DEFAULT_WITHDRAW     = true
	DEFAULT_DEPOSIT      = true
	DEFAULT_CONFIRMATION = 2
	DEFAULT_LISTED       = true
)
View Source
const (
	API_URL string = "https://ftx.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountIdentifier            int     `json:"accountIdentifier"`
	Username                     string  `json:"username"`
	Collateral                   float64 `json:"collateral"`
	FreeCollateral               float64 `json:"freeCollateral"`
	TotalAccountValue            float64 `json:"totalAccountValue"`
	TotalPositionSize            float64 `json:"totalPositionSize"`
	InitialMarginRequirement     float64 `json:"initialMarginRequirement"`
	MaintenanceMarginRequirement float64 `json:"maintenanceMarginRequirement"`
	MarginFraction               float64 `json:"marginFraction"`
	OpenMarginFraction           float64 `json:"openMarginFraction"`
	Liquidating                  bool    `json:"liquidating"`
	BackstopProvider             bool    `json:"backstopProvider"`
	Positions                    []struct {
		Future                       string      `json:"future"`
		Size                         float64     `json:"size"`
		Side                         string      `json:"side"`
		NetSize                      float64     `json:"netSize"`
		LongOrderSize                float64     `json:"longOrderSize"`
		ShortOrderSize               float64     `json:"shortOrderSize"`
		Cost                         float64     `json:"cost"`
		EntryPrice                   interface{} `json:"entryPrice"`
		UnrealizedPnl                float64     `json:"unrealizedPnl"`
		RealizedPnl                  float64     `json:"realizedPnl"`
		InitialMarginRequirement     float64     `json:"initialMarginRequirement"`
		MaintenanceMarginRequirement float64     `json:"maintenanceMarginRequirement"`
		OpenSize                     float64     `json:"openSize"`
		CollateralUsed               float64     `json:"collateralUsed"`
		EstimatedLiquidationPrice    interface{} `json:"estimatedLiquidationPrice"`
	} `json:"positions"`
	TakerFee                    float64     `json:"takerFee"`
	MakerFee                    float64     `json:"makerFee"`
	Leverage                    float64     `json:"leverage"`
	PositionLimit               interface{} `json:"positionLimit"`
	PositionLimitUsed           interface{} `json:"positionLimitUsed"`
	UseFttCollateral            bool        `json:"useFttCollateral"`
	ChargeInterestOnNegativeUsd bool        `json:"chargeInterestOnNegativeUsd"`
	SpotMarginEnabled           bool        `json:"spotMarginEnabled"`
	SpotLendingEnabled          bool        `json:"spotLendingEnabled"`
}

type AccountAllBalances

type AccountAllBalances struct {
	Main []struct {
		Coin  string  `json:"coin"`
		Free  float64 `json:"free"`
		Total float64 `json:"total"`
	} `json:"main"`
	BattleRoyale []struct {
		Coin  string  `json:"coin"`
		Free  float64 `json:"free"`
		Total float64 `json:"total"`
	} `json:"Battle Royale"`
}

type AccountBalances

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

type CloseOrders

type CloseOrders []struct {
	AvgFillPrice  float64     `json:"avgFillPrice"`
	ClientID      interface{} `json:"clientId"`
	CreatedAt     time.Time   `json:"createdAt"`
	FilledSize    float64     `json:"filledSize"`
	Future        string      `json:"future"`
	ID            int         `json:"id"`
	Ioc           bool        `json:"ioc"`
	Market        string      `json:"market"`
	PostOnly      bool        `json:"postOnly"`
	Price         float64     `json:"price"`
	ReduceOnly    bool        `json:"reduceOnly"`
	RemainingSize float64     `json:"remainingSize"`
	Side          string      `json:"side"`
	Size          float64     `json:"size"`
	Status        string      `json:"status"`
	Type          string      `json:"type"`
}

type CoinsData

type CoinsData []struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Index      bool   `json:"index,omitempty"`
	Collateral bool   `json:"collateral,omitempty"`
	Underlying string `json:"underlying,omitempty"`
}

type DepositAddress

type DepositAddress struct {
	Address string `json:"address"`
	Tag     string `json:"tag"`
}

type DepositHistory

type DepositHistory []struct {
	Coin          string    `json:"coin"`
	Notes         string    `json:"notes"`
	Confirmations int       `json:"confirmations"`
	ConfirmedTime time.Time `json:"confirmedTime"`
	Fee           float64   `json:"fee"`
	ID            int       `json:"id"`
	SentTime      time.Time `json:"sentTime"`
	Size          float64   `json:"size"`
	Status        string    `json:"status"`
	Time          time.Time `json:"time"`
	Txid          string    `json:"txid"`
}

type Ftx

type Ftx struct {
	ID      int
	Name    string `bson:"name"`
	Website string `bson:"website"`

	API_KEY          string
	API_SECRET       string
	Sub_Account_Name string

	Source    exchange.DataSource // / exchange API / microservicve api 1 / PSQL
	SourceURI string
}

func CreateFtx

func CreateFtx(config *exchange.Config) *Ftx

*************************************************

func (*Ftx) ApiKeyGET

func (e *Ftx) ApiKeyGET(strRequestPath string, mapParams map[string]string) string

************** Signature Http Request ************** Method: API Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request Step 3: Add HttpGetRequest below strUrl if API has different requests

func (*Ftx) ApiKeyRequest

func (e *Ftx) ApiKeyRequest(strMethod, strRequestPath string, mapParams map[string]string) string

func (*Ftx) CanDeposit

func (e *Ftx) CanDeposit(coin *coin.Coin) bool

func (*Ftx) CanWithdraw

func (e *Ftx) CanWithdraw(coin *coin.Coin) bool

func (*Ftx) CancelAllOrder

func (e *Ftx) CancelAllOrder() error

func (*Ftx) CancelOrder

func (e *Ftx) CancelOrder(order *exchange.Order) error

func (*Ftx) DeleteCoin

func (e *Ftx) DeleteCoin(coin *coin.Coin)

func (*Ftx) DeletePair

func (e *Ftx) DeletePair(pair *pair.Pair)

func (*Ftx) DoAccountOperation

func (e *Ftx) DoAccountOperation(operation *exchange.AccountOperation) error

func (*Ftx) GetBalance

func (e *Ftx) GetBalance(coin *coin.Coin) float64

func (*Ftx) GetCoinBySymbol

func (e *Ftx) GetCoinBySymbol(symbol string) *coin.Coin

func (*Ftx) GetCoinConstraint

func (e *Ftx) GetCoinConstraint(coin *coin.Coin) *exchange.CoinConstraint

************** Coins on the Exchanges **************

func (*Ftx) GetCoins

func (e *Ftx) GetCoins() []*coin.Coin

func (*Ftx) GetCoinsData

func (e *Ftx) GetCoinsData() error

************** Public API ************** Get Coins Information (If API provide) Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Ftx) GetConfirmation

func (e *Ftx) GetConfirmation(coin *coin.Coin) int

func (*Ftx) GetConstraintFetchMethod

func (e *Ftx) GetConstraintFetchMethod(pair *pair.Pair) *exchange.ConstrainFetchMethod

*************** Exchange Constraint ***************

func (*Ftx) GetFee

func (e *Ftx) GetFee(pair *pair.Pair) float64

*************** Pair Constraint ***************

func (*Ftx) GetID

func (e *Ftx) GetID() int

*************** Exchange Information ***************

func (*Ftx) GetLotSize

func (e *Ftx) GetLotSize(pair *pair.Pair) float64

func (*Ftx) GetName

func (e *Ftx) GetName() exchange.ExchangeName

func (*Ftx) GetPairBySymbol

func (e *Ftx) GetPairBySymbol(symbol string) *pair.Pair

func (*Ftx) GetPairConstraint

func (e *Ftx) GetPairConstraint(pair *pair.Pair) *exchange.PairConstraint

************** Pairs on the Exchanges **************

func (*Ftx) GetPairs

func (e *Ftx) GetPairs() []*pair.Pair

func (*Ftx) GetPairsData

func (e *Ftx) GetPairsData() error
GetPairsData - Get Pairs Information (If API provide)

Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Ftx) GetPriceFilter

func (e *Ftx) GetPriceFilter(pair *pair.Pair) float64

func (*Ftx) GetSymbolByCoin

func (e *Ftx) GetSymbolByCoin(coin *coin.Coin) string

func (*Ftx) GetSymbolByPair

func (e *Ftx) GetSymbolByPair(pair *pair.Pair) string

func (*Ftx) GetTradingWebURL

func (e *Ftx) GetTradingWebURL(pair *pair.Pair) string

func (*Ftx) GetTxFee

func (e *Ftx) GetTxFee(coin *coin.Coin) float64

*************** Coin Constraint ***************

func (*Ftx) HasPair

func (e *Ftx) HasPair(pair *pair.Pair) bool

func (*Ftx) InitData

func (e *Ftx) InitData() error

func (*Ftx) LimitBuy

func (e *Ftx) LimitBuy(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Ftx) LimitSell

func (e *Ftx) LimitSell(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Ftx) ListOrders

func (e *Ftx) ListOrders() ([]*exchange.Order, error)

func (*Ftx) LoadPublicData

func (e *Ftx) LoadPublicData(operation *exchange.PublicOperation) error

************** PUBLIC API **************

func (*Ftx) OrderBook

func (e *Ftx) OrderBook(pair *pair.Pair) (*exchange.Maker, error)

orderbook

func (*Ftx) OrderStatus

func (e *Ftx) OrderStatus(order *exchange.Order) error

func (*Ftx) SetCoinConstraint

func (e *Ftx) SetCoinConstraint(coinConstraint *exchange.CoinConstraint)

func (*Ftx) SetPairConstraint

func (e *Ftx) SetPairConstraint(pairConstraint *exchange.PairConstraint)

func (*Ftx) UpdateAllBalances

func (e *Ftx) UpdateAllBalances()

func (*Ftx) UpdateConstraint

func (e *Ftx) UpdateConstraint()

func (*Ftx) Withdraw

func (e *Ftx) Withdraw(coin *coin.Coin, quantity float64, addr, tag string) bool

TODO

type JsonResponse

type JsonResponse struct {
	Success bool            `json:"success"`
	Message string          `json:"message"`
	Result  json.RawMessage `json:"result"`
}

type OpenOrders

type OpenOrders []struct {
	CreatedAt     time.Time   `json:"createdAt"`
	FilledSize    float64     `json:"filledSize"`
	Future        string      `json:"future"`
	ID            int         `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      interface{} `json:"clientId"`
}

type OrderBook

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

type OrderStatus

type OrderStatus struct {
	CreatedAt     time.Time   `json:"createdAt"`
	FilledSize    float64     `json:"filledSize"`
	Future        string      `json:"future"`
	ID            int         `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      interface{} `json:"clientId"`
}

type PairsData

type PairsData []struct {
	Ask            float64 `json:"ask"`
	BaseCurrency   string  `json:"baseCurrency"`
	Bid            float64 `json:"bid"`
	Change1H       float64 `json:"change1h,omitempty"`
	Change24H      float64 `json:"change24h,omitempty"`
	ChangeBod      float64 `json:"changeBod,omitempty"`
	Enabled        bool    `json:"enabled"`
	Last           float64 `json:"last"`
	MinProvideSize float64 `json:"minProvideSize"`
	Name           string  `json:"name"`
	Price          float64 `json:"price"`
	PriceIncrement float64 `json:"priceIncrement"`
	QuoteCurrency  string  `json:"quoteCurrency"`
	QuoteVolume24H float64 `json:"quoteVolume24h,omitempty"`
	Restricted     bool    `json:"restricted"`
	SizeIncrement  float64 `json:"sizeIncrement"`
	Type           string  `json:"type"`
	Underlying     string  `json:"underlying"`
	VolumeUsd24H   float64 `json:"volumeUsd24h,omitempty"`
}

type PlaceOrder

type PlaceOrder struct {
	CreatedAt     time.Time   `json:"createdAt"`
	FilledSize    float64     `json:"filledSize"`
	Future        string      `json:"future"`
	ID            int         `json:"id"`
	Market        string      `json:"market"`
	Price         float64     `json:"price"`
	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      interface{} `json:"clientId"`
}

type RawKline

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

type Uuid

type Uuid struct {
	Id string `json:"uuid"`
}

type WithdrawHistory

type WithdrawHistory []struct {
	Coin    string      `json:"coin"`
	Notes   string      `json:"notes"`
	Address string      `json:"address"`
	Tag     interface{} `json:"tag"`
	Fee     float64     `json:"fee"`
	ID      int         `json:"id"`
	Size    float64     `json:"size"`
	Status  string      `json:"status"`
	Time    time.Time   `json:"time"`
	Txid    string      `json:"txid"`
}

need test array or single

Jump to

Keyboard shortcuts

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