Search in sources :

Example 1 with RedisTradeService

use of hry.redis.common.utils.RedisTradeService in project benchmark by seelunzi.

the class WebSocketScheduleServiceImpl method pushMarket.

/*    */
/*    */
public void pushMarket() /*    */
{
    /* 57 */
    Integer i = Integer.valueOf(0);
    /* 58 */
    Integer a = Integer.valueOf(0);
    /* 59 */
    String productListStr = TradeRedis.getStringData("cn:productFixList");
    /* 60 */
    if (!StringUtils.isEmpty(productListStr)) {
        /* 61 */
        List<String> productList = JSON.parseArray(productListStr, String.class);
        /* 62 */
        for (String coinCodetwo : productList) /*    */
        {
            /*    */
            /* 65 */
            RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
            /* 66 */
            Integer localInteger1 = i;
            Integer localInteger2 = i = Integer.valueOf(i.intValue() + 1);
            /* 67 */
            String[] coinCodeArr = coinCodetwo.split("_");
            /* 68 */
            String coinCode = coinCodeArr[0];
            /* 69 */
            String fixPriceCoinCode = coinCodeArr[1];
            /* 70 */
            String flagstrkey = TradeRedis.getEntrustTimeFlag(coinCode, fixPriceCoinCode);
            /* 71 */
            String flag = redisTradeService.get(flagstrkey);
            /* 73 */
            if ((null != flag) && (flag.equals("1"))) {
                /* 74 */
                Integer localInteger3 = a;
                Integer localInteger4 = a = Integer.valueOf(a.intValue() + 1);
                /* 75 */
                String header = TradeRedis.getHeader(coinCode, fixPriceCoinCode, null);
                /* 76 */
                ExEntrutKlineRunable exEntrutKlineRunable = new ExEntrutKlineRunable(coinCode, fixPriceCoinCode, header);
                /* 77 */
                ThreadPool.exe(exEntrutKlineRunable);
                /*    */
                /* 79 */
                redisTradeService.save(TradeRedis.getEntrustTimeFlag(coinCode, fixPriceCoinCode), "0");
            /*    */
            }
        /*    */
        }
    /*    */
    }
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /*    */
    /* 93 */
    long end = System.currentTimeMillis();
/*    */
}
Also used : ExEntrutKlineRunable(hry.trade.model.ExEntrutKlineRunable) RedisTradeService(hry.redis.common.utils.RedisTradeService)

Example 2 with RedisTradeService

use of hry.redis.common.utils.RedisTradeService in project benchmark by seelunzi.

the class TradeRedis method matchOneEnd.

