| | |
| | | import io.gate.gateapi.ApiClient; |
| | | import io.gate.gateapi.ApiException; |
| | | import io.gate.gateapi.GateApiException; |
| | | import io.gate.gateapi.api.AccountApi; |
| | | import io.gate.gateapi.api.FuturesApi; |
| | | import io.gate.gateapi.models.AccountDetail; |
| | | import io.gate.gateapi.models.FuturesAccount; |
| | | import io.gate.gateapi.models.FuturesInitialOrder; |
| | | import io.gate.gateapi.models.FuturesOrder; |
| | |
| | | private volatile BigDecimal lastKlinePrice; |
| | | /** 服务器返回的累计已实现盈亏 */ |
| | | private BigDecimal totalHistoryPnl = BigDecimal.ZERO; |
| | | /** 用户 ID,用于 WebSocket 私有频道订阅 */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 构造函数,初始化 Gate 期货 API 客户端。 |
| | |
| | | */ |
| | | public void init() { |
| | | try { |
| | | AccountApi accountApi = new AccountApi(apiClient); |
| | | AccountDetail accountDetail = accountApi.getAccountDetail(); |
| | | this.userId = accountDetail.getUserId(); |
| | | log.info("[GateGrid] 用户ID: {}", userId); |
| | | |
| | | futuresApi.updateContractPositionLeverageCall( |
| | | SETTLE, contract, leverage, marginMode, positionMode, null); |
| | | log.info("[GateGrid] 已设置杠杆: {}x, 保证金模式: {}", leverage, marginMode); |
| | |
| | | public BigDecimal getTotalHistoryPnl() { |
| | | return totalHistoryPnl; |
| | | } |
| | | |
| | | public Long getUserId() { |
| | | return userId; |
| | | } |
| | | } |