From 48ef6d4395d754e2e86e4376aff248e1d6b82150 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 30 Sep 2026 22:09:56 +0800
Subject: [PATCH] feat(gateApi): 添加基础仓位止盈网格功能
---
src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 266 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
index eec7531..0c12c52 100644
--- a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
+++ b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
@@ -21,11 +21,68 @@
@Configuration
public class RabbitMqConfig {
- public static final String EXCHANGE_ONE = "excoin-exchange-one";
+ public static final String EXCHANGE_ONE = "biue-exchange-one";
public static final String QUEUE_TEST = "test-queue";
public static final String ROUTING_KEY_TEST = "test-routingKey";
+
+ public static final String EXCHANGE_A = "biue-exchange-A";
+
+
+ // 开多止盈队列
+ public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO_NEW";
+ // 开空止盈队列
+ public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO_NEW";
+ // 开多止损队列
+ public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS_NEW";
+ // 开空止损队列
+ public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS_NEW";
+
+ // 限价委托
+ public static final String QUEUE_LIMIT = "QUEUE_LIMIT_NEW";
+
+ // 爆仓队列
+ public static final String QUEUE_COINOUT = "QUEUE_COINOUT_NEW";
+
+ //价格操作
+ public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE_NEW";
+
+ // 平仓队列
+ public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE_NEW";
+
+
+ // 开多止盈路由键
+ public static final String ROUTINGKEY_MOREPRO = "ROUTINGKEY_MOREPRO";
+ // 开空止盈路由
+ public static final String ROUTINGKEY_LESSPRO = "ROUTINGKEY_LESSPRO";
+ // 开多止损路由
+ public static final String ROUTINGKEY_MORELOSS = "ROUTINGKEY_MORELOSS";
+ // 开空止损路由
+ public static final String ROUTINGKEY_LESSLOSS = "ROUTINGKEY_LESSLOSS";
+ // 限价委托
+ public static final String ROUTINGKEY_LIMIT = "ROUTINGKEY_LIMIT";
+
+ // 爆仓路由
+ public static final String ROUTINGKEY_COINOUT = "ROUTINGKEY_COINOUT";
+
+
+ // 价格操作
+ public static final String ROUTINGKEY_PRICEOPERATE = "ROUTINGKEY_PRICEOPERATE";
+ // 平仓路由
+ public static final String ROUTINGKEY_CLOSETRADE = "ROUTINGKEY_CLOSETRADE";
+
+ // ==================== Gate 策略管理 ====================
+ /** Gate 管理交换机 */
+ public static final String EXCHANGE_GATE = "biue-exchange-gate";
+ /** 心跳+事件+确认 队列(Station 独占消费) */
+ public static final String QUEUE_GATE_HEARTBEAT = "QUEUE_GATE_HEARTBEAT";
+ /** 心跳+事件+确认 路由键 */
+ public static final String ROUTINGKEY_GATE_HEARTBEAT = "ROUTINGKEY_GATE_HEARTBEAT";
+ /** 策略事件队列(Station 消费落库) */
+ public static final String QUEUE_GATE_STATS = "QUEUE_GATE_STATS";
+ /** 策略事件路由键 */
+ public static final String ROUTINGKEY_GATE_STATS = "ROUTINGKEY_GATE_STATS";
@Resource
private ConnectionFactory connectionFactory;
@@ -60,4 +117,212 @@
return BindingBuilder.bind(testQueue()).to(defaultExchange()).with(ROUTING_KEY_TEST);
}
+
+ /**
+ * 交换器A 可以继续添加交换器B C
+ *
+ * @return
+ */
+ @Bean
+ public DirectExchange orderExchange() {
+ return new DirectExchange(EXCHANGE_A);
+ }
+
+
+ /**
+ * 开多止盈队列
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueMorePro() {
+ // 定义一个名称为QUEUE_A,持久化的队列
+ return new Queue(QUEUE_MOREPRO, true);
+ }
+
+ /**
+ * 开空止盈队列
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueLessPro() {
+ // 定义一个名称为QUEUE_A,持久化的队列
+ return new Queue(QUEUE_LESSPRO, true);
+ }
+
+ /**
+ * 开多止损
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueMoreLoss() {
+ // 定义一个名称为QUEUE_A,持久化的队列
+ return new Queue(QUEUE_MORELOSS, true);
+ }
+
+ /**
+ * 开空止损
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueLessLoss() {
+ // 定义一个名称为QUEUE_A,持久化的队列
+ return new Queue(QUEUE_LESSLOSS, true);
+ }
+
+ /**
+ * 限价委托
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueLimit() {
+ return new Queue(QUEUE_LIMIT, true);
+ }
+
+
+ /**
+ * 爆仓
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueCoinout() {
+ return new Queue(QUEUE_COINOUT, true);
+ }
+
+ /**
+ * 价格操作
+ *
+ * @return
+ */
+ @Bean
+ public Queue queuePriceoperate() {
+ return new Queue(QUEUE_PRICEOPERATE, true);
+ }
+
+ /**
+ * 价格操作
+ *
+ * @return
+ */
+ @Bean
+ public Queue queueCloseTrade() {
+ return new Queue(QUEUE_CLOSETRADE, true);
+ }
+
+
+ /**
+ * 开多止盈
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingMroPro() {
+ return BindingBuilder.bind(queueMorePro()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_MOREPRO);
+ }
+
+ /**
+ * 开空止盈
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingLessPro() {
+ return BindingBuilder.bind(queueLessPro()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LESSPRO);
+ }
+
+ /**
+ * 开多止损
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingMroLoss() {
+ return BindingBuilder.bind(queueMoreLoss()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_MORELOSS);
+ }
+
+ /**
+ * 开空止损
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingLessLoss() {
+ return BindingBuilder.bind(queueLessLoss()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LESSLOSS);
+ }
+
+
+ /**
+ * 委托
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingLimit() {
+ return BindingBuilder.bind(queueLimit()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_LIMIT);
+ }
+
+
+ /**
+ * 爆仓
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingCoinout() {
+ return BindingBuilder.bind(queueCoinout()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_COINOUT);
+ }
+
+
+ /**
+ * 价格操作
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingPriceoperate() {
+ return BindingBuilder.bind(queuePriceoperate()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_PRICEOPERATE);
+ }
+
+ /**
+ * 平仓绑定
+ *
+ * @return
+ */
+ @Bean
+ public Binding bindingCloseTrade() {
+ return BindingBuilder.bind(queueCloseTrade()).to(orderExchange()).with(RabbitMqConfig.ROUTINGKEY_CLOSETRADE);
+ }
+
+ // ==================== Gate 管理队列 ====================
+
+ @Bean
+ public DirectExchange gateExchange() {
+ return new DirectExchange(EXCHANGE_GATE);
+ }
+
+ @Bean
+ public Queue gateHeartbeatQueue() {
+ return new Queue(QUEUE_GATE_HEARTBEAT, true);
+ }
+
+ @Bean
+ public Binding bindingGateHeartbeat() {
+ return BindingBuilder.bind(gateHeartbeatQueue()).to(gateExchange()).with(ROUTINGKEY_GATE_HEARTBEAT);
+ }
+
+ @Bean
+ public Queue gateStatsQueue() {
+ return new Queue(QUEUE_GATE_STATS, true);
+ }
+
+ @Bean
+ public Binding bindingGateStats() {
+ return BindingBuilder.bind(gateStatsQueue()).to(gateExchange()).with(ROUTINGKEY_GATE_STATS);
+ }
+
}
--
Gitblit v1.9.1