bitmex

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: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 5
	DEFAULT_TAKER_FEE    = 0.001
	DEFAULT_MAKER_FEE    = 0.001
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001 //PRICE FILTER
	DEFAULT_TXFEE        = 0.005
	DEFAULT_WITHDRAW     = true
	DEFAULT_DEPOSIT      = true
	DEFAULT_CONFIRMATION = 2
)
View Source
const (
	API_URL = "https://www.bitmex.com/api/v1"
)

The Base Endpoint URL

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalances

type AccountBalances struct {
	MakerCommission  int  `json:"makerCommission"`
	TakerCommission  int  `json:"takerCommission"`
	BuyerCommission  int  `json:"buyerCommission"`
	SellerCommission int  `json:"sellerCommission"`
	CanTrade         bool `json:"canTrade"`
	CanWithdraw      bool `json:"canWithdraw"`
	CanDeposit       bool `json:"canDeposit"`
	Balances         []struct {
		Asset  string `json:"asset"`
		Free   string `json:"free"`
		Locked string `json:"locked"`
	} `json:"balances"`
}

type Bitmex

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

	API_KEY    string
	API_SECRET string

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

func CreateBitmex

func CreateBitmex(config *exchange.Config) *Bitmex

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

func (*Bitmex) ApiKeyGet

func (e *Bitmex) ApiKeyGet(mapParams map[string]string, strRequestPath string) string

************** Signature Http Request ************** Method: GET and Signature is required --reference Binance 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 (*Bitmex) ApiKeyPost

func (e *Bitmex) ApiKeyPost(mapParams map[string]string, strRequestPath string) string

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 (*Bitmex) CanDeposit

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

func (*Bitmex) CanWithdraw

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

func (*Bitmex) CancelAllOrder

func (e *Bitmex) CancelAllOrder() error

func (*Bitmex) CancelOrder

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

func (*Bitmex) DeleteCoin

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

func (*Bitmex) DeletePair

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

func (*Bitmex) DoAccountOperation

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

************** Private API **************

func (*Bitmex) GetBalance

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

func (*Bitmex) GetCoinBySymbol

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

func (*Bitmex) GetCoinConstraint

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

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

func (*Bitmex) GetCoins

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

func (*Bitmex) GetCoinsData

func (e *Bitmex) 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 (*Bitmex) GetConfirmation

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

func (*Bitmex) GetConstraintFetchMethod

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

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

func (*Bitmex) GetFee

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

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

func (*Bitmex) GetID

func (e *Bitmex) GetID() int

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

func (*Bitmex) GetLotSize

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

func (*Bitmex) GetName

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

func (*Bitmex) GetPairBySymbol

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

func (*Bitmex) GetPairConstraint

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

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

func (*Bitmex) GetPairs

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

func (*Bitmex) GetPairsData

func (e *Bitmex) 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 (*Bitmex) GetPriceFilter

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

func (*Bitmex) GetSymbolByCoin

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

func (*Bitmex) GetSymbolByPair

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

func (*Bitmex) GetTradingWebURL

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

func (*Bitmex) GetTxFee

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

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

func (*Bitmex) HasPair

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

func (*Bitmex) InitData

func (e *Bitmex) InitData() error

func (*Bitmex) LimitBuy

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

func (*Bitmex) LimitSell

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

func (*Bitmex) ListOrders

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

func (*Bitmex) LoadPublicData

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

func (*Bitmex) OrderBook

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

Get Pair Market Depth Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Get Exchange Pair Code ex. symbol := e.GetPairCode(p) Step 4: Modify API Path(strRequestUrl) Step 5: Add Params - Depend on API request Step 6: Convert the response to Standard Maker struct

func (*Bitmex) OrderStatus

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

func (*Bitmex) SetCoinConstraint

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

func (*Bitmex) SetPairConstraint

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

func (*Bitmex) UpdateAllBalances

func (e *Bitmex) UpdateAllBalances()

func (*Bitmex) UpdateConstraint

func (e *Bitmex) UpdateConstraint()

func (*Bitmex) Withdraw

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

Withdraw(coin *coin.Coin, quantity float64, addr, tag string)

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Message string `json:"message"`
		Name    string `json:"name"`
	} `json:"error"`
}

type OrderBook

