spider

package
v2.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteHostTypeBinance = iota
	RemoteHostTypeOKEX
)
View Source
const (
	SideTypeBuy  SideType = "BUY"
	SideTypeSell SideType = "SELL"

	PositionSideTypeBoth  PositionSideType = "BOTH"
	PositionSideTypeLong  PositionSideType = "LONG"
	PositionSideTypeShort PositionSideType = "SHORT"

	OrderTypeLimit              OrderType = "LIMIT"
	OrderTypeMarket             OrderType = "MARKET"
	OrderTypeStop               OrderType = "STOP"
	OrderTypeStopMarket         OrderType = "STOP_MARKET"
	OrderTypeTakeProfit         OrderType = "TAKE_PROFIT"
	OrderTypeTakeProfitMarket   OrderType = "TAKE_PROFIT_MARKET"
	OrderTypeTrailingStopMarket OrderType = "TRAILING_STOP_MARKET"

	TimeInForceTypeGTC TimeInForceType = "GTC" // Good Till Cancel
	TimeInForceTypeIOC TimeInForceType = "IOC" // Immediate or Cancel
	TimeInForceTypeFOK TimeInForceType = "FOK" // Fill or Kill
	TimeInForceTypeGTX TimeInForceType = "GTX" // Good Till Crossing (Post Only)

	NewOrderRespTypeACK    NewOrderRespType = "ACK"
	NewOrderRespTypeRESULT NewOrderRespType = "RESULT"

	OrderExecutionTypeNew         OrderExecutionType = "NEW"
	OrderExecutionTypePartialFill OrderExecutionType = "PARTIAL_FILL"
	OrderExecutionTypeFill        OrderExecutionType = "FILL"
	OrderExecutionTypeCanceled    OrderExecutionType = "CANCELED"
	OrderExecutionTypeCalculated  OrderExecutionType = "CALCULATED"
	OrderExecutionTypeExpired     OrderExecutionType = "EXPIRED"
	OrderExecutionTypeTrade       OrderExecutionType = "TRADE"

	OrderStatusTypeNew             OrderStatusType = "NEW"
	OrderStatusTypePartiallyFilled OrderStatusType = "PARTIALLY_FILLED"
	OrderStatusTypeFilled          OrderStatusType = "FILLED"
	OrderStatusTypeCanceled        OrderStatusType = "CANCELED"
	OrderStatusTypeRejected        OrderStatusType = "REJECTED"
	OrderStatusTypeExpired         OrderStatusType = "EXPIRED"
	OrderStatusTypeNewInsurance    OrderStatusType = "NEW_INSURANCE"
	OrderStatusTypeNewADL          OrderStatusType = "NEW_ADL"

	SymbolTypeFuture SymbolType = "FUTURE"

	WorkingTypeMarkPrice     WorkingType = "MARK_PRICE"
	WorkingTypeContractPrice WorkingType = "CONTRACT_PRICE"

	SymbolStatusTypePreTrading   SymbolStatusType = "PRE_TRADING"
	SymbolStatusTypeTrading      SymbolStatusType = "TRADING"
	SymbolStatusTypePostTrading  SymbolStatusType = "POST_TRADING"
	SymbolStatusTypeEndOfDay     SymbolStatusType = "END_OF_DAY"
	SymbolStatusTypeHalt         SymbolStatusType = "HALT"
	SymbolStatusTypeAuctionMatch SymbolStatusType = "AUCTION_MATCH"
	SymbolStatusTypeBreak        SymbolStatusType = "BREAK"

	SymbolFilterTypeLotSize          SymbolFilterType = "LOT_SIZE"
	SymbolFilterTypePrice            SymbolFilterType = "PRICE_FILTER"
	SymbolFilterTypePercentPrice     SymbolFilterType = "PERCENT_PRICE"
	SymbolFilterTypeMarketLotSize    SymbolFilterType = "MARKET_LOT_SIZE"
	SymbolFilterTypeMaxNumOrders     SymbolFilterType = "MAX_NUM_ORDERS"
	SymbolFilterTypeMaxNumAlgoOrders SymbolFilterType = "MAX_NUM_ALGO_ORDERS"
	SymbolFilterTypeMinNotional      SymbolFilterType = "MIN_NOTIONAL"

	SideEffectTypeNoSideEffect SideEffectType = "NO_SIDE_EFFECT"
	SideEffectTypeMarginBuy    SideEffectType = "MARGIN_BUY"
	SideEffectTypeAutoRepay    SideEffectType = "AUTO_REPAY"

	MarginTypeIsolated MarginType = "ISOLATED"
	MarginTypeCrossed  MarginType = "CROSSED"

	ContractTypePerpetual ContractType = "PERPETUAL"

	UserDataEventTypeListenKeyExpired    UserDataEventType = "listenKeyExpired"
	UserDataEventTypeMarginCall          UserDataEventType = "MARGIN_CALL"
	UserDataEventTypeAccountUpdate       UserDataEventType = "ACCOUNT_UPDATE"
	UserDataEventTypeOrderTradeUpdate    UserDataEventType = "ORDER_TRADE_UPDATE"
	UserDataEventTypeAccountConfigUpdate UserDataEventType = "ACCOUNT_CONFIG_UPDATE"

	UserDataEventReasonTypeDeposit             UserDataEventReasonType = "DEPOSIT"
	UserDataEventReasonTypeWithdraw            UserDataEventReasonType = "WITHDRAW"
	UserDataEventReasonTypeOrder               UserDataEventReasonType = "ORDER"
	UserDataEventReasonTypeFundingFee          UserDataEventReasonType = "FUNDING_FEE"
	UserDataEventReasonTypeWithdrawReject      UserDataEventReasonType = "WITHDRAW_REJECT"
	UserDataEventReasonTypeAdjustment          UserDataEventReasonType = "ADJUSTMENT"
	UserDataEventReasonTypeInsuranceClear      UserDataEventReasonType = "INSURANCE_CLEAR"
	UserDataEventReasonTypeAdminDeposit        UserDataEventReasonType = "ADMIN_DEPOSIT"
	UserDataEventReasonTypeAdminWithdraw       UserDataEventReasonType = "ADMIN_WITHDRAW"
	UserDataEventReasonTypeMarginTransfer      UserDataEventReasonType = "MARGIN_TRANSFER"
	UserDataEventReasonTypeMarginTypeChange    UserDataEventReasonType = "MARGIN_TYPE_CHANGE"
	UserDataEventReasonTypeAssetTransfer       UserDataEventReasonType = "ASSET_TRANSFER"
	UserDataEventReasonTypeOptionsPremiumFee   UserDataEventReasonType = "OPTIONS_PREMIUM_FEE"
	UserDataEventReasonTypeOptionsSettleProfit UserDataEventReasonType = "OPTIONS_SETTLE_PROFIT"

	ForceOrderCloseTypeLiquidation ForceOrderCloseType = "LIQUIDATION"
	ForceOrderCloseTypeADL         ForceOrderCloseType = "ADL"
)

