From 4247fde7cd165a12c9a017bb84359b8eac331850 Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Mon, 14 Jul 2025 19:55:16 +0200 Subject: [PATCH] Old DataStream removed --- AuraTrader/MainForm.pas | 1 - Src/Myc.Fmx.Chart.Series.pas | 2 +- Src/Myc.Test.Trade.DataStream.pas | 144 ------------------------------ Src/Myc.Trade.DataProvider.pas | 13 --- Test/MycTests.dpr | 54 ++++++----- Test/MycTests.dproj | 2 - 6 files changed, 27 insertions(+), 189 deletions(-) delete mode 100644 Src/Myc.Test.Trade.DataStream.pas delete mode 100644 Src/Myc.Trade.DataProvider.pas diff --git a/AuraTrader/MainForm.pas b/AuraTrader/MainForm.pas index f86b112..4b92402 100644 --- a/AuraTrader/MainForm.pas +++ b/AuraTrader/MainForm.pas @@ -30,7 +30,6 @@ uses Myc.Trade.Types, Myc.Trade.DataStream, Myc.Trade.DataPoint, - Myc.Trade.DataProvider, Myc.Signals, Myc.Mutable, Myc.Signals.FMX, diff --git a/Src/Myc.Fmx.Chart.Series.pas b/Src/Myc.Fmx.Chart.Series.pas index a3d66f7..69274e2 100644 --- a/Src/Myc.Fmx.Chart.Series.pas +++ b/Src/Myc.Fmx.Chart.Series.pas @@ -261,7 +261,7 @@ begin end; Canvas.Stroke.Color := FLineColor; - Canvas.Stroke.Thickness := 3; //FLineWidth; + Canvas.Stroke.Thickness := FLineWidth; Canvas.Stroke.Join := TStrokeJoin.Bevel; Canvas.DrawPath(points, 1); finally diff --git a/Src/Myc.Test.Trade.DataStream.pas b/Src/Myc.Test.Trade.DataStream.pas deleted file mode 100644 index 9d3b854..0000000 --- a/Src/Myc.Test.Trade.DataStream.pas +++ /dev/null @@ -1,144 +0,0 @@ -unit Myc.Test.Trade.DataStream; - -interface - -uses - System.SysUtils, - System.Generics.Collections, - DUnitX.TestFramework, - Myc.Signals, - Myc.Mutable, - Myc.Futures, - Myc.Trade.Types, - Myc.Trade.DataPoint, - Myc.Trade.DataStream; - -type - // Test fixture for TDataServer and TAuraTABFileServer, focusing on data equivalence - // with TDataSeries.LoadDataSeries. - [TestFixture] - [IgnoreMemoryLeaks(true)] - TTest_TABFileServer_Equivalence = class(TObject) - private - FServer: IDataServer; - FStream: IDataStream; - public - [SetupFixture] - procedure SetupFixture; - [Setup] - procedure Setup; - [TearDown] - procedure TearDown; - [TearDownFixture] - procedure TearDownFixture; - - [Test] - procedure Test_ServerReturnsSameDataAs_LoadDataSeries; - end; - -implementation - -uses - Myc.TaskManager; - -const - // The reference data file for this test. - C_TEST_PATH = '\\COFFEE\TickData\Pepperstone'; - C_TEST_SYMBOL = 'GER40'; - // The chunk size for fetching data from the server. - C_MAX_FETCH = 200; - -{ TTest_TABFileServer_Equivalence } - -procedure TTest_TABFileServer_Equivalence.SetupFixture; -begin - FServer := TAuraTABFileServer.Create(C_TEST_PATH); - // TAskBid.ClearCache ensures a clean state for data series loading. - FServer.ClearCache; -end; - -procedure TTest_TABFileServer_Equivalence.TearDownFixture; -begin - FServer := nil; -end; - -procedure TTest_TABFileServer_Equivalence.Setup; -begin - // Initializes the data server with a specific test file. - FStream := FServer.CreateStream(C_TEST_SYMBOL); -end; - -procedure TTest_TABFileServer_Equivalence.TearDown; -begin - // Releases the data server instance. - FStream := nil; - // Clears any cached data to prevent interference with subsequent tests. - FServer.ClearCache; -end; - -procedure TTest_TABFileServer_Equivalence.Test_ServerReturnsSameDataAs_LoadDataSeries; -var - chunk: array[0..C_MAX_FETCH - 1] of TDataPoint; - dst: TArray>; - i: Int64; - n: Integer; - cnt: Int64; - timeout: Integer; - filename: TAuraDataFile; - expectedData: TArray>; -begin - // 1. Expected data is loaded directly using LoadDataSeries. - filename := (FServer as TAuraDataServer).FindFirstFile(C_TEST_SYMBOL).WaitFor; - Assert.IsTrue(filename.IsValid, 'Test data file could not be found.'); - - expectedData := (FServer as TAuraTABFileServer).LoadDataSeries(filename).WaitFor; - SetLength(dst, Length(expectedData)); - - // 2. Fetch data chunks from the stream until all data is retrieved. - cnt := 0; - timeout := 0; - while (cnt < Length(expectedData)) do - begin - n := FStream.GetChunk(chunk); - if n > 0 then - begin - Move(chunk[0], dst[cnt], n * SizeOf(TDataPoint)); - Inc(cnt, n); - timeout := 0; // Reset timeout on progress - end - else - begin - // If GetChunk returns 0, the stream might be waiting for async I/O. - // A small sleep prevents a tight loop from consuming 100% CPU. - Sleep(1); - Inc(timeout); - Assert.IsTrue(timeout < 5000, 'Test timed out waiting for data from stream.'); - end; - end; - - // 3. A final call should return 0, as the stream must be depleted. - n := FStream.GetChunk(chunk); - Assert.AreEqual(0, n, 'Stream returned data after it should have been depleted.'); - n := FStream.GetChunk(chunk); - Assert.AreEqual(0, n, 'Stream returned data after it should have been depleted.'); - - // --- Assertions --- - - // 4. Verify that the total number of records fetched matches the expected count. - Assert.AreEqual(Length(expectedData), cnt, 'Data record count mismatch.'); - - // 5. Verify that the content of each record is identical. - // The loop checks every 1000th element for efficiency. - for n := 0 to High(expectedData) div 1000 do - begin - i := n * 1000; - Assert.AreEqual(expectedData[i].Time, dst[i].Time, 'Timestamp mismatch at index ' + i.ToString); - Assert.AreEqual(expectedData[i].Data.Ask, dst[i].Data.Ask, 'Ask price mismatch at index ' + i.ToString); - Assert.AreEqual(expectedData[i].Data.Bid, dst[i].Data.Bid, 'Bid price mismatch at index ' + i.ToString); - end; -end; - -initialization - // Registers the test fixture with DUnitX. - TDUnitX.RegisterTestFixture(TTest_TABFileServer_Equivalence); -end. diff --git a/Src/Myc.Trade.DataProvider.pas b/Src/Myc.Trade.DataProvider.pas deleted file mode 100644 index 6b167d7..0000000 --- a/Src/Myc.Trade.DataProvider.pas +++ /dev/null @@ -1,13 +0,0 @@ -unit Myc.Trade.DataProvider; - -interface - -uses - Myc.Signals, - Myc.Mutable, - Myc.Trade.DataPoint, - Myc.Trade.DataStream; - -implementation - -end. diff --git a/Test/MycTests.dpr b/Test/MycTests.dpr index f5e3013..d48091f 100644 --- a/Test/MycTests.dpr +++ b/Test/MycTests.dpr @@ -5,34 +5,32 @@ program MycTests; {$ENDIF} {$STRONGLINKTYPES ON} uses - FastMM5, - DUnitX.MemoryLeakMonitor.FastMM5, - System.SysUtils, -{$IFDEF TESTINSIGHT} - TestInsight.DUnitX, -{$ELSE} - DUnitX.Loggers.Console, -{$ENDIF } - DUnitX.TestFramework, - TestNotifier in 'TestNotifier.pas', - TestNotifier_Threading in 'TestNotifier_Threading.pas' {/TestNotifier_ChaosStress in 'TestNotifier_ChaosStress.pas',}, - TestNotifier_ChaosStress in 'TestNotifier_ChaosStress.pas', - TestTasks in 'TestTasks.pas', - Myc.Futures in '..\Src\Myc.Futures.pas', - TestCoreFutures in 'TestCoreFutures.pas', - Myc.TaskManager in '..\Src\Myc.TaskManager.pas', - TestFutures in 'TestFutures.pas', - Myc.Test.Core.Atomic in '..\Src\Myc.Test.Core.Atomic.pas', - Myc.Test.Signals.Latch in '..\Src\Myc.Test.Signals.Latch.pas', - Myc.Test.Signals.Dirty in '..\Src\Myc.Test.Signals.Dirty.pas', - Myc.Trade.DataPoint in '..\Src\Myc.Trade.DataPoint.pas', - Myc.Trade.Node in '..\Src\Myc.Trade.Node.pas', - Myc.Trade.DataStream in '..\Src\Myc.Trade.DataStream.pas', - Myc.Test.Trade.DataStream in '..\Src\Myc.Test.Trade.DataStream.pas', - Myc.Test.Trade.DataPoint in '..\Src\Myc.Test.Trade.DataPoint.pas', - Myc.Trade.DataProvider in '..\Src\Myc.Trade.DataProvider.pas', - Myc.Mutable in '..\Src\Myc.Mutable.pas', - Test.Core.Mutable in 'Test.Core.Mutable.pas'; + FastMM5, + DUnitX.MemoryLeakMonitor.FastMM5, + System.SysUtils, + {$IFDEF TESTINSIGHT} + TestInsight.DUnitX, + {$ELSE} + DUnitX.Loggers.Console, + {$ENDIF } + DUnitX.TestFramework, + TestNotifier in 'TestNotifier.pas', + TestNotifier_Threading in 'TestNotifier_Threading.pas' {/TestNotifier_ChaosStress in 'TestNotifier_ChaosStress.pas',}, + TestNotifier_ChaosStress in 'TestNotifier_ChaosStress.pas', + TestTasks in 'TestTasks.pas', + Myc.Futures in '..\Src\Myc.Futures.pas', + TestCoreFutures in 'TestCoreFutures.pas', + Myc.TaskManager in '..\Src\Myc.TaskManager.pas', + TestFutures in 'TestFutures.pas', + Myc.Test.Core.Atomic in '..\Src\Myc.Test.Core.Atomic.pas', + Myc.Test.Signals.Latch in '..\Src\Myc.Test.Signals.Latch.pas', + Myc.Test.Signals.Dirty in '..\Src\Myc.Test.Signals.Dirty.pas', + Myc.Trade.DataPoint in '..\Src\Myc.Trade.DataPoint.pas', + Myc.Trade.Node in '..\Src\Myc.Trade.Node.pas', + Myc.Trade.DataStream in '..\Src\Myc.Trade.DataStream.pas', + Myc.Test.Trade.DataPoint in '..\Src\Myc.Test.Trade.DataPoint.pas', + Myc.Mutable in '..\Src\Myc.Mutable.pas', + Test.Core.Mutable in 'Test.Core.Mutable.pas'; { keep comment here to protect the following conditional from being removed by the IDE when adding a unit } {$IFNDEF TESTINSIGHT} diff --git a/Test/MycTests.dproj b/Test/MycTests.dproj index e255d41..4a5fd2b 100644 --- a/Test/MycTests.dproj +++ b/Test/MycTests.dproj @@ -128,9 +128,7 @@ $(PreBuildEvent)]]> - -