Bugfix in TEvent, DataServer Push-Mode

This commit is contained in:
Michael Schimmel
2025-06-24 18:32:32 +02:00
parent 35413f5966
commit 3797507d95
13 changed files with 251 additions and 69 deletions
+33 -49
View File
@@ -3,70 +3,54 @@ unit Myc.Trade.Ticker;
interface
uses
Myc.Lazy;
System.SysUtils,
Myc.Signals,
Myc.Lazy,
Myc.Trade.DataPoint,
Myc.Trade.DataStream,
Myc.Trade.DataProvider;
type
TMycLogger = reference to procedure(const Msg: String);
TTickProc<T> = reference to procedure(const Tick: TDataPoint<T>);
IMycTradeObject = interface
end;
TMycTradeObject = class(TInterfacedObject, IMycTradeObject)
TTicker<T> = class(TInterfacedObject, TSignal.ISubscriber)
type
TConsumer = record
Proc: TTickProc<T>;
Lookback: Int64;
end;
private
FCaption: string;
FLog: TMycLogger;
function GetCaption: string;
FStream: IDataStream<T>;
FConsumers: TArray<TConsumer>;
FProvider: TMutable<TDataSeries<T>>;
function Notify: Boolean;
public
constructor Create(const ACaption: string; ALog: TMycLogger);
property Caption: string read GetCaption;
property Log: TMycLogger read FLog;
end;
IMycTime = interface
{$REGION 'property access'}
function GetTimeStamp: TDateTime;
{$ENDREGION}
property TimeStamp: TDateTime read GetTimeStamp;
end;
IMycTick = interface
{$REGION 'property access'}
function GetAsk: Double;
function GetBid: Double;
function GetTime: IMycTime;
function GetVolume: Double;
{$ENDREGION}
property Ask: Double read GetAsk;
property Bid: Double read GetBid;
property Time: IMycTime read GetTime;
property Volume: Double read GetVolume;
end;
IMycTicker = interface(IMycTradeObject)
{$REGION 'property access'}
function GetLastTick: TLazy<IMycTick>;
function GetCurrentTime: IMycTime;
{$ENDREGION}
property LastTick: TLazy<IMycTick> read GetLastTick;
property CurrentTime: IMycTime read GetCurrentTime;
end;
IMycHistoryTicker = interface(IMycTicker)
constructor Create(const AStream: IDataStream<T>; const AConsumers: TArray<TConsumer>);
end;
implementation
constructor TMycTradeObject.Create(const ACaption: string; ALog: TMycLogger);
constructor TTicker<T>.Create(const AStream: IDataStream<T>; const AConsumers: TArray<TConsumer>);
begin
inherited Create;
FCaption := ACaption;
FLog := procedure(const Msg: String) begin ALog('[' + FCaption + '] ' + Msg); end;
FStream := AStream;
FConsumers := AConsumers;
var ml: Int64 := 0;
for var consumer in FConsumers do
if consumer.Lookback > ml then
ml := consumer.Lookback;
FProvider := TDataStreamProvider<T>.Create(ml, 100, AStream);
end;
function TMycTradeObject.GetCaption: string;
{ TTicker<T> }
function TTicker<T>.Notify: Boolean;
begin
Result := FCaption;
end;
end.