Global enums

Variables

This section is empty.

Functions

This section is empty.

Types

type BinanceAssetPosEarnInfo added in v2.2.10

type BinanceAssetPosEarnInfo struct {
	Asset    string               `json:"asset"`
	Projects []BinancePosEarnInfo `json:"projects"`
}

type BinanceGetPosEarnListResponse added in v2.2.10

type BinanceGetPosEarnListResponse struct {
	Code    string          `json:"code"`
	Data    json.RawMessage `json:"data"`
	Total   int             `json:"total"`
	Success bool            `json:"success"`
}

type BinanceGetPosEarnListService added in v2.2.10

type BinanceGetPosEarnListService struct {
	// contains filtered or unexported fields
}

func (*BinanceGetPosEarnListService) Asset added in v2.2.10

func (*BinanceGetPosEarnListService) Do added in v2.2.10

func (*BinanceGetPosEarnListService) PageIndex added in v2.2.10

func (*BinanceGetPosEarnListService) PageSize added in v2.2.10

type BinancePosEarnConfig added in v2.2.10

type BinancePosEarnConfig struct {
	AnnualInterestRate       string `json:"annualInterestRate"`
	DailyInterestRate        string `json:"dailyInterestRate"`
	MinPurchaseAmount        string `json:"minPurchaseAmount"`
	MaxPurchaseAmountPerUser string `json:"maxPurchaseAmountPerUser"`
}

