PureBytes Links
Trading Reference Links
|
This message concerns TradeStation 4 build 26.
Some or all of the issues addressed may have always been problems
in TS4. In other words, I do not know whether these are Y2K related
bugs in TS which have always existed or which were introduced with
builds 23, 24, 25, and/or 26.
These issues may be problems in TS2000 too. I have not upgraded,
so I cannot test it, but it seems unlikely that these parts of
your base code would have undergone any significant modifications.
TS requires inconsistent year information in its various date
related functions. For example, the new EL function ELdate
requires a 4 digit year. The DaysToExpiration function does
not work with a 4 digit year. This inconsistency is a problem
for users. ELdate could be easily extended to cover both cases.
Documentation for the DateToJulian function says:
DateToJulian
Returns the Julian date of input value. The input value must
be a valid date (January 1, 1900 to February 28, 2100). The
value returned will be a number from 1 to 73049.
Category: Date & Time
Function: DateToJulian(num)
Example: DateToJulian(860617) returns 31578
Ignoring the fact that this serialized date is quite distinct from
the true Julian date, there are errors galore.
a. It returns 2 for Jan 1, 1900, and its return values are 1 day
too large for all other days for which I have tested it which
are relatively near to the year 1999.
b. It returns 7573 for Feb 28, 2100. 73049 would correspond to
Feb 28, 2100 if day 1 were Mar 1, 1900. If day 1 was Jan 1, 1900
as claimed, then it should actually return 73108, or with the
"one day off bug" for consistency it should be 73109.
c. The example is wrong. DateToJulian(860617) returns 31580.
The correct answer is 31579. Neither matches the documentation.
Documentation for the JulianToDate function says:
JulianToDate
Returns the date in YYMMDD format of the input Julian date.
This input value may range from 1 (January 1, 1900) through
73049 (February 28, 2100).
Category: Date & Time
Function: JulianToDate(num)
Example: JulianToDate(31578) returns 860617
Again ignoring the misnomer, there are errors.
a. Despite the documentation, to be consistent with DateToJulian,
given a "julian" day of 2, it should return Jan 1, 1900. Instead
it returns 1790607, or as a string interpreted by ELDateToString
06/07/2079.
b. With the input of 61 which should be Mar 2, 1900 (but corresponds
to Mar 1, 1900 according to DateToJulian), it returns 1790805
or in a string 08/05/2079.
c. Needless to say, the example in the documentation is wrong too.
Now to the questions:
1. What are the actual high and low date limits of the validity of
the routines DateToJulian and JulianToDate.
2. Within the limits of validity which you will report in answering
the first question, is the pseudo-Julian date always off by
one day so that your users can depend on date differences always
being correct?
3. Are there any problems caused in other areas of TradeStation
by these functions not behaving as documented, for example in
data storage, date interchange, etc.?
4. Were these bugs corrected in TS2000?
These bugs can be reproduced in many ways. One is the EL code
given below for your convenience. Note: there may be some
wrapping of long lines in the code by my email client application.
Rod Grisham
TS4 block 12902
{**************************************
Date conversion tests
***************************************}
Inputs: cday(1), cmon(12), cyr(1999);
Vars: String1("");
Vars: orjd(0), orcd(0), wd(0), orcurd(0), yroff(0), d2x(0);
If lastbaronchart then begin
Print( File("c:\temp\dbg.txt"), " " );
Print( File("c:\temp\dbg.txt"), "Date Conversion Tests" );
orcd = ELdate( cmon, cday, cyr );
orjd = DateToJulian( orcd );
Print( File("c:\temp\dbg.txt"), "Input day, month, and year = ", cday,
cmon, cyr );
Print( File("c:\temp\dbg.txt"), "OR Calendar Day = ", orcd );
Print( File("c:\temp\dbg.txt"), "OR Julian Day = ", orjd );
wd = DayOfWeek( orcd );
Print( File("c:\temp\dbg.txt"), "Day of week = ", wd );
Print( File("c:\temp\dbg.txt"), "Converting back" );
orcd = JulianToDate( orjd );
Print( File("c:\temp\dbg.txt"), "orC day from orJ day = ", orcd );
String1 = ELDateToString( orcd );
Print( File("c:\temp\dbg.txt"), "OR string version of the date = ", String1
);
orcurd = CurrentDate;
Print( File("c:\temp\dbg.txt"), "current date = ", orcurd );
If orcd > orcurd then begin
yroff = cyr - 1900;
d2x = DaysToExpiration( cmon, yroff );
Print( File("c:\temp\dbg.txt"), "Days to expiration from today = ", d2x );
Plot1( d2x, "Days Left" );
End;
End;
|