package com.xcong.excoin.rabbit.pricequeue; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.PriorityBlockingQueue; /** * 止盈止损的价格队列 */ public class PricePriorityQueue { /** * BTC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ public static PriorityBlockingQueue BTC_QUEUE_ASC = null; private static Map> BTC_MAP_ASC = null; /** * BTC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ public static PriorityBlockingQueue BTC_QUEUE_DESC = null; private static Map> BTC_MAP_DESC = null; /** * ETH 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue ETH_QUEUE_ASC = null; private static Map> ETH_MAP_ASC = null; /** * ETH 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue ETH_QUEUE_DESC = null; private static Map> ETH_MAP_DESC = null; /** * XRP 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue XRP_QUEUE_ASC = null; private static Map> XRP_MAP_ASC = null; /** * XRP 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue XRP_QUEUE_DESC = null; private static Map> XRP_MAP_DESC = null; /** * LTC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue LTC_QUEUE_ASC = null; private static Map> LTC_MAP_ASC = null; /** * LTC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue LTC_QUEUE_DESC = null; private static Map> LTC_MAP_DESC = null; /** * BCH 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue BCH_QUEUE_ASC = null; private static Map> BCH_MAP_ASC = null; /** * BCH 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue BCH_QUEUE_DESC = null; private static Map> BCH_MAP_DESC = null; /** * EOS 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue EOS_QUEUE_ASC = null; private static Map> EOS_MAP_ASC = null; /** * EOS 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue EOS_QUEUE_DESC = null; private static Map> EOS_MAP_DESC = null; /** * ETC 正序队列 头元素最小 开多止损 开空止盈 开多爆仓 限价开多 */ private static PriorityBlockingQueue ETC_QUEUE_ASC = null; private static Map> ETC_MAP_ASC = null; /** * ETC 倒序队列 头元素最大 开多止盈 开空止损 开空爆仓 限价开空 */ private static PriorityBlockingQueue ETC_QUEUE_DESC = null; private static Map> ETC_MAP_DESC = null; // 收到消息队列的方法 即收取到新的止盈止损等 // 【1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空】 public static PriorityBlockingQueue getQueueAsc(String symbol) { switch (symbol) { case "BTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (BTC_QUEUE_ASC == null) { BTC_QUEUE_ASC = new PriorityBlockingQueue(); } return BTC_QUEUE_ASC; case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (ETH_QUEUE_ASC == null) { ETH_QUEUE_ASC = new PriorityBlockingQueue(); } return ETH_QUEUE_ASC; case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (XRP_QUEUE_ASC == null) { XRP_QUEUE_ASC = new PriorityBlockingQueue(); } return XRP_QUEUE_ASC; case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (LTC_QUEUE_ASC == null) { LTC_QUEUE_ASC = new PriorityBlockingQueue(); } return LTC_QUEUE_ASC; case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (BCH_QUEUE_ASC == null) { BCH_QUEUE_ASC = new PriorityBlockingQueue(); } return BCH_QUEUE_ASC; case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (EOS_QUEUE_ASC == null) { EOS_QUEUE_ASC = new PriorityBlockingQueue(); } return EOS_QUEUE_ASC; case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (ETC_QUEUE_ASC == null) { ETC_QUEUE_ASC = new PriorityBlockingQueue(); } return ETC_QUEUE_ASC; default: break; } return null; } public static PriorityBlockingQueue getQueueDesc(String symbol) { switch (symbol) { case "BTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 //if (type == 11 || type == 10 || type == 7 || type == 6 || type == 2) { if (BTC_QUEUE_DESC == null) { BTC_QUEUE_DESC = new PriorityBlockingQueue(); } return BTC_QUEUE_DESC; case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (ETH_QUEUE_DESC == null) { ETH_QUEUE_DESC = new PriorityBlockingQueue(); } return ETH_QUEUE_DESC; case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (XRP_QUEUE_DESC == null) { XRP_QUEUE_DESC = new PriorityBlockingQueue(); } return XRP_QUEUE_DESC; case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (LTC_QUEUE_DESC == null) { LTC_QUEUE_DESC = new PriorityBlockingQueue(); } return LTC_QUEUE_DESC; case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (BCH_QUEUE_DESC == null) { BCH_QUEUE_DESC = new PriorityBlockingQueue(); } return BCH_QUEUE_DESC; case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (EOS_QUEUE_DESC == null) { EOS_QUEUE_DESC = new PriorityBlockingQueue(); } return EOS_QUEUE_DESC; case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (ETC_QUEUE_DESC == null) { ETC_QUEUE_DESC = new PriorityBlockingQueue(); } return ETC_QUEUE_DESC; default: break; } return null; } /** * 获得币种价格订单map * @param symbol * @param type * @return */ public static Map> getOrderMap(String symbol, int type) { switch (symbol) { case "BTC/USDT": // 开空止损 开多止盈 开空爆仓 限价开空 if (type == 12 || type == 9 || type == 7 || type == 3) { if (BTC_MAP_ASC == null) { BTC_MAP_ASC = new ConcurrentHashMap>(); } return BTC_MAP_ASC; } else { if (BTC_MAP_DESC == null) { BTC_MAP_DESC = new ConcurrentHashMap>(); } return BTC_MAP_DESC; } case "ETH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (ETH_MAP_ASC == null) { ETH_MAP_ASC = new ConcurrentHashMap>(); } return ETH_MAP_ASC; } else { if (ETH_MAP_DESC == null) { ETH_MAP_DESC = new ConcurrentHashMap>(); } return ETH_MAP_DESC; } case "XRP/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (XRP_MAP_ASC == null) { XRP_MAP_ASC = new ConcurrentHashMap>(); } return XRP_MAP_ASC; } else { if (XRP_MAP_DESC == null) { XRP_MAP_DESC = new ConcurrentHashMap>(); } return XRP_MAP_DESC; } case "LTC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (LTC_MAP_ASC == null) { LTC_MAP_ASC = new ConcurrentHashMap>(); } return LTC_MAP_ASC; } else { if (LTC_MAP_DESC == null) { LTC_MAP_DESC =new ConcurrentHashMap>(); } return LTC_MAP_DESC; } case "BCH/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (BCH_MAP_ASC == null) { BCH_MAP_ASC = new ConcurrentHashMap>(); } return BCH_MAP_ASC; } else { if (BCH_MAP_DESC == null) { BCH_MAP_DESC = new ConcurrentHashMap>(); } return BCH_MAP_DESC; } case "EOS/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (EOS_MAP_ASC == null) { EOS_MAP_ASC = new ConcurrentHashMap>(); } return EOS_MAP_ASC; } else { if (EOS_MAP_DESC == null) { EOS_MAP_DESC = new ConcurrentHashMap>(); } return EOS_MAP_DESC; } case "ETC/USDT": // 开多止损 开空止盈 开多爆仓 限价开多 if (type == 12 || type == 9 || type == 7 || type == 3) { if (ETC_MAP_ASC == null) { ETC_MAP_ASC = new ConcurrentHashMap>(); } return ETC_MAP_ASC; } else { if (ETC_MAP_DESC == null) { ETC_MAP_DESC = new ConcurrentHashMap>(); } return ETC_MAP_DESC; } default: break; } return null; } }