Search in sources :

Example 6 with ExOrderInfo

use of hry.trade.entrust.model.ExOrderInfo in project benchmark by seelunzi.

the class TradeRedis method setExchangeDataCache.

/*     */
/*     */
/*     */
public static void setExchangeDataCache(List<ExOrderInfo> listExOrderInfo, String header) /*     */
{
    /* 317 */
    RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
    /* 318 */
    ExOrderInfo exOrderInfo = (ExOrderInfo) listExOrderInfo.get(listExOrderInfo.size() - 1);
    /*     */
    /* 320 */
    setStringData(header + ":" + "currentExchangPrice", exOrderInfo.getTransactionPrice().setScale(10, 4).toString());
    /*     */
    /* 322 */
    String v = redisService.get(header + ":" + "LastOrderRecords");
    /* 323 */
    List<ExOrderInfo> list = null;
    /* 324 */
    if (!StringUtil.isEmpty(v)) {
        /* 325 */
        list = JSON.parseArray(v, ExOrderInfo.class);
    /*     */
    } else {
        /* 327 */
        list = new ArrayList();
    /*     */
    }
    /* 329 */
    list.addAll(listExOrderInfo);
    /* 330 */
    if (list.size() > ExchangeDataCacheRedis.LastOrderRecordsLmit.intValue()) {
        /* 331 */
        List<ExOrderInfo> sublist = list.subList(list.size() - ExchangeDataCacheRedis.LastOrderRecordsLmit.intValue(), list.size());
        /* 332 */
        redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(sublist));
    /*     */
    } else {
        /* 334 */
        redisService.save(header + ":" + "LastOrderRecords", JSON.toJSONString(list));
    /*     */
    }
/*     */
}
Also used : RedisService(hry.redis.common.utils.RedisService) ExOrderInfo(hry.trade.entrust.model.ExOrderInfo)

Example 7 with ExOrderInfo

use of hry.trade.entrust.model.ExOrderInfo in project benchmark by seelunzi.

the class TradeRedis method put.

/*     */
/*     */
/*     */
public static void put(ExOrderInfo exOrderInfo) /*     */
{
    /* 528 */
    RedisService redisService = (RedisService) ContextUtil.getBean("redisService");
    /* 529 */
    String v = redisService.get("exorderinfos");
    /* 530 */
    List<ExOrderInfo> list = JSON.parseArray(v, ExOrderInfo.class);
    /* 531 */
    list.add(exOrderInfo);
    /* 532 */
    redisService.save("exorderinfos", JSON.toJSONString(list));
/*     */
}
Also used : RedisService(hry.redis.common.utils.RedisService) ExOrderInfo(hry.trade.entrust.model.ExOrderInfo)

Aggregations

ExOrderInfo (hry.trade.entrust.model.ExOrderInfo)7 RedisService (hry.redis.common.utils.RedisService)4 BigDecimal (java.math.BigDecimal)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 SortList (hry.core.util.SortList)1 RedisTradeService (hry.redis.common.utils.RedisTradeService)1 ExEntrust (hry.trade.entrust.model.ExEntrust)1 EntrustTrade (hry.trade.redis.model.EntrustTrade)1 MarketTrades (hry.trade.websoketContext.model.MarketTrades)1 MarketTradesSub (hry.trade.websoketContext.model.MarketTradesSub)1