generateCandleVectors function
Implementation
Future<List<List<num>>> generateCandleVectors({
required String assetType,
required String ticker,
required List<int> timestamps,
required List<double> opens,
required List<double> closes,
required List<double> lows,
required List<double> highs,
}) async {
final int length = timestamps.length;
if ([opens, closes, lows, highs].any((list) => list.length != length)) {
throw ArgumentError(
'Todas as listas devem ter o mesmo tamanho e não podem estar vazias.');
}
if (length == 0) {
throw ArgumentError('As listas não podem estar vazias.');
}
final fbblNumber = generateSecureNumericHash(ticker);
final blindScale = await generateBlindScale(assetType);
List<List<num>> vectors = [];
for (int i = 0; i < length; i++) {
final encodedOpen = await encodeScale(opens[i], assetType);
final encodedClose = await encodeScale(closes[i], assetType);
final encodedLow = await encodeScale(lows[i], assetType);
final encodedHigh = await encodeScale(highs[i], assetType);
final blindOHLC = await applyBlindScale(
[encodedOpen, encodedClose, encodedLow, encodedHigh], blindScale);
vectors.add([timestamps[i], ...blindOHLC, fbblNumber]);
}
return vectors;
}