¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: reqCurrentTime


 

Here is my own answer.?

I first created a new CurrentTimeMessage Class to handle this type of message:
using IBApi;
?
namespace IBSampleApp.messages
{
? ? class CurrentTimeMessage : MarketDataMessage
? ? {
? ? ? ? public CurrentTimeMessage(long t): base(t)
? ? ? ? {
? ? ? ? ? ? CurrentTime = t;
? ? ? ? }
? ? ? ? public long CurrentTime { get; set; }
? ? }
}
And modified the abstract class MarketDataMessage with a new constructor with one parameter only.
? ? ? ? public MarketDataMessage(long t)
? ? ? ? {
? ? ? ? ? ? time = t;
? ? ? ? }
In the Dialog constructor:
? ? ? ? ? ? //ibClient.CurrentTime += time => AddTextToBox("Current Time: " + Util.UnixSecondsToString(time, "yyyy MM dd HH:mm:ss zzz") + "\n");
? ? ? ? ? ? ibClient.CurrentTime += IbClient_CurrentTime;
Along with a specific handler:
? ? ? ? void IbClient_CurrentTime(CurrentTimeMessage msg)
? ? ? ? {
? ? ? ? ? ? AddTextToBox("Current Time: " + Util.UnixSecondsToString(msg.CurrentTime, "yyyy MM dd HH:mm:ss zzz") + "\n");
? ? ? ? }
This can be replicated for TickString, TickGeneric etc.
Hope this can help other less experienced C# API programmers out there.

Join [email protected] to automatically receive all group messages.