Unit SimpleMarketData; Interface Const MinVolatility = 0.001; // Could use a better number here, but this will at least avoid the divided by 0 problem. Function SymbolIsFuture(Symbol : String) : Boolean; Function SymbolIsIndex(Symbol : String) : Boolean; Function LongExchangeName(Const ShortExchangeName : String) : String; // AAIu.CAT is a symbol in TAL. This causes problems for us because we // capatalize the letters everywhere. So we quote this as AAI*U.CAT when // we display it to the user. And We convert it back to talk to TAL. // Internally we use the quoted form almost everywhere. Function StarQuote(TalFormat : String) : String; Function StarUnquote(ExternalFormat : String) : String; Implementation Function SymbolIsFuture(Symbol : String) : Boolean; Begin Result := (Length(Symbol)>0) And (Symbol[1] = '/'); // ((Length(Symbol)=5) And (Symbol[3] = ' ')) // eSignal End; Function SymbolIsIndex(Symbol : String) : Boolean; Begin Result := (Length(Symbol)>0) And (Symbol[1] = '$') End; Function LongExchangeName(Const ShortExchangeName : String) : String; Begin If ShortExchangeName = 'AMEX' Then Result := 'American' Else If ShortExchangeName = 'NASD' Then Result := 'NASDAQ' Else If ShortExchangeName = 'NYSE' Then Result := 'New York' Else If ShortExchangeName = 'CBOE' Then Result := 'Chicago Board Options' Else If ShortExchangeName = 'LSE' Then Result := 'London' Else Result := ShortExchangeName End; Function StarQuote(TalFormat : String) : String; Var FromIndex, ToIndex : Integer; Current : Char; Begin SetLength(Result, Length(TalFormat)*2); ToIndex := 1; For FromIndex := 1 To Length(TalFormat) Do Begin Current := TalFormat[FromIndex]; If Current In ['a'..'z'] Then Begin Result[ToIndex] := '*'; Inc(ToIndex); Current := Char(Ord(Current) - 32) End; Result[ToIndex] := Current; Inc(ToIndex) End; SetLength(Result, Pred(ToIndex)); //WriteLn('"' + TalFormat + '" => "' + Result + '"') End; Function StarUnquote(ExternalFormat : String) : String; Var FromIndex, ToIndex : Integer; NextIsLowerCase : Boolean; Current : Char; Begin SetLength(Result, Length(ExternalFormat)); ToIndex := 1; NextIsLowerCase := False; For FromIndex := 1 To Length(ExternalFormat) Do Begin Current := ExternalFormat[FromIndex]; If Current = '*' Then NextIsLowerCase := True Else Begin If NextIsLowerCase And (Current In ['A' .. 'Z']) Then Current := Char(Ord(Current) + 32); Result[ToIndex] := Current; Inc(ToIndex); NextIsLowerCase := False End End; SetLength(Result, Pred(ToIndex)) End; End.