DataStream updated
This commit is contained in:
@@ -9,8 +9,7 @@ uses
|
||||
DynamicFMXControl in 'DynamicFMXControl.pas',
|
||||
Myc.Trade.Pipeline.Impl in '..\Src\Myc.Trade.Pipeline.Impl.pas',
|
||||
Myc.Trade.Indicators_v2 in '..\Src\Myc.Trade.Indicators_v2.pas',
|
||||
Strategy2 in 'Strategy2.pas',
|
||||
Myc.Trade.DataFeed in '..\Src\Myc.Trade.DataFeed.pas';
|
||||
Strategy2 in 'Strategy2.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ProjectVersion>20.3</ProjectVersion>
|
||||
<FrameworkType>FMX</FrameworkType>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Platform Condition="'$(Platform)'==''">Win64</Platform>
|
||||
<ProjectName Condition="'$(ProjectName)'==''">AuraTrader</ProjectName>
|
||||
<TargetedPlatforms>3</TargetedPlatforms>
|
||||
@@ -140,7 +140,6 @@
|
||||
<DCCReference Include="..\Src\Myc.Trade.Pipeline.Impl.pas"/>
|
||||
<DCCReference Include="..\Src\Myc.Trade.Indicators_v2.pas"/>
|
||||
<DCCReference Include="Strategy2.pas"/>
|
||||
<DCCReference Include="..\Src\Myc.Trade.DataFeed.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
@@ -190,12 +189,6 @@
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win64\Debug\AuraTrader.rsm" Configuration="Debug" Class="DebugSymbols">
|
||||
<Platform Name="Win64">
|
||||
<RemoteName>AuraTrader.rsm</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win64\Release\AuraTrader.exe" Configuration="Release" Class="ProjectOutput">
|
||||
<Platform Name="Win64">
|
||||
<RemoteName>AuraTrader.exe</RemoteName>
|
||||
|
||||
@@ -204,13 +204,6 @@ object Form1: TForm1
|
||||
Text = 'Button2'
|
||||
OnClick = Button2Click
|
||||
end
|
||||
object Button3: TButton
|
||||
Position.X = 64.000000000000000000
|
||||
Position.Y = 152.000000000000000000
|
||||
TabOrder = 2
|
||||
Text = 'Button3'
|
||||
OnClick = Button3Click
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,7 +56,6 @@ uses
|
||||
Myc.Trade.Indicators,
|
||||
Myc.Trade.Indicators.Common,
|
||||
Myc.Core.FileCache,
|
||||
Myc.Trade.DataFeed,
|
||||
StrategyTest,
|
||||
TestMethodCallFromRecordParams;
|
||||
|
||||
@@ -89,7 +88,6 @@ type
|
||||
Strat2Button: TSpeedButton;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure StopButtonClick(Sender: TObject);
|
||||
@@ -97,7 +95,6 @@ type
|
||||
procedure AddWorkspaceActionExecute(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure LogMemoChange(Sender: TObject);
|
||||
procedure Strat2ButtonClick(Sender: TObject);
|
||||
procedure TestActionExecute(Sender: TObject);
|
||||
@@ -115,8 +112,6 @@ type
|
||||
FProcessDone: TState;
|
||||
FApplication: IAuraApplication;
|
||||
FModulesItem: TTreeViewItem;
|
||||
FFileCache: IDataFileCache<TArray<TScalarBatch>>;
|
||||
FFeed: IScalarBatchLoader;
|
||||
function SelectedSymbol: String;
|
||||
procedure ExecuteStrategy(const Symbol: String; Timeframe: TTimeframe; const Consumer: IConsumer<TDataPoint<TOhlcItem>>);
|
||||
|
||||
@@ -197,8 +192,6 @@ procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FApplication := TMycAuraApplication.Create;
|
||||
|
||||
FFileCache := TDataFileCache<TArray<TScalarBatch>>.Create;
|
||||
|
||||
FModulesItem := TTreeViewItem.Create(Self);
|
||||
FModulesItem.Text := 'Modules';
|
||||
|
||||
@@ -350,99 +343,6 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TForm1.Button3Click(Sender: TObject);
|
||||
begin
|
||||
var symbol := SelectedSymbol;
|
||||
if symbol = '' then
|
||||
exit;
|
||||
|
||||
var layout := CurrLayout<TVertScrollBox>;
|
||||
if layout = nil then
|
||||
exit;
|
||||
|
||||
// 1. Setup Chart
|
||||
var chart := TMycChart.Create(Self);
|
||||
AlignControl(chart);
|
||||
chart.Height := layout.ChildrenRect.Width * 9 / 16;
|
||||
chart.Lookback.Value := 500000;
|
||||
|
||||
// 2. Define Schema (Keywords & Layout)
|
||||
var kTime := TKeywordRegistry.Intern('Time');
|
||||
var kClose := TKeywordRegistry.Intern('Close');
|
||||
|
||||
var def :=
|
||||
TScalarRecord.TRegistry.Intern(
|
||||
[
|
||||
TPair<IKeyword, TScalar.TKind>.Create(kTime, TScalar.TKind.DateTime),
|
||||
TPair<IKeyword, TScalar.TKind>.Create(kClose, TScalar.TKind.Float)
|
||||
]
|
||||
);
|
||||
|
||||
// 3. Build Pipeline
|
||||
|
||||
var iTime := def.IndexOf(kTime);
|
||||
var iClose := def.IndexOf(kClose);
|
||||
|
||||
var terminated := TFlag.CreateObserver(FTerminate.Signal).State;
|
||||
var path := '\\COFFEE\TickData\Pepperstone'; // Or FServer.Path if compatible
|
||||
|
||||
FFeed :=
|
||||
TScalarBatchLoader.Create(
|
||||
FFileCache,
|
||||
path,
|
||||
'.m1',
|
||||
true,
|
||||
SizeOf(TM1FileItem),
|
||||
procedure(const Src: Pointer; Dst: TScalar.PValue)
|
||||
var
|
||||
Item: ^TM1FileItem;
|
||||
begin
|
||||
Item := Src;
|
||||
|
||||
// Field 0: Time (DateTime is stored as Double/OADate in TScalar)
|
||||
Dst.AsDouble := Item.OADateTime;
|
||||
|
||||
// Move to next field in destination (TScalar values are contiguous)
|
||||
Inc(Dst);
|
||||
|
||||
// Field 1: Close (Float)
|
||||
// Convert Int64 price to Double using Digits: Price / 10^Digits
|
||||
if Item.Digits > 0 then
|
||||
Dst.AsDouble := Item.Close / Power(10, Item.Digits)
|
||||
else
|
||||
Dst.AsDouble := Item.Close;
|
||||
end
|
||||
);
|
||||
|
||||
// Converter: Transforms raw IRecordSeries (Columns) into TArray<TDataPoint>
|
||||
|
||||
var unpacker := TScalarBatchLoader.CreateTicker(def);
|
||||
|
||||
var ticker :=
|
||||
unpacker.Producer.Chain<TDataPoint<Double>>(
|
||||
function(const Tick: IScalarRecord): TDataPoint<Double>
|
||||
begin
|
||||
Result.Time := Tick[iTime].Value.Value.AsDouble;
|
||||
Result.Data := Tick[iClose].Value.Value.AsDouble;
|
||||
end
|
||||
);
|
||||
|
||||
FFeed.BatchProducer.Chain(unpacker.Consumer);
|
||||
|
||||
// Link Chart to Ticker
|
||||
chart
|
||||
.SetXAxisSeries(TTimeframe.M, ticker.Chain<TDateTime>(function(const p: TDataPoint<Double>): TDateTime begin Result := p.Time end));
|
||||
|
||||
var panel := chart.AddPanel;
|
||||
panel.AddDoubleSeries(
|
||||
ticker.Chain<Double>(function(const p: TDataPoint<Double>): Double begin Result := p.Data end),
|
||||
TAlphaColors.Orange
|
||||
);
|
||||
|
||||
// Connect pipeline: Server -> Converter
|
||||
FProcessDone := FFeed.ProcessData(symbol, terminated);
|
||||
end;
|
||||
|
||||
function TForm1.CreateStrategy2(Timeframe: TTimeframe): IConsumer<TDataPoint<TOhlcItem>>;
|
||||
type
|
||||
TSignal = record
|
||||
|
||||
Reference in New Issue
Block a user