QuickFIX - set StartTime\EndTime - quickfix

QuickFIX has a configuration file where you set StartTime and EndTime. Unfortunately AFAIK QuickFIX only supports UTC for this configuration, whereas exchanges are often timezone dependent. This means that you need to remember to update this configuration file every time the clock changes.
Is there a way to set the StartTime \ EndTime parameters programatically instead of through the configuration file? That way you could adjust the timeset the correct values programatically.

There is a way to set this. You can can set a timezone as follows:
TimeZone=America/New_York
see the configuration guide.
It is weird that it is not in the quickfix configuration guide and it is present in the quickfixJ guide.

in our production environment we use always UTC times.
In the QuickFIX config file add for every counterparty the following line:
UseLocalTime=N
Please read the documentation here:
http://www.quickfixengine.org/quickfix/doc/html/configuration.html#Session

as per quickfix docs you should add
set UseLocalTime=Y
Indicates StartTime and EndTime are expressed in localtime instead of
UTC. Times in messages will still be set to UTC as this is required by
the FIX specifications.

We had an error
System.ArgumentException: Only UTC time is supported
Parameter name: oldtime
at QuickFix.SessionSchedule.IsNewSession(DateTime oldtime_utc, DateTime testtime_utc)
at QuickFix.Session.get_IsNewSession()
and the only way to fix it was to delete the store directory. Presumably the session timestamp like this

Related

Cloud Function writing wrong time on firestore

When I write a Timestamp on Firestore it shows 6.00PM on database though I have not defined any time in the Date object.
My Approach to get Timestamp from date :
let reservationDate = new Date(year,month,dayOfMonth);
let bookedRoomData = {
....
...
reservationDate: admin.firestore.Timestamp.fromDate(reservationDate),
...
};
What is the reason behind showing 6.00PM instead of 12.00AM ?
What should be done to fix this?
Screenshot of database is given bellow -
Since you tagged this google-cloud-functions, I'm assuming that your code is running in Cloud Functions.
When you create a new Date object on any machine, it uses the local machine's sense of timezone. So you're making a date at midnight in whatever timezone has been assigned to your Cloud Functions instance. It's not the timezone where you're computer's clock is set.
When you see a timestamp in the console, it's always going to appear on your computer's clock's configured timezone. So, your computer is 6 hours behind whatever is being used by Cloud Functions.
If you want a specific time, you should make sure your Date is configured that way. Consider using a library such as momentjs to create dates according to timezones of your interest. Bear in mind that Timestamp objects do not encode a timezone. They just render in the console according to your local timezone.

WHy is my FIX session Starting and Ending UTC insted of Local?

I am using quickfix .net engine.
StartTime=17:40:00
EndTime=17:25:00
I am running this on a New York server and clock on desktop shows NY local time.
However, the FIX session starts and ends at UTC time. My understanding of fix config was that the times were always Local.
Why might this be happening?
You might need to read the config section properly, once more.
StartTime, EndTime - time in the format of HH:MM:SS, time is represented in UTC
To use local time in the FIX config, you need to set in the config
UseLocalTime=Y
It is N by default. But an important point
Times in messages will still be set to UTC as this is required by the FIX specifications.

CQ5 timezone issue

I am facing an issue with setting time on page properties on cq:Page. The time being set into the JCR is getting converted to the timezone that is set in author’s machine. For example: time being set when author is in India is saved as +5:30 while in NY it is being set with -4:00 offset. Is there any way this can be fixed ?
Thanks !
I don't think you want to change this, unless I misunderstood the issue. Time is linear, so at any given point in time, there are as many possible ways to express the time as there are valid time zones. Anyone who views that page information through the application (not directly viewing the JCR) should see that timestamp converted to their local system time.

GWT Date Handing... have client respect server's timezone