/*     */
/*     */
/*     */
public static void matchOneEnd(List<Accountadd> exEntrustAccountadd, EntrustTrade exEntrust, Map<String, List<EntrustTrade>> maping, List<EntrustTrade> listed, BigDecimal matchonePrice) /*     */
{
    /* 199 */
    aaddlists.addAll(0, exEntrustAccountadd);
    /* 200 */
    listed.add(exEntrust);
    /* 201 */
    if (!exEntrust.getStatus().equals(Integer.valueOf(2))) {
        /* 202 */
        putSelfEntrustTradelist(exEntrust);
        /* 203 */
        setSelfonePrice(exEntrust);
    /*     */
    }
    /*     */
    /* 206 */
    RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
    /* 207 */
    for (Entry<String, List<EntrustTrade>> entry : maping.entrySet()) {
        /* 208 */
        List<EntrustTrade> listing = (List) entry.getValue();
        /* 209 */
        if ((null == listing) || (listing.size() == 0)) {
            /* 210 */
            redisTradeService.delete((String) entry.getKey());
        /*     */
        } else {
            /* 212 */
            redisTradeService.save((String) entry.getKey(), JSON.toJSONString(listing));
        /*     */
        }
    /*     */
    }
    /*     */
    /*     */
    /* 217 */
    MQEnter.pushDealFundMQ(aaddlists);
    /* 220 */
    for (EntrustTrade entrust : listed) {
        /* 221 */
        putEntrustByUser(entrust);
    /*     */
    }
    /* 223 */
    setMatchOnePrice(matchonePrice, exEntrust);
    /* 224 */
    String keyFront = getHeaderFront(exEntrust);
    /* 225 */
    setExchangeDataCache(eoinfolists, keyFront);
    /*     */
    /* 227 */
    RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
    /* 228 */
    redisService.save(getTradeDealEntrustChangeNum(), JSON.toJSONString(listed));
    /* 229 */
    redisService.save(getTradeDealOrderInfoChangeNum(), JSON.toJSONString(eoinfolists));
    /*     */
    /*     */
    /*     */
    /* 233 */
    List<ExOrderInfo> arr = new ArrayList();
    /* 234 */
    arr.addAll(eoinfolists);
    /* 235 */
    PeriodLastKLineListRunable periodLastKLineListRunable = new PeriodLastKLineListRunable(arr);
    /* 236 */
    ThreadPool.exe(periodLastKLineListRunable);
    /* 237 */
    aaddlists.clear();
    /* 238 */
    eoinfolists.clear();
    /*     */
    /* 240 */
    redisTradeService.save(getEntrustTimeFlag(exEntrust.getCoinCode(), exEntrust.getFixPriceCoinCode()), "1");
/*     */
}
Also used : RedisService(hry.redis.common.utils.RedisService) RedisTradeService(hry.redis.common.utils.RedisTradeService) ExOrderInfo(hry.trade.entrust.model.ExOrderInfo)

Example 3 with RedisTradeService

use of hry.redis.common.utils.RedisTradeService in project benchmark by seelunzi.

the class TradeRedis method NoMatchEnd.

/*     */
/*     */
public static void NoMatchEnd(EntrustTrade entrust, List<Accountadd> aadds) /*     */
{
    /* 179 */
    setSelfonePrice(entrust);
    /* 180 */
    putSelfEntrustTradelist(entrust);
    /*     */
    /* 182 */
    MQEnter.pushDealFundMQ(aadds);
    /* 183 */
    putEntrustByUser(entrust);
    /*     */
    /*     */
    /* 186 */
    RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
    /* 187 */
    List<EntrustTrade> listchange = new ArrayList();
    /* 188 */
    listchange.add(entrust);
    /* 189 */
    redisService.save(getTradeDealEntrustChangeNum(), JSON.toJSONString(listchange));
    /*     */
    /*     */
    /* 192 */
    RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
    /* 193 */
    redisTradeService.save(getEntrustTimeFlag(entrust.getCoinCode(), entrust.getFixPriceCoinCode()), "1");
/*     */
}
Also used : RedisService(hry.redis.common.utils.RedisService) RedisTradeService(hry.redis.common.utils.RedisTradeService)

Example 4 with RedisTradeService

use of hry.redis.common.utils.RedisTradeService in project benchmark by seelunzi.

the class TradeRedis method getMatchkeys.

/*     */
/*     */
public static List<BigDecimal> getMatchkeys(EntrustTrade exEntrust) {
    /* 584 */
    String key = getHeaderMatch(exEntrust);
    /* 585 */
    RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
    /* 586 */
    Set<String> keys = redisTradeService.noPerkeys(key + ":");
    /* 587 */
    if (null == keys) {
        /* 588 */
        return null;
    /*     */
    }
    /* 590 */
    List<BigDecimal> list2 = new ArrayList();
    /* 591 */
    Iterator<String> iterator = keys.iterator();
    /* 592 */
    while (iterator.hasNext()) {
        /* 593 */
        String keystr = (String) iterator.next();
        /* 594 */
        BigDecimal ks = new BigDecimal(keystr.split(":")[2]);
        /* 595 */
        list2.add(ks);
    /*     */
    }
    /* 597 */
    if (exEntrust.getType().equals(Integer.valueOf(1))) {
        /* 598 */
        Collections.sort(list2, new AscBigDecimalComparator());
    /*     */
    } else {
        /* 600 */
        Collections.sort(list2, new DescBigDecimalComparator());
    /*     */
    }
    /* 602 */
    return list2;
/*     */
}
Also used : AscBigDecimalComparator(hry.trade.comparator.AscBigDecimalComparator) DescBigDecimalComparator(hry.trade.comparator.DescBigDecimalComparator) RedisTradeService(hry.redis.common.utils.RedisTradeService) BigDecimal(java.math.BigDecimal)