type OrderBook []struct {
	Symbol string  `json:"symbol"`
	ID     int64   `json:"id"`
	Side   string  `json:"side"`
	Size   float64 `json:"size"`
	Price  float64 `json:"price"`
}

type PairsData

type PairsData []struct {
	Symbol                         string      `json:"symbol"`
	RootSymbol                     string      `json:"rootSymbol"`
	State                          string      `json:"state"`
	Typ                            string      `json:"typ"`
	Listing                        time.Time   `json:"listing"`
	Front                          time.Time   `json:"front"`
	Expiry                         time.Time   `json:"expiry"`
	Settle                         time.Time   `json:"settle"`
	RelistInterval                 interface{} `json:"relistInterval"`
	InverseLeg                     string      `json:"inverseLeg"`
	SellLeg                        string      `json:"sellLeg"`
	BuyLeg                         string      `json:"buyLeg"`
	OptionStrikePcnt               interface{} `json:"optionStrikePcnt"`
	OptionStrikeRound              interface{} `json:"optionStrikeRound"`
	OptionStrikePrice              interface{} `json:"optionStrikePrice"`
	OptionMultiplier               interface{} `json:"optionMultiplier"`
	PositionCurrency               string      `json:"positionCurrency"`
	Underlying                     string      `json:"underlying"`
	QuoteCurrency                  string      `json:"quoteCurrency"`
	UnderlyingSymbol               string      `json:"underlyingSymbol"`
	Reference                      string      `json:"reference"`
	ReferenceSymbol                string      `json:"referenceSymbol"`
	CalcInterval                   interface{} `json:"calcInterval"`
	PublishInterval                interface{} `json:"publishInterval"`
	PublishTime                    interface{} `json:"publishTime"`
	MaxOrderQty                    float64     `json:"maxOrderQty"`
	MaxPrice                       float64     `json:"maxPrice"`
	LotSize                        float64     `json:"lotSize"`
	TickSize                       float64     `json:"tickSize"`
	Multiplier                     int         `json:"multiplier"`
	SettlCurrency                  string      `json:"settlCurrency"`
	UnderlyingToPositionMultiplier int         `json:"underlyingToPositionMultiplier"`
	UnderlyingToSettleMultiplier   interface{} `json:"underlyingToSettleMultiplier"`
	QuoteToSettleMultiplier        int         `json:"quoteToSettleMultiplier"`
	IsQuanto                       bool        `json:"isQuanto"`
	IsInverse                      bool        `json:"isInverse"`
	InitMargin                     float64     `json:"initMargin"`
	MaintMargin                    float64     `json:"maintMargin"`
	RiskLimit                      int64       `json:"riskLimit"`
	RiskStep                       int64       `json:"riskStep"`
	Limit                          interface{} `json:"limit"`
	Capped                         bool        `json:"capped"`
	Taxed                          bool        `json:"taxed"`
	Deleverage                     bool        `json:"deleverage"`
	MakerFee                       float64     `json:"makerFee"`
	TakerFee                       float64     `json:"takerFee"`
	SettlementFee                  float64     `json:"settlementFee"`
	InsuranceFee                   int         `json:"insuranceFee"`
	FundingBaseSymbol              string      `json:"fundingBaseSymbol"`
	FundingQuoteSymbol             string      `json:"fundingQuoteSymbol"`
	FundingPremiumSymbol           string      `json:"fundingPremiumSymbol"`
	FundingTimestamp               interface{} `json:"fundingTimestamp"`
	FundingInterval                interface{} `json:"fundingInterval"`
	FundingRate                    interface{} `json:"fundingRate"`
	IndicativeFundingRate          interface{} `json:"indicativeFundingRate"`
	RebalanceTimestamp             interface{} `json:"rebalanceTimestamp"`
	RebalanceInterval              interface{} `json:"rebalanceInterval"`
	OpeningTimestamp               time.Time   `json:"openingTimestamp"`
	ClosingTimestamp               time.Time   `json:"closingTimestamp"`
	SessionInterval                time.Time   `json:"sessionInterval"`
	PrevClosePrice                 float64     `json:"prevClosePrice"`
	LimitDownPrice                 interface{} `json:"limitDownPrice"`
	LimitUpPrice                   interface{} `json:"limitUpPrice"`
	BankruptLimitDownPrice         interface{} `json:"bankruptLimitDownPrice"`
	BankruptLimitUpPrice           interface{} `json:"bankruptLimitUpPrice"`
	PrevTotalVolume                float64     `json:"prevTotalVolume"`
	TotalVolume                    float64     `json:"totalVolume"`
	Volume                         float64     `json:"volume"`
	Volume24H                      float64     `json:"volume24h"`
	PrevTotalTurnover              int64       `json:"prevTotalTurnover"`
	TotalTurnover                  int64       `json:"totalTurnover"`
	Turnover                       int64       `json:"turnover"`
	Turnover24H                    int64       `json:"turnover24h"`
	HomeNotional24H                float64     `json:"homeNotional24h"`
	ForeignNotional24H             float64     `json:"foreignNotional24h"`
	PrevPrice24H                   float64     `json:"prevPrice24h"`
	Vwap                           float64     `json:"vwap"`
	HighPrice                      float64     `json:"highPrice"`
	LowPrice                       float64     `json:"lowPrice"`
	LastPrice                      float64     `json:"lastPrice"`
	LastPriceProtected             float64     `json:"lastPriceProtected"`
	LastTickDirection              string      `json:"lastTickDirection"`
	LastChangePcnt                 float64     `json:"lastChangePcnt"`
	BidPrice                       float64     `json:"bidPrice"`
	MidPrice                       float64     `json:"midPrice"`
	AskPrice                       float64     `json:"askPrice"`
	ImpactBidPrice                 float64     `json:"impactBidPrice"`
	ImpactMidPrice                 float64     `json:"impactMidPrice"`
	ImpactAskPrice                 float64     `json:"impactAskPrice"`
	HasLiquidity                   bool        `json:"hasLiquidity"`
	OpenInterest                   float64     `json:"openInterest"`
	OpenValue                      int64       `json:"openValue"`
	FairMethod                     string      `json:"fairMethod"`
	FairBasisRate                  float64     `json:"fairBasisRate"`
	FairBasis                      float64     `json:"fairBasis"`
	FairPrice                      float64     `json:"fairPrice"`
	MarkMethod                     string      `json:"markMethod"`
	MarkPrice                      float64     `json:"markPrice"`
	IndicativeTaxRate              float64     `json:"indicativeTaxRate"`
	IndicativeSettlePrice          float64     `json:"indicativeSettlePrice"`
	OptionUnderlyingPrice          interface{} `json:"optionUnderlyingPrice"`
	SettledPrice                   interface{} `json:"settledPrice"`
	Timestamp                      time.Time   `json:"timestamp"`
}

