Administrator
2025-12-29 8b4173d1ad4be984992b0ff7b5f04135bc8440c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.xcong.excoin.modules.okxNewPrice.okxpi.trade.impl;
 
import com.alibaba.fastjson.JSON;
import com.xcong.excoin.modules.okxNewPrice.okxpi.config.OKXAccount;
import com.xcong.excoin.modules.okxNewPrice.okxpi.config.enums.HttpMethod;
import com.xcong.excoin.modules.okxNewPrice.okxpi.config.utils.OKXContants;
import com.xcong.excoin.modules.okxNewPrice.okxpi.config.utils.ParameterChecker;
import com.xcong.excoin.modules.okxNewPrice.okxpi.trade.TradeEventEnum;
import com.xcong.excoin.modules.okxNewPrice.okxpi.trade.TradeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
 
import java.util.LinkedHashMap;
 
@Slf4j
@RequiredArgsConstructor
public class TradeServiceBuy implements TradeService {
 
    @Override
    public String tradeEvent() {
        return TradeEventEnum.TRADE_BUY.getEventPoint();
    }
 
    @Override
    public String doTrade(LinkedHashMap<String, Object> tradeDto, OKXAccount okxAccount) {
        ParameterChecker.checkParameter(tradeDto, "instId", String.class);
        ParameterChecker.checkParameter(tradeDto, "tdMode", String.class);
        ParameterChecker.checkParameter(tradeDto, "side", String.class);
        ParameterChecker.checkParameter(tradeDto, "ordType", String.class);
        ParameterChecker.checkParameter(tradeDto, "sz", Double.class);
        String placeOrderRspOkxRestResponse = okxAccount.requestHandler.sendSignedRequest(okxAccount.baseUrl, OKXContants.ORDER, tradeDto, HttpMethod.POST, okxAccount.isSimluate());
        log.info("开仓响应:{}",JSON.parseObject(placeOrderRspOkxRestResponse).get("data"));
        /**
         *  todo 下单之后的日志处理
         */
        return placeOrderRspOkxRestResponse;
    }
}