I've read many a post here re: GWT date handling.
One in particular that struck a cord with me was this one
Sending a date and timezone from GAE server to GWT client
Anyhow, there's a need on a project I'm working on to be able to display days, hours, minute intervals as labels in a grid. My team has adopted an approach where all date/time instances are passed the client from the server in ISO8601 String format. The server time zone is to be respected by the client. The biz use case is that all date/time instances are in "market time", so that any browser that visits the app will see and work with dates in the "market time" timezone which happens to be GMT-05:00 (if Daylight Savings in effect) or GMT-06:00 (if Standard Time in effect).
I have posted some source on Github, here:
https://github.com/fastnsilver/gwt-datehandling-example
Particularly...
https://github.com/fastnsilver/gwt-datehandling-example/blob/master/src/main/java/me/fns/gwt/datehandling/client/util/CSTimeUtil.java
and the GWTTestCase
https://github.com/fastnsilver/gwt-datehandling-example/blob/master/src/test/java/me/fns/gwt/datehandling/client/util/CSTimeUtilTestGwt.java
in the hopes that someone can stare at the utility (and test) we're employing for date handling and help us see what we're not seeing.
EDIT
The basic problem is that CSTimeUtil#hoursInDay(Date) is not being calculated correctly in Production mode for "transition days" This method is used by other methods (like CSTimeUtil#dateToHour(Date) and CSTimeUtil#labelsForDay(Date)).
I have deployed our application with the current implementation of CSTimeUtil and it appears to work, but not quite. I'm really confused by alternate test results when e.g., mvn gwt:test is run in GWT Mode or Production Mode on Windows where the OS timezone is set to various timezones other than U.S. GMT-05:00 or GMT-06:00.
Based on some hints from Andrei and some serious blood, sweat and tears, I figured this out on my own. I have updated the code in Github, so if you're curious please go have a look there.
The basics:
Make sure all Strings are ISO8601 (no millis) compliant when sent from server to client and vice versa
Use DateTimeFormat.getFormat("yyyy-MM-ddTHH:mm:ss.SZZZZ") to format and parse dates
Retreive GMT-prefixed time zone info from java.util.Date in "Market time" using DateTimeFormat(Date, TimeZone), where TimeZone param is set as TimeZone.createTimeZone(TZ_CONSTANTS_INSTANCE.americaChicago()) and time zone String retrieved by TimeZone.getISOTimeZoneString(Date)
Generating days, see generateDay(Date, int) or hours generateHour(Date, int), from a source date had to take into consideration that an increment or decrement coudl trigger a change in time zone offset if occurring on a "transition day".
If you time zone is fixed, why would you use a string to represent date/time? You can send a standard Java Date object to the client. If you want, you can even store all dates and times as Longs and pass Longs only. You also send the GWT's TimeZone Json string for your time zone (once per session). You can find it in the GWT - there is a file with strings for all time zones.
On a client you use DateTimeFormat with many predefined formats to display whatever you need: full date, month and date, date and time, etc. Just remember to create TimeZone object from this Json string and use it in DateTimeFormat.getFormat(...).format(Date, TimeZone).
With this approach you don't have to worry about DST changes (they are encoded in that Json string) and locales. You only pass simple Date or Long objects.

wrong timezone when loading joda Instant field via JPA

In my Play application I have a model with a created field of type Instant. It's populated using a #PrePersist hook which just sets it to a new Instant(). The default timezone is correctly detected as US/Chicago, and when persisted to mysql it appears in the same timezone (in a datetime field).
However, when the object is read back from the database and the time is displayed, it's shown in UTC rather than local time. I'm currently displaying it using
${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.created)}
Being new to Joda and fairly new with JPA, I'm not sure if this is a joda problem, a JPA problem, if I should be using a different Joda type, a different mysql type, or if I'm going about this completely wrong. Can someone point me in the right direction?
According to the API UTC seems to be the reference timezone. You can always change that on the DateTimeFormat itself with the withZone(DateTimeZone) method. The following code outputs the date in America/Chicago which seems to be the right timezone in joda-zime:
${org.joda.time.format.DateTimeFormat.forStyle("SS").withZone(org.joda.time.DateTimeZone.forID("America/Chicago")).printTo(out, object.created)}
Following the user guide you can also set the default timezone for joda with DateTimeZone.setDefault(DateTimeZone.forID("America/Chicago")); but I always thought that specifing the default timezone with an VM argument works too and should be the better option.