From 0f25ef5fe5076be73cf7d40b2f0f9c3f7293eadb Mon Sep 17 00:00:00 2001
From: zainali5120 <512061637@qq.com>
Date: Thu, 08 Oct 2020 13:41:12 +0800
Subject: [PATCH] 修复冻结问题
---
src/main/java/com/xcong/excoin/quartz/job/KLineGeneratorJob.java | 49 +++++++++++++------------------------------------
1 files changed, 13 insertions(+), 36 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/quartz/job/KLineGeneratorJob.java b/src/main/java/com/xcong/excoin/quartz/job/KLineGeneratorJob.java
index 5972de9..8fb4f5c 100644
--- a/src/main/java/com/xcong/excoin/quartz/job/KLineGeneratorJob.java
+++ b/src/main/java/com/xcong/excoin/quartz/job/KLineGeneratorJob.java
@@ -1,28 +1,16 @@
package com.xcong.excoin.quartz.job;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.huobi.client.model.Candlestick;
-import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao;
import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
import com.xcong.excoin.modules.coin.service.OrderCoinService;
import com.xcong.excoin.processor.CoinProcessorFactory;
-import com.xcong.excoin.trade.TradePlateModel;
-import com.xcong.excoin.utils.RedisUtils;
-import com.xcong.excoin.websocket.CandlestickModel;
-import com.xcong.excoin.websocket.NewCandlestick;
-import com.xcong.excoin.websocket.TradePlateSendWebSocket;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.List;
import java.util.Random;
/**
@@ -40,35 +28,19 @@
- @Scheduled(cron = "0/1 * * * * *")
+ //@Scheduled(cron = "0/40 * * * * *")
public void test(){
-// for(int i=1;i<=2;i++){
-// OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
-// detail.setMemberId(13L);
-// //detail.setOrderId(111);
-// detail.setOrderNo("tete");
-// detail.setOrderType(1);
-// detail.setTradeType(1);
-// detail.setSymbol("NEKK");
-// detail.setSymbolCnt(new BigDecimal(10));
-// detail.setEntrustPrice(new BigDecimal(10));
-// detail.setDealPrice(new BigDecimal(i*10*Math.random()));
-// detail.setDealAmount(new BigDecimal(50));
-// detail.setFeeAmount(new BigDecimal(1));
-// detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
-// orderCoinDealDao.insert(detail);
-// }
Random random = new Random();
Integer type = OrderCoinsDealEntity.ORDERTYPE_BUY;
Integer tradeType = OrderCoinsDealEntity.TRADETYPE_FIXEDPRICE;
- int i = random.nextInt(100);
- if(i==0){
- i=10;
+ double random1 = Math.random();
+ BigDecimal price = new BigDecimal(random1).setScale(4, RoundingMode.HALF_UP).multiply(new BigDecimal("2"));
+ if(price.compareTo(BigDecimal.ZERO)==0){
+ price = BigDecimal.ONE;
}
- BigDecimal price = new BigDecimal(i);
- orderCoinService.initOrders("NEKK",type,tradeType,price,new BigDecimal(2),null);
- orderCoinService.initOrders("NEKK",OrderCoinsDealEntity.ORDERTYPE_SELL,tradeType,price,new BigDecimal(2),null);
-
+ System.out.println(price);
+ orderCoinService.initOrders("ROC",type,tradeType,price,new BigDecimal(2),null);
+ orderCoinService.initOrders("ROC",OrderCoinsDealEntity.ORDERTYPE_SELL,tradeType,price,new BigDecimal(2),null);
}
@@ -130,6 +102,11 @@
long time = calendar.getTimeInMillis();
processor.generateKLine(1, Calendar.HOUR_OF_DAY, time);
+ // 四小时K线
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
+ if(hour%4==0){
+ processor.generateKLine(4, Calendar.HOUR_OF_DAY, time);
+ }
}
});
}
--
Gitblit v1.9.1