Unit DataFormats; { This describes what goes across the wire to the unix side. Presumably other programs could get data from other sources, and possibly even different application frameworks, but they will all share this. I used all 64 bit integers to match the destination assumptions. Realtick never gives me 64 bit values, so perhaps I could have used less. But this makes the format somewhat generic and less likely to change in the future. } Interface Type // Null terminated string. This should always be null terminated, // even if we have to truncate the string. This is the same format that // comes from the datafeed. A CSV file on the server will tell it how to // interpret these values for different data feeds. TExchangeCode = Array [1..8] Of Char; TWireL1 = Packed Record CurrentTime : Int64; // time_t, 0 for unknown. BidPrice : Double; BidSize : Int64; // Shares BidExchange : TExchangeCode; AskPrice : Double; AskSize : Int64; // Shares AskExchange : TExchangeCode; // Null terminated string. End; TWireTos = Packed Record CurrentTime : Int64; // time_t, 0 for unknown. Price : Double; Time : Int64; // time_t Size : Int64; Exchange : TExchangeCode; TodaysClose : Double; Volume : Int64; Open, High, Low : Double; FormT, UpdatesLast, NewPrint : Boolean End; TWireHalt = Packed Record CurrentTime : Int64; HaltType : Int64; Reason : Int64; Price : Double; End; Const // These are the command names used to send the data. Note that these names // are tied to the exact formats shown above. If a format changes, then we // would likely have a new command for the new format. That would allow the // listener to support multiple formats, or at least to detect or ignore an // unknown format. WireL1Invalid = 'WireL1Invalid'; WireTosInvalid = 'WireTosInvalid'; WireL1Data = 'WireL1Data'; WireTosData = 'WireTosData'; WireHaltData = 'WireHaltData'; // These each use a single int64, rather than a record. WireImbalanceData = 'WireImbalanceData'; WirePutVolumeData = 'WirePutVolumeData'; WireCallVolumeData = 'WireCallVolumeData'; // These each use a single double, rather than a record. WireNyseBidData = 'WireNyseBidData'; WireNyseAskData = 'WireNyseAskData'; // Limit Data WireLimitType = 'WireLimitType'; WireLimitUp = 'WireLimitUp'; WireLimitDown = 'WireLimitDown'; // Use this field to hold one of the commands listed above. WireCommand = 'command'; // For the items with data, store the data in this field. It would be the // contents of one of the records above, with no encoding. Just make a // string of the appropriate length. WireBody = 'body'; // Use this field to store the symbol name. WireSymbol = 'symbol'; Function AsString(Const Data : TWireL1) : String; Overload; Function AsString(Const Data : TWireTos) : String; Overload; Function AsString(Const Data : TWireHalt) : String; Overload; Procedure StoreString(Var Simple : TExchangeCode; Const Delphi : String); Implementation Uses SysUtils; Function AsString(Const Data : TWireL1) : String; Begin SetString(Result, PChar(@Data), SizeOf(Data)) End; Function AsString(Const Data : TWireTos) : String; Begin SetString(Result, PChar(@Data), SizeOf(Data)) End; Function AsString(Const Data : TWireHalt) : String; Begin SetString(Result, PChar(@Data), SizeOf(Data)) End; Procedure StoreString(Var Simple : TExchangeCode; Const Delphi : String); Begin PInt64(@Simple)^ := 0; If Delphi <> '' Then StrLCopy(@Simple, PChar(Delphi), Pred(SizeOf(Simple))) End; End.