Refactoring to new TDataSeries
This commit is contained in:
@@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
System.SysUtils, System.Classes, System.Generics.Collections, System.StrUtils,
|
||||
Myc.Futures,
|
||||
Myc.TickLoader, Myc.OHLCCache; // OHLCCache for TOHLC, IGenericCandleBuilder, TF_ constants
|
||||
Myc.Trade.DataSeries, Myc.OHLCCache;
|
||||
|
||||
type
|
||||
TTimeframeSetting = record
|
||||
@@ -16,7 +16,7 @@ type
|
||||
|
||||
TChartDataController = class
|
||||
private
|
||||
FTickDataArray: TArray<TTickData>;
|
||||
FTickDataArray: TArray<TAskBid.TTick>;
|
||||
FOHLCCacheList: TList<TOHLC>;
|
||||
FTimeframeSettingsArray: TArray<TTimeframeSetting>; // Now includes registered generic builders
|
||||
FMemoLog: TStrings;
|
||||
@@ -39,9 +39,8 @@ type
|
||||
|
||||
procedure ClearAllDataAndCaches;
|
||||
function GetTickDataCount: Integer;
|
||||
function GetTickDataArrayPtr: PTTickData;
|
||||
function GetTickDataLength: Integer;
|
||||
function GetTickDataItem(AIndex: Integer): TTickData;
|
||||
function GetTickDataItem(AIndex: Integer): TAskBid.TTick;
|
||||
function HasData: Boolean;
|
||||
|
||||
// ABuilderCaption is the unique key used for FTimeframeSettingsArray.Caption and FGenericBuilders key.
|
||||
@@ -55,7 +54,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.DateUtils; // For FormatDateTime in logging
|
||||
System.DateUtils;
|
||||
|
||||
const
|
||||
dcSecsPerDayConst = 24 * 60 * 60;
|
||||
@@ -211,7 +210,7 @@ procedure TChartDataController.LoadTickDataSeries(const AFileName: string);
|
||||
begin
|
||||
ClearAllDataAndCaches();
|
||||
try
|
||||
FTickDataArray := Myc.TickLoader.LoadTickDataSeries(AFileName).WaitFor;
|
||||
FTickDataArray := TAskBid.LoadDataSeries(AFileName).WaitFor();
|
||||
if FMemoLog <> nil then
|
||||
FMemoLog.Add(Format('DataController: Loading tick records from series: %s',
|
||||
[AFileName]));
|
||||
@@ -401,20 +400,12 @@ begin
|
||||
Result := Length(FTickDataArray);
|
||||
end;
|
||||
|
||||
function TChartDataController.GetTickDataArrayPtr: PTTickData;
|
||||
begin
|
||||
if Length(FTickDataArray) > 0 then
|
||||
Result := @FTickDataArray[0]
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TChartDataController.GetTickDataLength: Integer;
|
||||
begin
|
||||
Result := Length(FTickDataArray);
|
||||
end;
|
||||
|
||||
function TChartDataController.GetTickDataItem(AIndex: Integer): TTickData;
|
||||
function TChartDataController.GetTickDataItem(AIndex: Integer): TAskBid.TTick;
|
||||
begin
|
||||
if (AIndex >= 0) and (AIndex < Length(FTickDataArray)) then
|
||||
Result := FTickDataArray[AIndex]
|
||||
@@ -422,7 +413,7 @@ begin
|
||||
begin
|
||||
if FMemoLog <> nil then
|
||||
FMemoLog.Add(Format('DataController: Attempted to access invalid tick data index %d. Count is %d.', [AIndex, Length(FTickDataArray)]));
|
||||
Result := Default(TTickData);
|
||||
Result := Default(TAskBid.TTick);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user