Example 5 with RedisTradeService

use of hry.redis.common.utils.RedisTradeService in project benchmark by seelunzi.

the class ExEntrustServiceImpl method tradeInit.

/*     */
/*     */
/*     */
/*     */
public void tradeInit() /*     */
{
    /* 104 */
    RedisTradeService redisTradeService = (RedisTradeService) ContextUtil.getBean("redisTradeService");
    /*     */
    /* 106 */
    redisTradeService.delkeys(":buy:");
    /* 107 */
    redisTradeService.delkeys(":sell:");
    /*     */
    /*     */
    /* 110 */
    List<ExCointoCoin> listExCointoCoin = this.commonDao.getExointocoinValid();
    /* 111 */
    for (ExCointoCoin exCointoCoin : listExCointoCoin) {
        /* 112 */
        String header = getHeader(exCointoCoin.getCoinCode(), exCointoCoin.getFixPriceCoinCode());
        /*     */
        /* 114 */
        QueryFilter filterbuy = new QueryFilter(ExEntrust.class);
        /* 115 */
        filterbuy.addFilter("status<", Integer.valueOf(2));
        /* 116 */
        filterbuy.addFilter("type=", Integer.valueOf(1));
        /* 117 */
        filterbuy.addFilter("coinCode=", exCointoCoin.getCoinCode());
        /* 118 */
        filterbuy.addFilter("fixPriceCoinCode=", exCointoCoin.getFixPriceCoinCode());
        /* 119 */
        filterbuy.setOrderby("entrustPrice desc");
        /* 120 */
        List<ExEntrust> listbuy = find(filterbuy);
        /* 121 */
        List<EntrustTrade> listbuypricesame = new ArrayList();
        /* 122 */
        String buyonePricekey = header + ":" + "buyonePrice";
        /* 123 */
        if ((null != listbuy) && (listbuy.size() > 0)) {
            /* 124 */
            BigDecimal sameprice = ((ExEntrust) listbuy.get(0)).getEntrustPrice();
            /* 125 */
            EntrustTrade entrustTrade = null;
            /* 126 */
            for (ExEntrust l : listbuy) {
                /* 127 */
                String exentrust = JSON.toJSONString(l);
                /* 128 */
                entrustTrade = (EntrustTrade) JSON.parseObject(exentrust, EntrustTrade.class);
                /* 129 */
                if (l.getEntrustPrice().compareTo(sameprice) == 0) {
                    /* 130 */
                    listbuypricesame.add(entrustTrade);
                /*     */
                } else {
                    /* 132 */
                    String key = getHeader(entrustTrade) + ":buy:" + sameprice.setScale(10, 6).toString();
                    /* 133 */
                    redisTradeService.save(key, JSON.toJSONString(listbuypricesame));
                    /* 134 */
                    listbuypricesame = new ArrayList();
                    /* 135 */
                    listbuypricesame.add(entrustTrade);
                    /* 136 */
                    sameprice = l.getEntrustPrice();
                /*     */
                }
            /*     */
            }
            /* 139 */
            String key = header + ":buy:" + sameprice.setScale(10, 6).toString();
            /* 140 */
            redisTradeService.save(key, JSON.toJSONString(listbuypricesame));
            /*     */
            /*     */
            /* 143 */
            this.redisService.save(buyonePricekey, JSON.toJSONString(((ExEntrust) listbuy.get(0)).getEntrustPrice()));
        /*     */
        } else {
            /* 145 */
            this.redisService.delete(buyonePricekey);
        /*     */
        }
        /*     */
        /*     */
        /*     */
        /* 150 */
        QueryFilter filtersell = new QueryFilter(ExEntrust.class);
        /* 151 */
        filtersell.addFilter("status<", Integer.valueOf(2));
        /* 152 */
        filtersell.addFilter("type=", Integer.valueOf(2));
        /* 153 */
        filtersell.addFilter("coinCode=", exCointoCoin.getCoinCode());
        /* 154 */
        filtersell.addFilter("fixPriceCoinCode=", exCointoCoin.getFixPriceCoinCode());
        /* 155 */
        filtersell.setOrderby("entrustPrice asc");
        /* 156 */
        List<ExEntrust> listsell = find(filtersell);
        /* 157 */
        List<EntrustTrade> listsellpricesame = new ArrayList();
        /* 158 */
        String sellonePricekey = header + ":" + "sellonePrice";
        /* 159 */
        if ((null != listsell) && (listsell.size() > 0)) {
            /* 160 */
            BigDecimal sameprice = ((ExEntrust) listsell.get(0)).getEntrustPrice();
            /* 161 */
            EntrustTrade entrustTrade = null;
            /* 162 */
            for (ExEntrust l : listsell) {
                /* 163 */
                String exentrust = JSON.toJSONString(l);
                /* 164 */
                entrustTrade = (EntrustTrade) JSON.parseObject(exentrust, EntrustTrade.class);
                /* 165 */
                if (l.getEntrustPrice().compareTo(sameprice) == 0) {
                    /* 166 */
                    listsellpricesame.add(entrustTrade);
                /*     */
                } else {
                    /* 168 */
                    String key = getHeader(entrustTrade) + ":sell:" + sameprice.setScale(10, 6).toString();
                    /* 169 */
                    redisTradeService.save(key, JSON.toJSONString(listsellpricesame));
                    /* 170 */
                    listsellpricesame = new ArrayList();
                    /* 171 */
                    listsellpricesame.add(entrustTrade);
                    /* 172 */
                    sameprice = l.getEntrustPrice();
                /*     */
                }
            /*     */
            }
            /*     */
            /*     */
            /* 177 */
            String key = header + ":sell:" + sameprice.setScale(10, 6).toString();
            /* 178 */
            redisTradeService.save(key, JSON.toJSONString(listsellpricesame));
            /*     */
            /* 180 */
            this.redisService.save(sellonePricekey, JSON.toJSONString(((ExEntrust) listsell.get(0)).getEntrustPrice()));
        /*     */
        } else {
            /* 182 */
            this.redisService.delete(sellonePricekey);
        /*     */
        }
    /*     */
    }
/*     */
}
Also used : ExCointoCoin(hry.exchange.product.model.ExCointoCoin) EntrustTrade(hry.trade.redis.model.EntrustTrade) QueryFilter(hry.core.util.QueryFilter) ExEntrust(hry.trade.entrust.model.ExEntrust) RedisTradeService(hry.redis.common.utils.RedisTradeService) BigDecimal(java.math.BigDecimal)

Aggregations

RedisTradeService (hry.redis.common.utils.RedisTradeService)10 RedisService (hry.redis.common.utils.RedisService)3 BigDecimal (java.math.BigDecimal)3 AscBigDecimalComparator (hry.trade.comparator.AscBigDecimalComparator)2 DescBigDecimalComparator (hry.trade.comparator.DescBigDecimalComparator)2 QueryFilter (hry.core.util.QueryFilter)1 ExCointoCoin (hry.exchange.product.model.ExCointoCoin)1 ExEntrust (hry.trade.entrust.model.ExEntrust)1 ExOrderInfo (hry.trade.entrust.model.ExOrderInfo)1 ExEntrutKlineRunable (hry.trade.model.ExEntrutKlineRunable)1 EntrustTrade (hry.trade.redis.model.EntrustTrade)1