Java 放弃将数据连接到tradingview

Java 放弃将数据连接到tradingview,java,tradingview-api,Java,Tradingview Api,OracleJDK1.8 弹簧靴1.5 所以我一直在尝试将我的数据连接到tradingview图表库,并在这方面取得了一些成功。但是,有些问题我无法解决 Issues: 1. For testing, I am Using Binance BTCUSDT data and saving it in my local mongo collection. And data is in millions. The chart takes forever to load the first time

OracleJDK1.8 弹簧靴1.5

所以我一直在尝试将我的数据连接到tradingview图表库,并在这方面取得了一些成功。但是,有些问题我无法解决

Issues: 
1. For testing, I am Using Binance BTCUSDT data and saving it in my local mongo collection. And data is in millions. The chart takes forever to load the first time and it results in timeout. 
2. The history chart forms correctly, but the bar colors are inverted. That means if I use the same timeframe for Binance- BTCUSDT on tradingview.com the bar color will be green, but in my chart the bar colors are red. 
3. After the chart is loaded the first time, new bar are not created in the perfect resolution manner. That means if resolution is of 5 minutes, all bars should be of exactly five minutes. But in my chart, new bar are created randomly, one bar of one minute, another of 2 minutes. 
下面是代码片段:

    public TVHistoryDataResponse fetchHistoryData(Market market, long from, long to, String r) {
    long resolutionSeconds = getSecondsOnResolution(r);
    long diff = to - from;
    int totalBarCount = (int) (long) (diff / resolutionSeconds);

    TVHistoryDataResponse tvHistoryDataResponse = new TVHistoryDataResponse();
    long startTime = from;
    long sstartTime=System.currentTimeMillis();
    for (int i = 0; i <= totalBarCount; i++) {
        List<TradingData> tradingDataList = tradingDataRepository.findByMarketAndTimestampBetweenOrderByTimestampDesc(market, startTime, startTime + resolutionSeconds);
        if (!tradingDataList.isEmpty()) {
            tvHistoryDataResponse.getT().add(startTime);
            calculateBar(tradingDataList, tvHistoryDataResponse);

        }
        startTime = startTime + resolutionSeconds;
    }

    if (!tvHistoryDataResponse.getT().isEmpty()) {
        tvHistoryDataResponse.setS("ok");
    } else {
        tvHistoryDataResponse.setS("no_data");
    }

    long sendTime = System.currentTimeMillis();
    log.info("That took " + (sendTime - sstartTime) + " milliseconds");
    log.info("API Response >>>>>>>> " +tvHistoryDataResponse.toString());
    return tvHistoryDataResponse;
}

private void calculateBar(List<TradingData> tradeData, TVHistoryDataResponse response) {

    BigDecimal openingBal = tradeData.get(0).getPrice();
    BigDecimal closingBal = tradeData.get(tradeData.size() - 1).getPrice();
    BigDecimal highBal = tradeData.stream().max(Comparator.comparing(a -> a.getPrice())).get().getPrice();
    BigDecimal lowBal = tradeData.stream().min(Comparator.comparing(a -> a.getPrice())).get().getPrice();

    BigDecimal sum = tradeData.stream().map(a -> a.getVolume())
            .reduce(BigDecimal.ZERO, BigDecimal::add);

    response.getO().add(openingBal);
    response.getH().add(highBal);
    response.getL().add(lowBal);
    response.getC().add(closingBal);
    response.getV().add(sum);
}

private static long getSecondsOnResolution(String r) {

    switch (r) {
        case "1":
            return Duration.ofMinutes(1).getSeconds();
        case "15":
            return Duration.ofMinutes(15).getSeconds();
        case "30":
            return Duration.ofMinutes(30).getSeconds();
        case "60":
            return Duration.ofHours(1).getSeconds();
        case "1D":
            return Duration.ofDays(1).getSeconds();
        case "1W":
            return Duration.ofDays(7).getSeconds();
        case "1M":
            return Duration.ofDays(30).getSeconds();
        default:
            return Duration.ofMinutes(5).getSeconds();
    }
}
public TVHistoryDataResponse fetchHistoryData(市场、长起、长至、字符串r){
long resolutionSeconds=getSecondsOnResolution(r);
长差=到-从;
int totalBarCount=(int)(长)(差异/分辨率秒);
TVHistoryDataResponse TVHistoryDataResponse=新TVHistoryDataResponse();
长起始时间=起始时间;
long sstartTime=System.currentTimeMillis();
对于(inti=0;ia.getPrice()).get().getPrice();
BigDecimal lowBal=tradeData.stream().min(Comparator.comparing(a->a.getPrice()).get().getPrice();
BigDecimal sum=tradeData.stream().map(a->a.getVolume())
.reduce(BigDecimal.ZERO,BigDecimal::add);
response.getO().add(openingBal);
response.getH().add(highBal);
response.getL().add(lowBal);
response.getC().add(closingBal);
response.getV().add(sum);
}
私有静态长getSecondsOnResolution(字符串r){
开关(r){
案例“1”:
返回持续时间.ofMinutes(1).getSeconds();
案例“15”:
返回持续时间.ofMinutes(15).getSeconds();
案例“30”:
返回持续时间.ofMinutes(30).getSeconds();
案例“60”:
返回持续时间.小时(1).getSeconds();
案例“1D”:
返回持续时间.ofDays(1).getSeconds();
案例“1W”:
返回持续时间.ofDays(7).getSeconds();
案例“1M”:
返回持续时间.ofDays(30).getSeconds();
违约:
返回持续时间.ofMinutes(5).getSeconds();
}
}
对于第2期,请查看我的图表和TRadingview图表的附加图像,它们具有相同的分辨率、相同的时间范围和相同的交换

这是我的图表:

这是tradingview图表:

问题3:请查看下图以了解

非常感谢您在这方面的任何帮助