TDataPoint<T> review

This commit is contained in:
Michael Schimmel
2025-06-11 08:54:04 +02:00
parent c4152d25cd
commit b03d02449a
3 changed files with 27 additions and 27 deletions
+12 -12
View File
@@ -56,8 +56,8 @@ type
// Interface for generic candle building logic
IGenericCandleBuilder = interface
function Init(const ADataSet: TArray<TDataRecord<TAskBidItem>>): Boolean; // Changed DataSet to ADataSet for clarity
function IsNewBar(AIndex: Integer; const ATick: TDataRecord<TAskBidItem>): Boolean; // Changed Idx to AIndex, Tick to ATick
function Init(const ADataSet: TArray<TDataPoint<TAskBidItem>>): Boolean; // Changed DataSet to ADataSet for clarity
function IsNewBar(AIndex: Integer; const ATick: TDataPoint<TAskBidItem>): Boolean; // Changed Idx to AIndex, Tick to ATick
function GetCaption: string; // Method for the Caption property
property Caption: string read GetCaption;
end;
@@ -80,7 +80,7 @@ type
public
constructor Create;
procedure ClearCache;
procedure Build(const ATickData: TArray<TDataRecord<TAskBidItem>>;
procedure Build(const ATickData: TArray<TDataPoint<TAskBidItem>>;
ASelectedTimeframeSeconds: Int64;
AAutoAggCandleWidth: Integer;
AAutoAggCandleSpacing: Integer;
@@ -188,7 +188,7 @@ begin
Result := Length(FCachedCandles);
end;
procedure TOHLC.Build(const ATickData: TArray<TDataRecord<TAskBidItem>>;
procedure TOHLC.Build(const ATickData: TArray<TDataPoint<TAskBidItem>>;
ASelectedTimeframeSeconds: Int64;
AAutoAggCandleWidth: Integer; AAutoAggCandleSpacing: Integer; AAutoAggPaintBoxClientWidth: Integer;
AMemoForLogging: TStrings; AGenericCandleBuilder: IGenericCandleBuilder = nil); // Parameter changed
@@ -200,7 +200,7 @@ var
CandleList: TList<TCachedCandle>;
TempCandle: TCachedCandle;
LogTimePerCandleStr: string;
CurrentTick: TDataRecord<TAskBidItem>;
CurrentTick: TDataPoint<TAskBidItem>;
begin
if AMemoForLogging <> nil then
AMemoForLogging.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now) + Format(' - TOHLC.Build: TF Secs: %d...',
@@ -353,8 +353,8 @@ begin
SetLength(FCachedCandles, NumCandlesToCacheAuto);
if (NumDataPoints > 1) and (NumCandlesToCacheAuto > 0) then
begin
var FirstTickTimeVal_A := ATickData[0].TimeStamp;
var LastTickTimeVal_A := ATickData[High(ATickData)].TimeStamp;
var FirstTickTimeVal_A := ATickData[0].Time;
var LastTickTimeVal_A := ATickData[High(ATickData)].Time;
var TotalDataDurationDaysVal_A := LastTickTimeVal_A - FirstTickTimeVal_A;
if NumCandlesToCacheAuto > 0 then // Avoid division by zero if NumCandlesToCacheAuto is somehow 0 here
begin
@@ -432,7 +432,7 @@ begin
CurrentTickIndex := 0;
while CurrentTickIndex <= High(ATickData) do
begin
BucketStartTimeOADate := Floor(ATickData[CurrentTickIndex].TimeStamp / TimeframeIntervalOADays) * TimeframeIntervalOADays;
BucketStartTimeOADate := Floor(ATickData[CurrentTickIndex].Time / TimeframeIntervalOADays) * TimeframeIntervalOADays;
BucketEndTimeOADate := BucketStartTimeOADate + TimeframeIntervalOADays;
DataIndexStart := CurrentTickIndex;
@@ -444,8 +444,8 @@ begin
// Iterate through ticks that fall into the current bucket
while (CurrentTickIndex <= High(ATickData)) and
(ATickData[CurrentTickIndex].TimeStamp >= BucketStartTimeOADate) and
(ATickData[CurrentTickIndex].TimeStamp < BucketEndTimeOADate) do
(ATickData[CurrentTickIndex].Time >= BucketStartTimeOADate) and
(ATickData[CurrentTickIndex].Time < BucketEndTimeOADate) do
begin
if ATickData[CurrentTickIndex].Data.Ask > HighPrice then HighPrice := ATickData[CurrentTickIndex].Data.Ask; // Changed
if ATickData[CurrentTickIndex].Data.Ask < LowPrice then LowPrice := ATickData[CurrentTickIndex].Data.Ask; // Changed
@@ -492,8 +492,8 @@ begin
if Length(ATickData) > 0 then
begin
var FirstTickTimeVal := ATickData[0].TimeStamp;
var LastTickTimeVal := ATickData[High(ATickData)].TimeStamp;
var FirstTickTimeVal := ATickData[0].Time;
var LastTickTimeVal := ATickData[High(ATickData)].Time;
FTotalDataTimeSpanText := FormatTimeSpanFromSeconds((LastTickTimeVal - FirstTickTimeVal) * SecsPerDay_Double);
if AMemoForLogging <> nil then
AMemoForLogging.Add(Format('TOHLC.Build: Total data time span: %s.', [FTotalDataTimeSpanText]));