Documentation ¶
Index ¶
- func ConvertAddReduceMarginRequestToParams(req *AddReduceMarginRequest) client.Params
- func ConvertConfirmNewRiskLimitRequestToParams(req *ConfirmNewRiskLimitRequest) client.Params
- func ConvertGetClosedPnLRequestToParams(req *GetClosedPnLRequest) client.Params
- func ConvertGetMovePositionHistoryRequestToParams(req *GetMovePositionHistoryRequest) client.Params
- func ConvertMovePositionRequestToParams(req *MovePositionRequest) client.Params
- func ConvertPositionRequestParams(params *RequestParams) client.Params
- func ConvertSetAutoAddMarginRequestToParams(req *SetAutoAddMarginRequest) client.Params
- func ConvertSetLeverageRequestToParams(req *SetLeverageRequest) client.Params
- func ConvertSetRiskLimitRequestToParams(req *SetRiskLimitRequest) client.Params
- func ConvertSetTPSLModeRequestToParams(req *SetTPSLModeRequest) client.Params
- func ConvertSetTradingStopRequestToParams(req *SetTradingStopRequest) client.Params
- func ConvertSwitchMarginModeRequestToParams(req *SwitchMarginModeRequest) client.Params
- func ConvertSwitchPositionModeRequestToParams(req *SwitchPositionModeRequest) client.Params
- type AddReduceMarginRequest
- type ClosedPnLResponse
- type ConfirmNewRiskLimitRequest
- type Details
- type GetClosedPnLRequest
- type GetMovePositionHistoryRequest
- type GetMovePositionHistoryResponse
- type MovePositionHistoryEntry
- type MovePositionRequest
- type MovePositionRequestLeg
- type MovePositionResponse
- type Position
- type RequestParams
- type Response
- type SetAutoAddMarginRequest
- type SetLeverageRequest
- type SetRiskLimitRequest
- type SetTPSLModeRequest
- type SetTradingStopRequest
- type SwitchMarginModeRequest
- type SwitchPositionModeRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertAddReduceMarginRequestToParams ¶
func ConvertAddReduceMarginRequestToParams(req *AddReduceMarginRequest) client.Params
func ConvertConfirmNewRiskLimitRequestToParams ¶
func ConvertConfirmNewRiskLimitRequestToParams(req *ConfirmNewRiskLimitRequest) client.Params
func ConvertGetClosedPnLRequestToParams ¶
func ConvertGetClosedPnLRequestToParams(req *GetClosedPnLRequest) client.Params
func ConvertGetMovePositionHistoryRequestToParams ¶
func ConvertGetMovePositionHistoryRequestToParams(req *GetMovePositionHistoryRequest) client.Params
func ConvertMovePositionRequestToParams ¶
func ConvertMovePositionRequestToParams(req *MovePositionRequest) client.Params
func ConvertPositionRequestParams ¶
func ConvertPositionRequestParams(params *RequestParams) client.Params
ConvertPositionRequestParams prepares the request parameters for fetching position info.
func ConvertSetAutoAddMarginRequestToParams ¶
func ConvertSetAutoAddMarginRequestToParams(req *SetAutoAddMarginRequest) client.Params
func ConvertSetLeverageRequestToParams ¶
func ConvertSetLeverageRequestToParams(req *SetLeverageRequest) client.Params
func ConvertSetRiskLimitRequestToParams ¶
func ConvertSetRiskLimitRequestToParams(req *SetRiskLimitRequest) client.Params
func ConvertSetTPSLModeRequestToParams ¶
func ConvertSetTPSLModeRequestToParams(req *SetTPSLModeRequest) client.Params
func ConvertSetTradingStopRequestToParams ¶
func ConvertSetTradingStopRequestToParams(req *SetTradingStopRequest) client.Params
func ConvertSwitchMarginModeRequestToParams ¶
func ConvertSwitchMarginModeRequestToParams(req *SwitchMarginModeRequest) client.Params
func ConvertSwitchPositionModeRequestToParams ¶
func ConvertSwitchPositionModeRequestToParams(req *SwitchPositionModeRequest) client.Params
Types ¶
type AddReduceMarginRequest ¶
type AddReduceMarginRequest struct { Category string `json:"category"` // Required: "linear" or "inverse" Symbol string `json:"symbol"` // Required: Symbol name Margin string `json:"margin"` // Required: Amount to add (positive) or reduce (negative) PositionIdx *int `json:"positionIdx"` // Optional: Position index for hedge mode }
AddReduceMarginRequest represents the payload for adding or reducing margin.
type ClosedPnLResponse ¶
type ClosedPnLResponse struct { RetCode int `json:"retCode"` RetMsg string `json:"retMsg"` Result struct { NextPageCursor string `json:"nextPageCursor"` Category string `json:"category"` List []interface{} `json:"list"` } `json:"result"` RetExtInfo interface{} `json:"retExtInfo"` Time int64 `json:"time"` }
ClosedPnLResponse represents the response structure for closed PnL records.
type ConfirmNewRiskLimitRequest ¶
type ConfirmNewRiskLimitRequest struct { Category string `json:"category"` // Required: "linear" or "inverse" Symbol string `json:"symbol"` // Required: Symbol name }
ConfirmNewRiskLimitRequest represents the payload for confirming a new risk limit.
type Details ¶
type Details struct { PositionIdx int `json:"positionIdx"` RiskID int `json:"riskId"` RiskLimitValue string `json:"riskLimitValue"` Symbol string `json:"symbol"` Side string `json:"side"` Size string `json:"size"` AvgPrice string `json:"avgPrice"` PositionValue string `json:"positionValue"` TradeMode int `json:"tradeMode"` PositionStatus string `json:"positionStatus"` AutoAddMargin int `json:"autoAddMargin"` AdlRankIndicator int `json:"adlRankIndicator"` Leverage string `json:"leverage"` PositionBalance string `json:"positionBalance"` MarkPrice string `json:"markPrice"` LiqPrice string `json:"liqPrice"` BustPrice string `json:"bustPrice"` PositionMM string `json:"positionMM"` PositionIM string `json:"positionIM"` TpslMode string `json:"tpslMode"` TakeProfit string `json:"takeProfit"` StopLoss string `json:"stopLoss"` TrailingStop string `json:"trailingStop"` UnrealisedPnl string `json:"unrealisedPnl"` CumRealisedPnl string `json:"cumRealisedPnl"` Seq int64 `json:"seq"` IsReduceOnly bool `json:"isReduceOnly"` MmrSysUpdateTime string `json:"mmrSysUpdateTime"` LeverageSysUpdatedTime string `json:"leverageSysUpdatedTime"` CreatedTime string `json:"createdTime"` UpdatedTime string `json:"updatedTime"` }
Details represent the details of a single position.
type GetClosedPnLRequest ¶
type GetClosedPnLRequest struct { Category string `json:"category"` // Required: "linear" or "inverse" Symbol *string `json:"symbol,omitempty"` // Optional: Symbol name StartTime *int64 `json:"startTime,omitempty"` // Optional: The start timestamp (ms) EndTime *int64 `json:"endTime,omitempty"` // Optional: The end timestamp (ms) Limit *int `json:"limit,omitempty"` // Optional: Limit for data size per page Cursor *string `json:"cursor,omitempty"` // Optional: Cursor for pagination }
GetClosedPnLRequest represents the query parameters for fetching closed PnL records.
type GetMovePositionHistoryRequest ¶
type GetMovePositionHistoryRequest struct { Category *string `json:"category,omitempty"` // Optional: Product type Symbol *string `json:"symbol,omitempty"` // Optional: Symbol name StartTime *int64 `json:"startTime,omitempty"` // Optional: Start timestamp EndTime *int64 `json:"endTime,omitempty"` // Optional: End timestamp Status *string `json:"status,omitempty"` // Optional: Order status BlockTradeId *string `json:"blockTradeId,omitempty"` // Optional: Block trade ID Limit *int `json:"limit,omitempty"` // Optional: Data size limit per page Cursor *string `json:"cursor,omitempty"` // Optional: Pagination cursor }
GetMovePositionHistoryRequest represents the query parameters for fetching move position history.
type GetMovePositionHistoryResponse ¶
type GetMovePositionHistoryResponse struct { RetCode int `json:"retCode"` RetMsg string `json:"retMsg"` Result struct { List []MovePositionHistoryEntry `json:"list"` NextPageCursor string `json:"nextPageCursor"` } `json:"result"` RetExtInfo interface{} `json:"retExtInfo"` Time int64 `json:"time"` }
GetMovePositionHistoryResponse represents the response from fetching move position history.
type MovePositionHistoryEntry ¶
type MovePositionHistoryEntry struct { BlockTradeId string `json:"blockTradeId"` Category string `json:"category"` OrderId string `json:"orderId"` UserId int `json:"userId"` Symbol string `json:"symbol"` Side string `json:"side"` Price string `json:"price"` Qty string `json:"qty"` ExecFee string `json:"execFee"` Status string `json:"status"` ExecId string `json:"execId"` ResultCode int `json:"resultCode"` ResultMessage string `json:"resultMessage"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` RejectParty string `json:"rejectParty"` }
MovePositionHistoryEntry represents a single entry in the move position history.
type MovePositionRequest ¶
type MovePositionRequest struct { FromUID string `json:"fromUid"` ToUID string `json:"toUid"` List []MovePositionRequestLeg `json:"list"` }
MovePositionRequest encapsulates the payload for moving positions.
type MovePositionRequestLeg ¶
type MovePositionRequestLeg struct { Category string `json:"category"` // "linear", "spot", "option" Symbol string `json:"symbol"` Price string `json:"price"` Side string `json:"side"` // "Buy" or "Sell" Qty string `json:"qty"` }
MovePositionRequestLeg represents a single leg of a move position request.
type MovePositionResponse ¶
type MovePositionResponse struct { RetCode int `json:"retCode"` RetMsg string `json:"retMsg"` Result struct { BlockTradeId string `json:"blockTradeId"` Status string `json:"status"` RejectParty string `json:"rejectParty"` } `json:"result"` }
MovePositionResponse represents the response from a move position request.
type Position ¶
type Position interface { // GetPositionInfo get position info GetPositionInfo(params *RequestParams) (*Response, error) // SetLeverage set leverage for position info request SetLeverage(req *SetLeverageRequest) (*Response, error) // GetLeverage get leverage for position info request SwitchMarginMode(req *SwitchMarginModeRequest) (*Response, error) // SetTPSLMode sets the TP/SL mode for a given symbol. SetTPSLMode(req *SetTPSLModeRequest) (*Response, error) // SwitchPositionMode switches the position mode for USDT perpetual and Inverse futures. SwitchPositionMode(req *SwitchPositionModeRequest) (*Response, error) // SetRiskLimit sets the risk limit for a specific symbol. SetRiskLimit(req *SetRiskLimitRequest) (*Response, error) // SetTradingStop sets take profit, stop loss, or trailing stop for the position. SetTradingStop(req *SetTradingStopRequest) (*Response, error) // SetAutoAddMargin toggles auto-add-margin for an isolated margin position. SetAutoAddMargin(req *SetAutoAddMarginRequest) (*Response, error) // AddOrReduceMargin manually adds or reduces margin for an isolated margin position. AddOrReduceMargin(req *AddReduceMarginRequest) (*Response, error) // MovePositions transfers positions between UIDs. MovePositions(req *MovePositionRequest) (*MovePositionResponse, error) // GetMovePositionHistory queries the history of moved positions. GetMovePositionHistory(req *GetMovePositionHistoryRequest) (*GetMovePositionHistoryResponse, error) // ConfirmNewRiskLimit confirms the new risk limit for a position, removing the reduceOnly mark if successful. ConfirmNewRiskLimit(req *ConfirmNewRiskLimitRequest) (*Response, error) }
type RequestParams ¶
type RequestParams struct { Category *string `json:"category"` Symbol *string `json:"symbol"` BaseCoin *string `json:"baseCoin"` SettleCoin *string `json:"settleCoin"` Limit *int `json:"limit"` Cursor *string `json:"cursor"` }
RequestParams represents the query parameters for fetching position information.
type Response ¶
type Response struct { RetCode int `json:"retCode"` RetMsg string `json:"retMsg"` Result struct { List []Details `json:"list"` NextPageCursor string `json:"nextPageCursor"` Category string `json:"category"` } `json:"result"` RetExtInfo interface{} `json:"retExtInfo"` Time int64 `json:"time"` }
Response represents the response structure for position information.
type SetAutoAddMarginRequest ¶
type SetAutoAddMarginRequest struct { Category string `json:"category"` // Required: "linear" or "inverse" Symbol string `json:"symbol"` // Required: Symbol name AutoAddMargin int `json:"autoAddMargin"` // Required: 0 for off, 1 for on PositionIdx *int `json:"positionIdx,omitempty"` // Optional: Position index for hedge mode }
SetAutoAddMarginRequest represents the payload for toggling auto-add-margin.
type SetLeverageRequest ¶
type SetLeverageRequest struct { Category *string `json:"category"` Symbol *string `json:"symbol"` BuyLeverage *string `json:"buyLeverage"` SellLeverage *string `json:"sellLeverage"` }
SetLeverageRequest represents the payload for setting leverage.
type SetRiskLimitRequest ¶
type SetRiskLimitRequest struct { Category string `json:"category"` // Required: "linear" or "inverse" Symbol string `json:"symbol"` // Required: Symbol name RiskID int `json:"riskId"` // Required: Risk limit ID PositionIdx *int `json:"positionIdx"` // Optional: Position index (for hedge mode) }
SetRiskLimitRequest represents the payload for setting the risk limit of a position.
type SetTPSLModeRequest ¶
type SetTPSLModeRequest struct { Category *string `json:"category"` Symbol *string `json:"symbol"` TPSLMode *string `json:"tpSlMode"` // "Full" or "Partial" }
SetTPSLModeRequest represents the payload for setting the TP/SL mode.
type SetTradingStopRequest ¶
type SetTradingStopRequest struct { Category string `json:"category"` // Required Symbol string `json:"symbol"` // Required TakeProfit *string `json:"takeProfit,omitempty"` // Optional, 0 to cancel StopLoss *string `json:"stopLoss,omitempty"` // Optional, 0 to cancel TrailingStop *string `json:"trailingStop,omitempty"` // Optional, 0 to cancel TpTriggerBy *string `json:"tpTriggerBy,omitempty"` // Optional SlTriggerBy *string `json:"slTriggerBy,omitempty"` // Optional ActivePrice *string `json:"activePrice,omitempty"` // Optional TPSLMode string `json:"tpslMode"` // Required TpSize *string `json:"tpSize,omitempty"` // Optional SlSize *string `json:"slSize,omitempty"` // Optional TpLimitPrice *string `json:"tpLimitPrice,omitempty"` // Optional SlLimitPrice *string `json:"slLimitPrice,omitempty"` // Optional TpOrderType *string `json:"tpOrderType,omitempty"` // Optional SlOrderType *string `json:"slOrderType,omitempty"` // Optional PositionIdx int `json:"positionIdx"` // Required }
SetTradingStopRequest represents the payload for setting trading stops (TP, SL, TS).
type SwitchMarginModeRequest ¶
type SwitchPositionModeRequest ¶
type SwitchPositionModeRequest struct { Category string `json:"category"` // Required: "linear" for USDT Perp, "inverse" for Inverse Futures Symbol *string `json:"symbol,omitempty"` // Optional: Symbol name; either symbol or coin is required Coin *string `json:"coin,omitempty"` // Optional: Coin; either symbol or coin is required Mode *int `json:"mode"` // Required: 0 for Merged Single, 3 for Both Sides }
SwitchPositionModeRequest represents the payload for switching the position mode.