Administrator
3 days ago 586ae5f7391d623c5131d6482518a3070a0fff90
refactor(gateApi): 优化期货交易配置和日志记录

- 添加 lombok slf4j 注解用于日志记录
- 将常量变量名改为大写格式以提高可读性
- 更新期货账户初始化逻辑并添加初始本金日志输出
- 修正持仓模式设置方法调用和异常处理
- 移除多余参数传递简化杠杆更新调用
- 统一保证金模式字符串格式为大写
- 移除未使用的 BigDecimal 导入声明
2 files modified
19 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/Example.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 17 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/Example.java
@@ -31,7 +31,7 @@
            String SETTLE = "usdt";
            //保证金模式 isolated/cross
            String MARGINMODE = "CROSS";
            String LEVERAGE = "50";
            String LEVERAGE = "100";
            FuturesApi futuresApi = new FuturesApi(defaultClient);
            FuturesAccount account = futuresApi.listFuturesAccounts(SETTLE);
            log.info("[Gate] 初始本金: {} USDT", account.getTotal());
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -166,6 +166,14 @@
                }
            }
            try {
                futuresApi.updateDualModePositionLeverageCall(
                        SETTLE, config.getContract(), config.getLeverage(),
                        null, null).execute();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (!config.getMarginMode().equals(account.getMarginMode())) {
                UpdateDualCompPositionCrossModeRequest updateDualCompPositionCrossModeRequest = new UpdateDualCompPositionCrossModeRequest();
@@ -178,15 +186,6 @@
                }
            }
            log.info("[Gate] 持仓模式: {} 余额: {}", config.getPositionMode(), account.getAvailable());
            try {
                futuresApi.updateDualModePositionLeverageCall(
                        SETTLE, config.getContract(), config.getLeverage(),
                        null, null).execute();
            } catch (IOException e) {
                e.printStackTrace();
            }
            log.info("[Gate] 杠杆: {}x {}", config.getLeverage(), config.getMarginMode());
        } catch (GateApiException e) {
            log.error("[Gate] 初始化失败, label:{}, msg:{}", e.getErrorLabel(), e.getMessage());