type PlaceOrder

type PlaceOrder struct {
	OrderID               string      `json:"orderID"`
	ClOrdID               string      `json:"clOrdID"`
	ClOrdLinkID           string      `json:"clOrdLinkID"`
	Account               int         `json:"account"`
	Symbol                string      `json:"symbol"`
	Side                  string      `json:"side"`
	SimpleOrderQty        float64     `json:"simpleOrderQty"`
	OrderQty              interface{} `json:"orderQty"`
	Price                 float64     `json:"price"`
	DisplayQty            interface{} `json:"displayQty"`
	StopPx                interface{} `json:"stopPx"`
	PegOffsetValue        interface{} `json:"pegOffsetValue"`
	PegPriceType          string      `json:"pegPriceType"`
	Currency              string      `json:"currency"`
	SettlCurrency         string      `json:"settlCurrency"`
	OrdType               string      `json:"ordType"`
	TimeInForce           string      `json:"timeInForce"`
	ExecInst              string      `json:"execInst"`
	ContingencyType       string      `json:"contingencyType"`
	ExDestination         string      `json:"exDestination"`
	OrdStatus             string      `json:"ordStatus"`
	Triggered             string      `json:"triggered"`
	WorkingIndicator      bool        `json:"workingIndicator"`
	OrdRejReason          string      `json:"ordRejReason"`
	SimpleLeavesQty       float64     `json:"simpleLeavesQty"`
	LeavesQty             float64     `json:"leavesQty"`
	SimpleCumQty          float64     `json:"simpleCumQty"`
	CumQty                float64     `json:"cumQty"`
	AvgPx                 float64     `json:"avgPx"`
	MultiLegReportingType string      `json:"multiLegReportingType"`
	Text                  string      `json:"text"`
	TransactTime          time.Time   `json:"transactTime"`
	Timestamp             time.Time   `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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