Skip to content

Commit 842c5cf

Browse files
authored
Merge pull request #6 from mgatny/master
Recommend EP206 for sub-millisecond date/time
2 parents 1b6242d + 5f2efd5 commit 842c5cf

File tree

1 file changed

+46
-39
lines changed

1 file changed

+46
-39
lines changed

Encoding_FIX_using_JSON-User_Guide.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PROTOCOL IS ASSUMED BY THE USER.
3434

3535
NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL SHALL HAVE ANY LIABILITY
3636
FOR DAMAGES OF ANY KIND ARISING IN ANY MANNER OUT OF OR IN CONNECTION WITH ANY
37-
USER'S USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT,
37+
USERS USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT,
3838
INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL (INCLUDING, WITHOUT LIMITATION,
3939
LOSS OF DATA, LOSS OF USE, CLAIMS OF THIRD PARTIES OR LOST PROFITS OR REVENUES
4040
OR OTHER ECONOMIC LOSS), WHETHER IN TORT (INCLUDING NEGLIGENCE AND STRICT
@@ -62,10 +62,11 @@ Copyright 2003-2016 FIX Protocol Limited, all rights reserved.
6262

6363
**Document History**
6464

65-
| Revision | Date | Author | Revision Comments |
66-
|----------|------------|-------------------------------|----------------------------------------------|
67-
| 0.1.0 | 2016-04-14 | Don Mendelson | Initial draft. |
68-
| 0.2.0 | 2016-09-12 | Mike Gatny, Connamara Systems | Updated according to Working Group feedback. |
65+
| Revision | Date | Author | Revision Comments |
66+
|----------|------------|-------------------------------|----------------------------------------------------------|
67+
| 0.1.0 | 2016-04-14 | Don Mendelson | Initial draft. |
68+
| 0.2.0 | 2016-09-12 | Mike Gatny, Connamara Systems | Updated according to Working Group feedback. |
69+
| 0.3.0 | 2016-11-04 | Mike Gatny, Connamara Systems | Recommend EP206 for sub-millisecond date/time precision. |
6970

7071
Introduction
7172
============
@@ -116,10 +117,10 @@ JSON is so simple that the standard’s authors foresaw no need for versioning s
116117

117118
- An **array** is an ordered list of values.
118119
- An **object** is a collection of name/value pairs. Names are *strings*.
119-
- A **value** can be an *object, array, number, string,**boolean**,* or *null*.
120+
- A **value** can be an *object*, *array*, *number*, *string*, *boolean*, or *null*.
120121
- **Numbers** are signed. There is no syntactic distinction between integer and floating point values. In practice, most implementations store all numbers as double precision binary floating point.
121122
- **Strings** are Unicode, with a few rules for escaping special values.
122-
- **Booleans** are *true*or*false.*
123+
- **Booleans** are *true* or *false*.
123124
- Arbitrary levels of *object* nesting are allowed.
124125

125126
Standards References
@@ -137,15 +138,18 @@ This user guide provides standardized solutions to the following issues.
137138

138139
### Dates and Times
139140

140-
JSON has no explicit provision for encoding dates or times, although JavaScript
141-
has a Date object. Fortunately, the Date object can extract a date/time in a
142-
string format compatible with an international standard, namely ISO 8601.
141+
JSON has no explicit provision for encoding dates or times. However, most
142+
languages/platforms that support JSON also support conversion of date/time to
143+
and from strings in ISO 8601 format (e.g. the JavaScript **Date** object).
143144

144-
Another potential issue is that the JavaScript Date object only supports
145-
millisecond precision while FIX timestamps sometimes require micro or
146-
nanosecond precision. Given that any timestamps captured on the client side are
147-
limited by PC clock precision, however, millisecond precision should be
148-
sufficient for web applications.
145+
Another potential issue is that particular languages/platforms only support
146+
millisecond precision (e.g. the JavaScript **Date** object), while FIX
147+
timestamps may require microsecond or nanosecond precision. Given that any
148+
timestamps captured on the client side are limited by PC clock precision,
149+
millisecond precision should be sufficient for web applications. When finer
150+
than millisecond precision is required, applications should adhere to the
151+
recommendations of [FIX.5.0 SP2 EP206: Clock Synchronization Data Types
152+
Enhancements](http://www.fixtradingcommunity.org/pg/extensions/extension-pack?ExtensionID=EP206).
149153

150154
### Decimal Representation
151155

@@ -157,12 +161,14 @@ encodings, are unfortunately pointless.
157161

158162
### Enumerations
159163

160-
Enumerations of valid values are needed for codes in FIX fields. Unlike many
161-
other programming languages, JavaScript and JSON have no special syntax for
162-
enumerations. Although it is possible to emulate an enumeration in JavaScript
163-
with an associative array of symbolic names and values, deserialization of a
164-
code in JSON does not automatically associate to its symbolic name, and
165-
serialized strings or numbers are not constrained to valid values.
164+
Enumerations of valid values are needed for codes in FIX fields, but JSON has no special syntax for enumerations.
165+
166+
Languages/platforms that support JSON may also lack support for enumerations
167+
(e.g. JavaScript). Although it may be possible in such cases to emulate an
168+
enumeration with an associative array of symbolic names and values,
169+
deserialization of a code in JSON does not automatically associate to its
170+
symbolic name, and serialized strings or numbers are not constrained to valid
171+
values.
166172

167173
### No tags
168174

@@ -176,11 +182,12 @@ numbers of fields per message.
176182

177183
JSON serialization and deserialization are not controlled by an external
178184
template or schema, only by an object that is being serialized. Each object is
179-
*sui generis*; JavaScript does not have classes that objects must conform to,
180-
as realized by Java, C\# and C++. It does have a prototype feature, but
181-
JavaScript objects are quite malleable. Properties and functions can be added
182-
on the fly. Nevertheless, it would be possible to generate JavaScript objects
183-
corresponding to messages defined by the FIX Repository.
185+
*sui generis*; JSON grew out of JavaScript, which does not have classes that
186+
objects must conform to, as realized by Java, C\# and C++. It does have a
187+
prototype feature, but JavaScript objects are quite malleable. Properties and
188+
functions can be added on the fly. Nevertheless, it is possible to generate
189+
JSON objects corresponding to messages defined by the FIX Repository or FIX
190+
Orchestra.
184191

185192
Constraint
186193
----------
@@ -210,7 +217,7 @@ quantities, etc. Furthermore, most implementations (e.g. JavaScript) store all
210217
JSON numeric values using a binary floating point data type. Using JSON
211218
*string* values to represent FIX protocol numeric types circumvents this issue,
212219
and allows applications to choose the most appropriate data type provided by
213-
their platform (e.g. Java BigDecimal).
220+
their language/platform (e.g. the Java *BigDecimal* type).
214221

215222
Names
216223
-----
@@ -223,8 +230,8 @@ applications to display a human-readable form with little or no logic and
223230
without requiring a data dictionary in the browser. However, for user-defined
224231
fields, the *Tag* number may be used instead of the *Name*.
225232

226-
The field’s *Value*should be used instead of its *SymbolicName* since there are
227-
many cases (e.g. bonds, complex options) where the *SymbolicName*means
233+
The field’s *Value* should be used instead of its *SymbolicName* since there
234+
are many cases (e.g. bonds, complex options) where the *SymbolicName* means
228235
something other than how it is being used.
229236

230237
Field Encoding
@@ -233,7 +240,7 @@ Field Encoding
233240
Fields are encoded in accordance with the JSON standard as name/value pairs.
234241
Values must be serialized as JSON *strings*.
235242

236-
Example of FIX field encoded as a JSON name/value pair:
243+
Example of a FIX field encoded as a JSON name/value pair:
237244

238245
| FIX tag=value Encoding | JSON Encoding |
239246
|------------------------|-------------------|
@@ -251,14 +258,14 @@ Message Structure
251258
Field Presence
252259
--------------
253260

254-
Although JSON does have a special value for null, it need not be used for a
261+
Although JSON does have a special value for *null*, it need not be used for a
255262
non-populated optional FIX field. Like FIX *tag=value* encoding, optional
256263
fields that are not populated are simply not serialized on the wire.
257264

258265
Field Order
259266
-----------
260267

261-
Like FIX *tag=value* encoding, order of field within a message or repeating
268+
Like FIX *tag=value* encoding, order of fields within a message or repeating
262269
group entry is not significant. All fields are accessed by name.
263270

264271
Message Framing
@@ -272,7 +279,7 @@ Since this encoding is designed for use with web protocols, message framing is
272279
generally handled by the session layer protocol, e.g. HTTP or websockets. In
273280
these cases, no additional framing protocol is needed.
274281

275-
For cases where additional a framing protocol *is* needed, applications may use
282+
For cases where an additional framing protocol *is* needed, applications may use
276283
*FIX Simple Open Framing Header* (SOFH).
277284

278285
Header, Body, and Trailer
@@ -289,12 +296,12 @@ Every JSON message must have top-level fields named “Header”, “Body”, an
289296
}
290297
```
291298

292-
This structure serves the goal of not discarding information that is useful
299+
This structure serves the goal of *not* discarding information that is useful
293300
when converting to/from other FIX encodings.
294301

295302
JSON encoding does not include a “CheckSum” field since it is unlikely to be
296-
useful at best, and incorrect at worst (e.g. if copied over from another FIX
297-
encoding).
303+
useful at best, and likely to be incorrect at worst (e.g. if copied over from
304+
another FIX encoding).
298305

299306
Message Type
300307
------------
@@ -323,10 +330,10 @@ entry is its own JSON object. Because some of the fields may be optional, not
323330
all entries are required to contain the same fields.
324331

325332
The count of entries is implicit to the array structure. There is no explicit
326-
NumInGroup field in the JSON encoding.
333+
*NumInGroup* field in the JSON encoding.
327334

328-
The name of a repeating group is the name of the associated NumInGroup field
329-
name as it appears in the FIX repository.
335+
The name of a repeating group is the name of the associated *NumInGroup* field
336+
name as it appears in the FIX Repository.
330337

331338
Example of a “NoMDEntries” group with two entries:
332339

0 commit comments

Comments
 (0)