Documentation
¶
Index ¶
- type Config
- type Exchange
- func (e *Exchange) ApiClient() *gateapi.APIClient
- func (e *Exchange) ApiCtx() context.Context
- func (e *Exchange) CancelFuturesOrder(orderId string) (out gateapi.FuturesOrder, err error)
- func (e *Exchange) CancelFuturesOrders(contract string, side string) (out []gateapi.FuturesOrder, err error)
- func (e *Exchange) CreateFuturesOrder(futuresOrder gateapi.FuturesOrder) (out gateapi.FuturesOrder, err error)
- func (e *Exchange) GetAccountDetail() (out gateapi.AccountDetail, err error)
- func (e *Exchange) GetDualModePosition(contract string) (out []gateapi.Position, err error)
- func (e *Exchange) GetFuturesContract(contract string) (out gateapi.Contract, err error)
- func (e *Exchange) GetPosition(contract string) (out gateapi.Position, err error)
- func (e *Exchange) GetTotalBalance() (out gateapi.TotalBalance, err error)
- func (e *Exchange) ListCurrencyPairs() (out []gateapi.CurrencyPair, err error)
- func (e *Exchange) ListFuturesAccountBook(contract, type_ string, limit, offset int32, from, to int64) (out []gateapi.FuturesAccountBook, err error)
- func (e *Exchange) ListFuturesAccounts() (out gateapi.FuturesAccount, err error)
- func (e *Exchange) ListFuturesCandlesticks(contract string, from int64, to int64, limit int32, interval string) (out FuturesCandlesticks, err error)
- func (e *Exchange) ListFuturesContract() (out []gateapi.Contract, err error)
- func (e *Exchange) ListFuturesOrderBook(contract string, limit int32, interval string) (out gateapi.FuturesOrderBook, err error)
- func (e *Exchange) ListFuturesOrders(contract string, status string, limit int32, offset int32, lastId string) (out []gateapi.FuturesOrder, err error)
- func (e *Exchange) ListFuturesTickers(contract string) (out []gateapi.FuturesTicker, err error)
- func (e *Exchange) ListPositionClose(contract string, limit, offset int32, from, to int64, side, pnl string) (out []gateapi.PositionClose, err error)
- func (e *Exchange) ListPositions(holding bool) (out []gateapi.Position, err error)
- func (e *Exchange) SetDualMode(dualMode bool) (out gateapi.FuturesAccount, err error)
- func (e *Exchange) Settle() string
- func (e *Exchange) Transfer(settle, currency, from, to, amount string) (out gateapi.TransactionId, err error)
- func (e *Exchange) UID() string
- func (e *Exchange) UpdatePositionLeverage(contract, leverage string, isCross bool) (out gateapi.Position, err error)
- func (e *Exchange) WsFuturesClient() *gatews.WsService
- func (e *Exchange) WsSpotClient() *gatews.WsService
- type FuturesCandlesticks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string `json:"name"` //交易所名称 name
ApiKey string `json:"api_key"` //交易所api key
ApiSecretKey string `json:"api_secret_key"` //交易所secret key
ApiPassphrase string `json:"api_passphrase"` //交易所API密码
ProxyUrl string `json:"proxy_url"` //代理服务器地址
Settle string `json:"settle"` //现货为计价币种,合约为结算币种
}
type Exchange ¶
type Exchange struct {
Config *Config `json:"config"` //exchange config
// contains filtered or unexported fields
}
func NewExchange ¶
func (*Exchange) CancelFuturesOrder ¶
func (e *Exchange) CancelFuturesOrder(orderId string) (out gateapi.FuturesOrder, err error)
func (*Exchange) CancelFuturesOrders ¶
func (*Exchange) CreateFuturesOrder ¶
func (e *Exchange) CreateFuturesOrder(futuresOrder gateapi.FuturesOrder) (out gateapi.FuturesOrder, err error)
func (*Exchange) GetAccountDetail ¶
func (e *Exchange) GetAccountDetail() (out gateapi.AccountDetail, err error)
func (*Exchange) GetDualModePosition ¶
func (*Exchange) GetFuturesContract ¶
GetFuturesContract Get a single contract
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param settle Settle currency
- @param contract Futures contract
@return Contract
func (*Exchange) GetPosition ¶
func (*Exchange) GetTotalBalance ¶
func (e *Exchange) GetTotalBalance() (out gateapi.TotalBalance, err error)
func (*Exchange) ListCurrencyPairs ¶
func (e *Exchange) ListCurrencyPairs() (out []gateapi.CurrencyPair, err error)
func (*Exchange) ListFuturesAccountBook ¶
func (e *Exchange) ListFuturesAccountBook(contract, type_ string, limit, offset int32, from, to int64) (out []gateapi.FuturesAccountBook, err error)
ListFuturesAccountBook 查询合约账户变更历史
func (*Exchange) ListFuturesAccounts ¶
func (e *Exchange) ListFuturesAccounts() (out gateapi.FuturesAccount, err error)
ListFuturesAccounts Query futures account
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param settle Settle currency
@return FuturesAccount
func (*Exchange) ListFuturesCandlesticks ¶
func (e *Exchange) ListFuturesCandlesticks(contract string, from int64, to int64, limit int32, interval string) (out FuturesCandlesticks, err error)
ListFuturesCandlesticks Get futures candlesticks Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval`
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param settle Settle currency
- @param contract Futures contract
- @param optional nil or *ListFuturesCandlesticksOpts - Optional Parameters:
- @param "From" (optional.Int64) - Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
- @param "To" (optional.Int64) - End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
- @param "Limit" (optional.Int32) - Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
- @param "Interval" (optional.String) - Interval time between data points
@return []FuturesCandlestick
func (*Exchange) ListFuturesContract ¶
func (*Exchange) ListFuturesOrderBook ¶
func (*Exchange) ListFuturesOrders ¶
func (*Exchange) ListFuturesTickers ¶
func (e *Exchange) ListFuturesTickers(contract string) (out []gateapi.FuturesTicker, err error)
func (*Exchange) ListPositionClose ¶
func (e *Exchange) ListPositionClose(contract string, limit, offset int32, from, to int64, side, pnl string) (out []gateapi.PositionClose, err error)
ListPositionClose 查询平仓历史 - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param settle Settle currency - @param optional nil or *ListPositionCloseOpts - Optional Parameters: - @param "Contract" (optional.String) - Futures contract, return related data only if specified - @param "Limit" (optional.Int32) - Maximum number of records to be returned in a single list - @param "Offset" (optional.Int32) - List offset, starting from 0 - @param "From" (optional.Int64) - Start timestamp - @param "To" (optional.Int64) - End timestamp - @param "Side" (optional.String) - Query side. long or shot - @param "Pnl" (optional.String) - Query profit or loss
func (*Exchange) ListPositions ¶
func (*Exchange) SetDualMode ¶
func (e *Exchange) SetDualMode(dualMode bool) (out gateapi.FuturesAccount, err error)
func (*Exchange) Transfer ¶
func (e *Exchange) Transfer(settle, currency, from, to, amount string) (out gateapi.TransactionId, err error)
func (*Exchange) UpdatePositionLeverage ¶
func (*Exchange) WsFuturesClient ¶
func (*Exchange) WsSpotClient ¶
type FuturesCandlesticks ¶
type FuturesCandlesticks []gateapi.FuturesCandlestick
func (FuturesCandlesticks) ToCandlesticks ¶
func (f FuturesCandlesticks) ToCandlesticks() common.Candlesticks
func (FuturesCandlesticks) ToOhlcv ¶
func (f FuturesCandlesticks) ToOhlcv() common.OHLCV