type BinancePosEarnInfo added in v2.2.10

type BinancePosEarnInfo struct {
	Asset     string               `json:"asset"`
	UpLimit   string               `json:"upLimit"`
	Purchased string               `json:"purchased"`
	Duration  string               `json:"duration"`
	Config    BinancePosEarnConfig `json:"config"`
	SellOut   bool                 `json:"sellOut"`
}

type Client

type Client struct {
	BaseURL    string
	UserAgent  string
	HTTPClient *http.Client
	Debug      bool
	Logger     *log.Logger
	TimeOffset int64
	// contains filtered or unexported fields
}

Client define API client

func NewClient

func NewClient(remoteType int) *Client

NewClient initialize an API client instance with API key and secret key. You should always call this function before using this SDK. Services will be created by the form client.NewXXXService().

func (*Client) NewBinanceGetPosEarnListService added in v2.2.10

func (c *Client) NewBinanceGetPosEarnListService() *BinanceGetPosEarnListService

func (*Client) NewOKEXGetEarnListService

func (c *Client) NewOKEXGetEarnListService() *OKEXGetEarnListService

func (*Client) NewOKEXGetFuturesInstrumentsService added in v2.2.9

func (c *Client) NewOKEXGetFuturesInstrumentsService() *OKEXGetFuturesInstrumentsService

func (*Client) NewOKEXGetFuturesMarkPriceService added in v2.2.9

func (c *Client) NewOKEXGetFuturesMarkPriceService() *OKEXGetFuturesMarkPriceService

func (*Client) NewOKEXGetServiceListService

func (c *Client) NewOKEXGetServiceListService() *OKEXGetServiceListService

func (*Client) SetProxy

func (c *Client) SetProxy(proxyUrl string)

设置代理访问

func (*Client) SetSourceAddr

func (c *Client) SetSourceAddr(srcIP string)

设置访问源IP

type ContractType

type ContractType string

ContractType define contract type

type ForceOrderCloseType

type ForceOrderCloseType string

ForceOrderCloseType define reason type for force order

type MarginType

type MarginType string

MarginType define margin type

type NewOrderRespType

type NewOrderRespType string

NewOrderRespType define response JSON verbosity

type OKEXEarnInfo

type OKEXEarnInfo struct {
	CurrencyName string            `json:"currencyName"`
	ProjectList  []OKEXServiceInfo `json:"projectList"`
}

type OKEXFuturesInstrument added in v2.2.9

type OKEXFuturesInstrument struct {
	InstrumentId        string `json:"instrument_id"`
	Underlying          string `json:"underlying"`
	BaseCurrency        string `json:"base_currency"`
	QuoteCurrency       string `json:"quote_currency"`
	SettlementCurrency  string `json:"settlement_currency"`
	ContractVal         string `json:"contract_val"`
	Listing             string `json:"listing"`
	Delivery            string `json:"delivery"`
	SizeIncrement       string `json:"size_increment"`
	TickSize            string `json:"tick_size"`
	IsInverse           string `json:"is_inverse"`
	Category            string `json:"category"`
	ContractValCurrency string `json:"contract_val_currency"`
	UnderlyingIndex     string `json:"underlying_index"`
}

type OKEXFuturesInstrumentsService added in v2.2.9

type OKEXFuturesInstrumentsService struct {
	// contains filtered or unexported fields
}

func (*OKEXFuturesInstrumentsService) BaseCurrency added in v2.2.9

func (*OKEXFuturesInstrumentsService) Do added in v2.2.9

func (s *OKEXFuturesInstrumentsService) Do(ctx context.Context, opts ...RequestOption) (data []byte, err error)

func (*OKEXFuturesInstrumentsService) InfoName added in v2.2.9

func (*OKEXFuturesInstrumentsService) QuoteCurrency added in v2.2.9

type OKEXFuturesMarkPrice added in v2.2.9

