Helius
2020-07-01 94c55976479131ad79e100e551a06d84b071d504
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
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) {
                    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) {
                    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) {
                    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) {
                    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) {
                    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) {
                    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) {
                    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;
    }
 
}