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