Closed urbandroid closed 1 month ago
I have tried to test jlama and when short questions asked it returns answer but when i ask specific question it returns empty result in chat facility.
here are the the steps i took:
" something wrong with the supertrend of rsi calculation can you guess what?
package com.example;
import java.util.ArrayList; import java.util.List;
public class SupertrendRSI {
private final int rsiLength; private final int atrLength; private final double factor; private final int smaLength; // Constructor with default values public SupertrendRSI() { this(14, 10, 3.0, 50); } // Constructor with custom values public SupertrendRSI(int rsiLength, int atrLength, double factor, int smaLength) { this.rsiLength = rsiLength; this.atrLength = atrLength; this.factor = factor; this.smaLength = smaLength; } // Method to calculate Supertrend of RSI public List<SupertrendResult> calculateSupertrendOfRSI(List<Price> priceList) { RSICalculator rsiCalculator = new RSICalculator(); List<Double> rsiValues = rsiCalculator.calculateRSI(priceList.stream().map(Price::getClose).toList(), rsiLength); List<Double> atrValues = calculateATR(priceList, atrLength); // Debugging output System.out.println("RSI Values Size: " + rsiValues.size()); System.out.println("ATR Values Size: " + atrValues.size()); // Ensure both rsiValues and atrValues have the same size int minSize = Math.min(rsiValues.size(), atrValues.size()); if (minSize < atrLength) { // Ensure we have enough data for ATR throw new IllegalStateException("Not enough data for ATR calculation."); } List<SupertrendResult> supertrendResults = new ArrayList<>(); Double previousSupertrend = null; boolean isUptrend = true; for (int i = 0; i < minSize; i++) { if (rsiValues.get(i) == null || atrValues.get(i) == null) { supertrendResults.add(new SupertrendResult(null, null, null)); continue; } double upperBand = rsiValues.get(i) + (factor * atrValues.get(i)); double lowerBand = rsiValues.get(i) - (factor * atrValues.get(i)); double supertrend; if (previousSupertrend == null) { supertrend = rsiValues.get(i); previousSupertrend = supertrend; } else { // Update Supertrend logic if (isUptrend) { previousSupertrend = Math.max(previousSupertrend, lowerBand); if (rsiValues.get(i) < previousSupertrend) { isUptrend = false; supertrend = upperBand; // Reverse trend } else { supertrend = previousSupertrend; } } else { previousSupertrend = Math.min(previousSupertrend, upperBand); if (rsiValues.get(i) > previousSupertrend) { isUptrend = true; supertrend = lowerBand; // Reverse trend } else { supertrend = previousSupertrend; } } } supertrendResults.add(new SupertrendResult(supertrend, upperBand, lowerBand)); } return supertrendResults; } // Method to calculate ATR private List<Double> calculateATR(List<Price> priceList, int period) { List<Double> atrValues = new ArrayList<>(); List<Double> trValues = new ArrayList<>(); // Calculate True Range (TR) for (int i = 1; i < priceList.size(); i++) { Price current = priceList.get(i); Price previous = priceList.get(i - 1); double high = current.getHigh(); double low = current.getLow(); double previousClose = previous.getClose(); // Calculate True Range double tr = Math.max(high - low, Math.max(Math.abs(high - previousClose), Math.abs(low - previousClose))); trValues.add(tr); } // Calculate ATR based on the true range values for (int i = 0; i < trValues.size(); i++) { if (i < period - 1) { atrValues.add(null); // Insufficient data for ATR calculation } else { double sum = 0; for (int j = i - period + 1; j <= i; j++) { sum += trValues.get(j); } atrValues.add(sum / period); // Calculate average } } // Add nulls for remaining entries to match original priceList size while (atrValues.size() < priceList.size()) { atrValues.add(null); } return atrValues; }
} "
Huh super interesting, thanks for the report. I'll take a look
The issue was I had the max tokens fixed to 1024, Ive changed it to be the model max. Fix will be in next release
I have tried to test jlama and when short questions asked it returns answer but when i ask specific question it returns empty result in chat facility.
here are the the steps i took:
" something wrong with the supertrend of rsi calculation can you guess what?
package com.example;
import java.util.ArrayList; import java.util.List;
public class SupertrendRSI {
} "