type OKEXFuturesMarkPrice struct {
	InstrumentId string `json:"instrument_id"`
	MarkPrice    string `json:"mark_price"`
	Timestamp    string `json:"timestamp"`
}

type OKEXGetEarnListService

type OKEXGetEarnListService struct {
	// contains filtered or unexported fields
}

func (*OKEXGetEarnListService) Do

func (s *OKEXGetEarnListService) Do(ctx context.Context, opts ...RequestOption) (res []*OKEXEarnInfo, err error)

func (*OKEXGetEarnListService) ProductType

type OKEXGetFuturesInstrumentsService added in v2.2.9

type OKEXGetFuturesInstrumentsService struct {
	// contains filtered or unexported fields
}

func (*OKEXGetFuturesInstrumentsService) Do added in v2.2.9

type OKEXGetFuturesMarkPriceService added in v2.2.9

type OKEXGetFuturesMarkPriceService struct {
	// contains filtered or unexported fields
}

func (*OKEXGetFuturesMarkPriceService) BaseCurrency added in v2.2.9

func (*OKEXGetFuturesMarkPriceService) Do added in v2.2.9

func (*OKEXGetFuturesMarkPriceService) QuoteCurrency added in v2.2.9

type OKEXGetServiceListService

type OKEXGetServiceListService struct {
	// contains filtered or unexported fields
}

func (*OKEXGetServiceListService) Do

func (s *OKEXGetServiceListService) Do(ctx context.Context, opts ...RequestOption) (res []*OKEXServiceInfo, err error)

Do send request

type OKEXProductType

type OKEXProductType int
const (
	OKEXProductTypeSaving  OKEXProductType = 1
	OKEXProductTypeStaking OKEXProductType = 3
)

type OKEXServiceInfo

type OKEXServiceInfo struct {
	Unit          string  `json:"unit"`
	ProductStatus bool    `json:"productStatus"`
	Status        int     `json:"status"`
	SumHold       float64 `json:"sumHold"`
	MinHold       float64 `json:"minHold"`
	MaxHold       float64 `json:"maxHold"`
	Period        string  `json:"period"`
	Rate          string  `json:"rate"`
	StartTime     int64   `json:"startTime"`
	EndTime       int64   `json:"endTime"`
}

type OKEXSpiderResponse

type OKEXSpiderResponse struct {
	Code      int             `json:"code"`
	Data      json.RawMessage `json:"data"`
	DetailMsg string          `json:"detailMsg"`
	ErrorCode string          `json:"error_code"`
	ErrorMsg  string          `json:"error_message"`
	Msg       string          `json:"msg"`
}

type OKEXStakingList

type OKEXStakingList struct {
	List json.RawMessage `json:"list"`
}

type OrderExecutionType

type OrderExecutionType string

OrderExecutionType define order execution type

type OrderStatusType

type OrderStatusType string

OrderStatusType define order status type

type OrderType

type OrderType string

OrderType define order type

type PositionSideType

type PositionSideType string

PositionSideType define position side type of order

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithHeader

func WithHeader(key, value string, replace bool) RequestOption

WithHeader set or add a header value to the request

func WithHeaders

func WithHeaders(header http.Header) RequestOption

WithHeaders set or replace the headers of the request

func WithRecvWindow

func WithRecvWindow(recvWindow int64) RequestOption

WithRecvWindow set recvWindow param for the request

type SideEffectType

type SideEffectType string

SideEffectType define side effect type for orders

type SideType

type SideType string

SideType define side type of order

type SymbolFilterType

type SymbolFilterType string

SymbolFilterType define symbol filter type

type SymbolStatusType

type SymbolStatusType string

SymbolStatusType define symbol status type

type SymbolType

type SymbolType string

SymbolType define symbol type

type TimeInForceType

type TimeInForceType string

TimeInForceType define time in force type of order

type UserDataEventReasonType

type UserDataEventReasonType string

UserDataEventReasonType define reason type for user data event

type UserDataEventType

type UserDataEventType string

UserDataEventType define user data event type

type WorkingType

type WorkingType string

WorkingType define working type

Jump to

Keyboard shortcuts

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