diff --git a/AuraTrader/AuraTrader.dproj b/AuraTrader/AuraTrader.dproj
index 78cf432..e0cbb98 100644
--- a/AuraTrader/AuraTrader.dproj
+++ b/AuraTrader/AuraTrader.dproj
@@ -4,7 +4,7 @@
20.3
FMX
True
- Release
+ Debug
Win64
AuraTrader
3
diff --git a/AuraTrader/MainForm.pas b/AuraTrader/MainForm.pas
index 6a00f60..5199b31 100644
--- a/AuraTrader/MainForm.pas
+++ b/AuraTrader/MainForm.pas
@@ -88,10 +88,14 @@ begin
if SymbolsComboBox.ItemIndex < 0 then
exit;
- var arr := TDataSeries.CreateArray(3000);
var curr := TWriteable>.CreateProtected;
var Symbol := FSymbols.WaitFor[SymbolsComboBox.ItemIndex];
+ var currPathData := TWriteable>.CreateProtected;
+
+ LogMemo.AddIdleHandler(curr.Changed, procedure begin LogMemo.Lines.Add(Symbol + ': ' + curr.Value.TotalCount.ToString); end);
+
+ var arr := TDataSeries.CreateArray(3000);
var done :=
FServer.ProcessData(
Symbol,
@@ -100,12 +104,36 @@ begin
begin
arr.Add(Values);
curr.Value := arr.Copy;
+
+ var PathData := TPathData.Create;
+ var Prices := arr;
+ if Prices.Count > 0 then
+ begin
+ PathData.MoveTo(PointF(Prices.Count - 1, Prices[0].Data.Ask));
+ for var i := 1 to Prices.Count - 1 do
+ PathData.LineTo(PointF(Prices.Count - i - 1, Prices[i].Data.Ask));
+ end;
+
+ currPathData.Value := TObjectRef.Create(PathData);
end
);
FLoadDone := TState.All([FLoadDone, done]);
- LogMemo.AddIdleHandler(curr.Changed, procedure begin LogMemo.Lines.Add(Symbol + ': ' + curr.Value.TotalCount.ToString); end);
+ Path1.AddIdleHandler(
+ currPathData.Changed,
+ procedure
+ begin
+ if currPathData.Value<>nil then
+ begin
+ Path1.Data.Assign( currPathData.Value.Obj );
+ currPathData.Value := nil;
+ end;
+ end );
+
+
+(*
+ FLoadDone := TState.All([FLoadDone, done]);
Path1.AddIdleHandler(
curr.Changed,
@@ -120,13 +148,16 @@ begin
Path1.Data.Clear;
Path1.Data.MoveTo(PointF(Path1.Width - 1, Prices[0].Data.Ask));
for var i := 1 to Prices.Count - 1 do
+ begin
Path1.Data.LineTo(PointF(Path1.Width - i - 1, Prices[i].Data.Ask));
+ end;
finally
Path1.EndUpdate;
end;
end;
end
);
+*)
end;
procedure TForm1.Button2Click(Sender: TObject);
diff --git a/Src/Myc.Futures.pas b/Src/Myc.Futures.pas
index 7ac3bb2..6a97f71 100644
--- a/Src/Myc.Futures.pas
+++ b/Src/Myc.Futures.pas
@@ -59,6 +59,22 @@ type
property Value: T read GetValue;
end;
+ IObjectRef = interface
+ function GetObj: T;
+ function Pop: T;
+ property Obj: T read GetObj;
+ end;
+
+ TObjectRef = class(TInterfacedObject, IObjectRef)
+ private
+ FObj: T;
+ function GetObj: T;
+ public
+ constructor Create(const ARef: T);
+ destructor Destroy; override;
+ function Pop: T;
+ end;
+
implementation
uses
@@ -144,4 +160,27 @@ begin
Dest.FFuture := FNull;
end;
+constructor TObjectRef.Create(const ARef: T);
+begin
+ inherited Create;
+ FObj := ARef;
+end;
+
+destructor TObjectRef.Destroy;
+begin
+ FObj.Free;
+ inherited Destroy;
+end;
+
+function TObjectRef.GetObj: T;
+begin
+ Result := FObj;
+end;
+
+function TObjectRef.Pop: T;
+begin
+ Result := FObj;
+ FreeAndNil( FObj );
+end;
+
end.
diff --git a/Src/Myc.Trade.DataStream.pas b/Src/Myc.Trade.DataStream.pas
index eef52b3..21579e2 100644
--- a/Src/Myc.Trade.DataStream.pas
+++ b/Src/Myc.Trade.DataStream.pas
@@ -101,7 +101,7 @@ type
// Used by cache to actually load an uncached file.
function DoLoad(const FileName: string): TFuture>>;
- function LoadFile(currFile: TAuraDataFile; Terminated: TState; Proc: TDataProc): TState;
+ function LoadFile(DataFile: TAuraDataFile; Terminated: TState; Proc: TDataProc): TState;
strict private
class var
@@ -400,19 +400,19 @@ begin
Result := FCachedFiles.GetOrAdd(DataFile.GetFullFileName);
end;
-function TAuraDataServer.LoadFile(currFile: TAuraDataFile; Terminated: TState; Proc: TDataProc): TState;
+function TAuraDataServer.LoadFile(DataFile: TAuraDataFile; Terminated: TState; Proc: TDataProc): TState;
begin
- if not currFile.IsValid or Terminated.IsSet then
+ if not DataFile.IsValid or Terminated.IsSet then
exit(TState.Null);
- var data := FCachedFiles.GetOrAdd(currFile.GetFullFileName);
+ var data := FCachedFiles.GetOrAdd(DataFile.GetFullFileName);
Result :=
data.Chain(
function(const Data: TArray>): TState
begin
Proc(Data, Terminated);
- Result := LoadFile(currFile.GetNextFile, Terminated, Proc);
+ Result := LoadFile(DataFile.GetNextFile, Terminated, Proc);
end
);
end;