unit Myc.Trade.DataPoint; interface uses System.SysUtils; type IDataPoint = interface ['{6A52697A-2868-42A9-982D-993542B7B360}'] function GetData: T; function GetTime: TDateTime; function GetVolume: Double; property Time: TDateTime read GetTime; property Volume: Double read GetVolume; property Data: T read GetData; end; ITick = interface ['{B342223B-D299-4A1C-82F3-569F54417A66}'] function GetAsk: Double; function GetBid: Double; property Ask: Double read GetAsk; property Bid: Double read GetBid; end; IOHLC = interface ['{05374E3C-731B-44FA-A23E-051F1461B78D}'] function GetOpen: Double; function GetHigh: Double; function GetLow: Double; function GetClose: Double; property Open: Double read GetOpen; property High: Double read GetHigh; property Low: Double read GetLow; property Close: Double read GetClose; end; // Abstract base class for all data points. TDataPoint = class abstract(TInterfacedObject, IDataPoint) protected fTime: TDateTime; fVolume: Double; FData: T; function GetTime: TDateTime; function GetVolume: Double; function GetData: T; public constructor Create(Time: TDateTime; Volume: Double; const AData: T); end; TTick = class(TInterfacedObject, ITick) private fAsk: Double; fBid: Double; function GetAsk: Double; function GetBid: Double; public constructor Create(Ask: Double; Bid: Double); end; TOHLC = class(TInterfacedObject, IOHLC) private fOpen: Double; fHigh: Double; fLow: Double; fClose: Double; function GetClose: Double; function GetHigh: Double; function GetLow: Double; function GetOpen: Double; public constructor Create(Open, High, Low, Close: Double); end; implementation { TDataPoint } constructor TDataPoint.Create(Time: TDateTime; Volume: Double; const AData: T); begin fTime := Time; fVolume := Volume; FData := AData; end; function TDataPoint.GetData: T; begin Result := FData; end; function TDataPoint.GetTime: TDateTime; begin result := fTime; end; function TDataPoint.GetVolume: Double; begin result := fVolume; end; { TTick } constructor TTick.Create(Ask: Double; Bid: Double); begin inherited Create; fAsk := Ask; fBid := Bid; end; function TTick.GetAsk: Double; begin result := fAsk; end; function TTick.GetBid: Double; begin result := fBid; end; { TOHLC } constructor TOHLC.Create(Open, High, Low, Close: Double); begin inherited Create; fOpen := Open; fHigh := High; fLow := Low; fClose := Close; end; function TOHLC.GetClose: Double; begin result := fClose; end; function TOHLC.GetHigh: Double; begin result := fHigh; end; function TOHLC.GetLow: Double; begin result := fLow; end; function TOHLC.GetOpen: Double; begin result := fOpen; end; end.