re: "Note that if the 'seconds' part of 'close' (in main's preliminaries) is 'n',
then the 'seconds' part of every exit/entry time will be <= 'n'. A 'close' of
XX:XX:59 may be best. Is this a bug or a feature?"
One implication of this may be that if XX:XX:00 is
specified, then the RandomTime(t0,t1) constructor
will only generate times on the minute, i.e., the
'seconds' part of every generated time will always
be zero. Wouldn't, given XX:00:00, the constructor
always generate times on the hour? I think that is
the case and will test it. If this is happening, it probably
isn't what someone would expect -- if someone
wanted to random-trade the 1st half hour, then
they might reasonably ask for a time from
09:30:00 to 10:00:00, which may only generate
10:00:00. I just tried and believe that this is
happening, and while trying found a bug in the commented-out
code, early in 'main', that trades the day session.
It should read:
Code:
// Trade the day session (MST)
RandomTime open = new RandomTime(3, 30, 0);
RandomTime close = new RandomTime(4, 0, 0);
(It contained 'RandomTime.open' and didn't ask
for a "new" one).
I do see it only trading at 04:00:00. This can be
fixed: in RandomTime(t0,t1),
ask for a 'nextRandomTime', which should
provide a time from 00:00:00 and 23:59:59,
inclusive, repeatedly until it does provide
a time from t0 to t1, inclusive. Shorter periods
may require more trips to 'nextRandomTIme', in
order to find a suitable value, than longer periods require.
As is, it can be
used to trade between [09:30:00 and 10:00:00) by
initializing 'close' with 09:59:59. Is there a better
fix than 'nextRandomTime'?
That's the second problem that using the
'close' values as arguments to 'nextInt' has
created. It was too easy: a no brainer. It may
have been used that way because I was thinking
about running the bot over the full day session,
until XX:XX:59, which would permit every random
second before the close at XX:XX:00 to be generated.