diff --git a/AuraTrader/MainForm.pas b/AuraTrader/MainForm.pas index 1514a2b..86ad195 100644 --- a/AuraTrader/MainForm.pas +++ b/AuraTrader/MainForm.pas @@ -114,7 +114,7 @@ type FProcessDone: TState; FApplication: IAuraApplication; FModulesItem: TTreeViewItem; - FTickerServer: IScalarBatchServer; + FFeed: IScalarRecordFeed; function SelectedSymbol: String; procedure ExecuteStrategy(const Symbol: String; Timeframe: TTimeframe; const Consumer: IConsumer>); @@ -382,11 +382,11 @@ begin var terminated := TFlag.CreateObserver(FTerminate.Signal).State; var path := '\\COFFEE\TickData\Pepperstone'; // Or FServer.Path if compatible - FTickerServer := TScalarBatchServer.Create(path, '.m1', true, def) as IScalarBatchServer; + FFeed := TScalarRecordFeed.Create(path, '.m1', true, def); // Converter: Transforms raw IRecordSeries (Columns) into TArray var ticker := - FTickerServer.Ticker.Chain>( + FFeed.Ticker.Chain>( function(const Tick: IScalarRecord): TDataPoint begin Result.Time := Tick.ItemByIndex(iTime).Value.AsDouble; @@ -404,7 +404,7 @@ begin TAlphaColors.Orange ); - FTickerServer.SetImportOptions( + FFeed.SetImportOptions( SizeOf(TM1FileItem), procedure(const Src: Pointer; Dst: TScalar.PValue) var @@ -428,7 +428,7 @@ begin ); // Connect pipeline: Server -> Converter - FProcessDone := FTickerServer.ProcessData(symbol, terminated); + FProcessDone := FFeed.ProcessData(symbol, terminated); end; function TForm1.CreateStrategy2(Timeframe: TTimeframe): IConsumer>; diff --git a/Src/Myc.Trade.DataFeed.pas b/Src/Myc.Trade.DataFeed.pas index 54765be..a500718 100644 --- a/Src/Myc.Trade.DataFeed.pas +++ b/Src/Myc.Trade.DataFeed.pas @@ -14,7 +14,7 @@ uses Myc.Data.Scalar, Myc.Data.Keyword, Myc.Data.Pipeline, - Myc.Data.Pipeline.Impl, // Added for TMycContainedProducer + Myc.Data.Pipeline.Impl, Myc.Core.FileCache; type @@ -31,7 +31,7 @@ type property Items[const Key: IKeyword]: TScalar read GetItems; default; end; - IScalarBatchServer = interface + IScalarRecordFeed = interface procedure ClearCache; procedure SetImportOptions(RecordSize: Integer; const Converter: TImportConverter); function EnumerateSymbols: TFuture>; @@ -43,7 +43,7 @@ type property Ticker: TProducer read GetTicker; end; - TScalarBatchServer = class(TInterfacedObject, IScalarBatchServer) + TScalarRecordFeed = class(TInterfacedObject, IScalarRecordFeed) public type TBatch = record @@ -197,9 +197,9 @@ begin Result.Create(FDef.Fields[Idx].Value, TScalar.PValue(NativeUInt(FData) + NativeUInt(idx * SizeOf(TScalar.TValue)))^); end; -{ TScalarBatchServer.TDataFile } +{ TScalarRecordFeed.TDataFile } -constructor TScalarBatchServer.TDataFile.Create(const APath, ASymbol, AExtension: String; AYear, AMonth: Integer; const ABasename: String); +constructor TScalarRecordFeed.TDataFile.Create(const APath, ASymbol, AExtension: String; AYear, AMonth: Integer; const ABasename: String); begin FPath := APath; FSymbol := ASymbol; @@ -209,24 +209,24 @@ begin FBasename := ABasename; end; -function TScalarBatchServer.TDataFile.GetBaseFileName: string; +function TScalarRecordFeed.TDataFile.GetBaseFileName: string; begin Result := FBasename; end; -function TScalarBatchServer.TDataFile.GetFullFileName: string; +function TScalarRecordFeed.TDataFile.GetFullFileName: string; begin Result := TPath.Combine(FPath, GetBaseFileName + FExtension); end; -function TScalarBatchServer.TDataFile.GetIsValid: Boolean; +function TScalarRecordFeed.TDataFile.GetIsValid: Boolean; begin Result := (FSymbol <> '') and (FYear > 0); end; -{ TScalarBatchServer } +{ TScalarRecordFeed } -constructor TScalarBatchServer.Create( +constructor TScalarRecordFeed.Create( const APath: String; const AExtension: String; IsCompressed: Boolean; @@ -249,43 +249,43 @@ begin .Create(function(const Filename: String): TFuture> begin Result := DoLoad(Filename, FLoadGate); end); end; -destructor TScalarBatchServer.Destroy; +destructor TScalarRecordFeed.Destroy; begin ClearCache; - FTicker.Free; FCachedFiles.Free; + FTicker.Free; inherited Destroy; end; -procedure TScalarBatchServer.AfterConstruction; +procedure TScalarRecordFeed.AfterConstruction; begin inherited; UpdateSymbols; end; -procedure TScalarBatchServer.ClearCache; +procedure TScalarRecordFeed.ClearCache; begin FCachedFiles.Clear; end; -procedure TScalarBatchServer.SetImportOptions(RecordSize: Integer; const Converter: TImportConverter); +procedure TScalarRecordFeed.SetImportOptions(RecordSize: Integer; const Converter: TImportConverter); begin FImportRecordSize := RecordSize; FImportConverter := Converter; ClearCache; end; -function TScalarBatchServer.GetPath: String; +function TScalarRecordFeed.GetPath: String; begin Result := FPath; end; -function TScalarBatchServer.GetTicker: TProducer; +function TScalarRecordFeed.GetTicker: TProducer; begin Result := FTicker; end; -procedure TScalarBatchServer.UpdateSymbols; +procedure TScalarRecordFeed.UpdateSymbols; begin FSymbols := TFuture>>.Construct( @@ -346,7 +346,7 @@ begin FSymbols.Manage; end; -function TScalarBatchServer.EnumerateSymbols: TFuture>; +function TScalarRecordFeed.EnumerateSymbols: TFuture>; begin Result := FSymbols.Chain>( @@ -354,7 +354,7 @@ begin ); end; -function TScalarBatchServer.FindFirstFile(const Symbol: string): TFuture; +function TScalarRecordFeed.FindFirstFile(const Symbol: string): TFuture; begin var symName := Symbol; Result := @@ -371,7 +371,7 @@ begin ); end; -function TScalarBatchServer.GetNextFile(const Curr: TDataFile): TDataFile; +function TScalarRecordFeed.GetNextFile(const Curr: TDataFile): TDataFile; var allSymbolFiles: TArray; foundIndex: Integer; @@ -399,7 +399,7 @@ begin end; end; -function TScalarBatchServer.ParseFileName(const FileName: string): TDataFile; +function TScalarRecordFeed.ParseFileName(const FileName: string): TDataFile; var path, fileNameNoPath, baseName, ext, symbol: string; year, month: Integer; @@ -440,7 +440,7 @@ begin Result := TDataFile.Create(path, symbol, ext, year, month, baseName); end; -function TScalarBatchServer.LoadDataFile(const DataFile: TDataFile): TFuture>; +function TScalarRecordFeed.LoadDataFile(const DataFile: TDataFile): TFuture>; begin if DataFile.IsValid then Result := FCachedFiles.GetOrAdd(DataFile.GetFullFileName) @@ -448,7 +448,7 @@ begin Result := TFuture>.Construct(TArray(nil)); end; -function TScalarBatchServer.DoLoad(const FileName: string; const Gate: TLatch): TFuture>; +function TScalarRecordFeed.DoLoad(const FileName: string; const Gate: TLatch): TFuture>; begin Result := TFuture>.Null; if not TFile.Exists(FileName) then @@ -490,7 +490,7 @@ begin end; end; -function TScalarBatchServer.ReadCompressedData(const InputStream: TStream): TArray; +function TScalarRecordFeed.ReadCompressedData(const InputStream: TStream): TArray; var decompressionStream: TStream; localHeader: TZipHeader; @@ -536,7 +536,7 @@ begin end; end; -function TScalarBatchServer.ReadUncompressedData(const InputStream: TStream): TArray; +function TScalarRecordFeed.ReadUncompressedData(const InputStream: TStream): TArray; var fileSize, totalRecords: Int64; fieldsPerRecord: Integer; @@ -605,7 +605,7 @@ begin end; end; -function TScalarBatchServer.ProcessData(const Symbol: String; const Terminated: TState): TState; +function TScalarRecordFeed.ProcessData(const Symbol: String; const Terminated: TState): TState; begin var cTerminated := Terminated; @@ -618,7 +618,7 @@ begin end); end; -function TScalarBatchServer.ProcessFile(FileInfo: TDataFile; const DataFile: TFuture>; const Terminated: TState): TState; +function TScalarRecordFeed.ProcessFile(FileInfo: TDataFile; const DataFile: TFuture>; const Terminated: TState): TState; begin if not FileInfo.IsValid or Terminated.IsSet then exit(DataFile.Done); @@ -638,7 +638,7 @@ begin ); end; -function TScalarBatchServer.ProcessChunks(const Batches: TArray; Terminated: TState): TState; +function TScalarRecordFeed.ProcessChunks(const Batches: TArray; Terminated: TState): TState; begin var callProcess := function(Idx: Integer): TFunc