| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.excoin.modules.okxApi.OkxGridTradeService; |
| | | import com.xcong.excoin.modules.okxApi.IOkxStrategy; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.java_websocket.client.WebSocketClient; |
| | | |
| | |
| | | /** 交易对标识,如 "ETH-USDT-SWAP" */ |
| | | private final String instId; |
| | | |
| | | /** 网格交易服务实例 */ |
| | | private final OkxGridTradeService gridTradeService; |
| | | /** 策略服务实例 */ |
| | | private final IOkxStrategy strategy; |
| | | |
| | | /** 订阅确认状态 */ |
| | | private volatile boolean subscribed = false; |
| | |
| | | /** |
| | | * 构造私有频道处理器。 |
| | | * |
| | | * @param channelName 频道名称(如 "positions"、"orders-algo") |
| | | * @param apiKey OKX API Key |
| | | * @param apiSecret OKX API Secret |
| | | * @param passphrase OKX API Passphrase |
| | | * @param instId 交易对标识(如 "ETH-USDT-SWAP") |
| | | * @param gridTradeService 网格交易服务实例 |
| | | * @param channelName 频道名称(如 "positions"、"orders-algo") |
| | | * @param apiKey OKX API Key |
| | | * @param apiSecret OKX API Secret |
| | | * @param passphrase OKX API Passphrase |
| | | * @param instId 交易对标识(如 "ETH-USDT-SWAP") |
| | | * @param strategy OKX 交易策略服务实例 |
| | | */ |
| | | public AbstractOkxPrivateChannelHandler(String channelName, |
| | | String apiKey, String apiSecret, |
| | | String passphrase, |
| | | String instId, |
| | | OkxGridTradeService gridTradeService) { |
| | | IOkxStrategy strategy) { |
| | | this.channelName = channelName; |
| | | this.apiKey = apiKey; |
| | | this.apiSecret = apiSecret; |
| | | this.passphrase = passphrase; |
| | | this.instId = instId; |
| | | this.gridTradeService = gridTradeService; |
| | | this.strategy = strategy; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return 网格交易服务实例 |
| | | * @return 策略服务实例 |
| | | */ |
| | | protected OkxGridTradeService getGridTradeService() { |
| | | return gridTradeService; |
| | | protected IOkxStrategy getStrategy() { |
| | | return strategy; |
| | | } |
| | | |
| | | // ==================== 订阅状态 ==================== |