Greetings,
Is there a way to get the trade time on the onTrade event?
When is the onTimestamp called? I am trying implement both interval and time stamp based resets for an indicator. The interval based works fine, but the onTimestamp has a funny behaviour:
calling:
public void onTimestamp(long t) {
LocalDateTime ts = LocalDateTime.ofInstant(Instant.ofEpochSecond(t / 1_000_000_000L), TimeZone.getDefault().toZoneId());
the timestamp during a replay shows the real time and not the replay time.
Could you please let me know how I could grab the time of the trade or grab a time stamp during the replay to be able to reset based on timestamps keeping in mind that the onInterval is not available?
Many thanks in advance,
Kind Regards
OnTimestamp and time of a trade
-
- Posts: 548
- Joined: Mon Jul 09, 2018 11:18 am
- Has thanked: 25 times
- Been thanked: 85 times
Re: OnTimestamp and time of a trade
Hi zcsoka,
onTimestamp is called any time a new event comes (depth, trade, order, whatever).
To catch an event time just store the t value and read it when you need to.
the timestamp during a replay shows the real time and not the replay time I am not sure I get it right, could you pls provide some more details. onTimestamp method must give timestamps of events happening on the screen. For example, I have just replayed a January feed and what I have in my console is:
Code example:
onTimestamp is called any time a new event comes (depth, trade, order, whatever).
To catch an event time just store the t value and read it when you need to.
the timestamp during a replay shows the real time and not the replay time I am not sure I get it right, could you pls provide some more details. onTimestamp method must give timestamps of events happening on the screen. For example, I have just replayed a January feed and what I have in my console is:
Code: Select all
20200312 09:49:52.602(UTC) INFO: Time is 2020-01-02T06:52:15
20200312 09:49:54.889(UTC) INFO: Time is 2020-01-02T06:52:19
20200312 09:49:54.982(UTC) INFO: Time is 2020-01-02T06:52:20
Code: Select all
public class ReplayTimeListener implements CustomModule, TradeDataListener, TimeListener {
private long t;
@Override
public void initialize(String alias, InstrumentInfo info, Api api, InitialState initialState) {
}
@Override
public void stop() {
}
@Override
public void onTrade(double price, int size, TradeInfo tradeInfo) {
LocalDateTime ts = LocalDateTime.ofInstant(Instant.ofEpochSecond(t / 1_000_000_000L), TimeZone.getDefault().toZoneId());
Log.info("Time is " + ts.toString());
}
@Override
public void onTimestamp(long t) {
this.t = t;
}
}
Re: OnTimestamp and time of a trade
Hi AndreyR,
Many thanks for your answer, sorry for the late reaction, I missed the notification. I found out, that on the Mac the replay timestamps are not correct, independent of the location of the replay the time stamp always ends with the las time stamp of the replay file. For example: Replay file's last time stamp is 17:21:01. I play my file till 07:21:00. I add my indicator. The indicator catches up and drawn till 07:21, but the printed time stamp is 17:21:01.
I will check it on my Windows machine as well.
Kind Regards,
Zoltan
Many thanks for your answer, sorry for the late reaction, I missed the notification. I found out, that on the Mac the replay timestamps are not correct, independent of the location of the replay the time stamp always ends with the las time stamp of the replay file. For example: Replay file's last time stamp is 17:21:01. I play my file till 07:21:00. I add my indicator. The indicator catches up and drawn till 07:21, but the printed time stamp is 17:21:01.
I will check it on my Windows machine as well.
Kind Regards,
Zoltan
-
- Site Admin
- Posts: 278
- Joined: Mon Jun 11, 2018 11:44 am
- Has thanked: 2 times
- Been thanked: 31 times
Re: OnTimestamp and time of a trade
Which interfaces are you implementing? Sounds like you have implemented HistoricalDataListener but not HistoricalModeListener, so Bookmap tries to take shortcut and precompute your indicator on all the data. But maybe I misunderstood the problem. Would it be possible to post a short code example showing the issue?