Investment Studio > Views > Downloads > Downloader > Format strings
A format string describes the text representation of a quote record. It consists of a sequence of field symbols, wildcards, status modifiers, literal characters and an optional trailing comment. All but literal characters are case-insensitive.
| Field symbols are used to describe the position and content of actual record fields. If the same field symbol occurs more than once in a format string used to parse some text, the record field's value is determined by the last match (reading from left to right). | |
| Wildcards match any actual content and are a way to say "anything goes in this position; just ignore it, whatever it happens to be". | |
| Status modifiers don't match text; instead, they modify the parser's interpretation of all subsequent text (reading from left to right). | |
| Literal characters must be matched exactly, character by character, for a string to be considered a valid record representation. | |
| Trailing comments start with the character "#". This character is simply ignored, along with anything following it (reading from left to right), all the way to the end of the format string (to match "#" as a literal character, use the escape sequence "\#"). |
The following field symbols are available:
| D | Day in month. Any integer in the range [1, 31]. Examples: "1", "9", "10", "31". |
| DD | Two-digit day in month. Any integer in the range [1, 31], left-padded with a zero where necessary to have two digits. Examples: "01", "09", "10", "31"s. |
| M | Month in year. Any integer in the range [1, 12]. Examples: "1", "6", "12". |
| MM | Two-digit month in year. Any integer in the range [1, 12], left-padded with a zero where necessary to have two digits. Examples: "01", "09", "10", "12". |
| MMM | English three-letter month abbreviations ("Jan", "Feb", "Mar"... "Dec"). Not case sensitive (i.e. "Jan", "JAN", "jan", "jAn", "jaN" are all equivalent). |
| MMMx x Î [0, 9] |
Custom month names, as defined in the
Download view's Month names dialog. The digit in the format string
(x) identifies the month set. For instance, if you have defined "März" to be month number 3 in month set number 7, the format string "MMM7" will parse the string "März" as month number 3. |
| Y | Year. Any integer in the range [1, 9999]. Examples: "1", "1999", "5476", "9999". |
| YY | Two-digit year. Any integer in the range
[0, 99], left-padded with a zero where necessary to have
two digits. Examples: "01", "09",
"50", "99". Not recommended. Use xxYY or xxYYzz unless you have a good reason not to. |
| YYY | Three-digit year. Any integer in the range [0, 999], left-padded with zeros where necessary to have three digits. Examples: "001", "099", "580", "999". |
| YYYY | Four-digit year. Any integer in the range [0, 9999], left-padded with zeros where necessary to have four digits. Examples: "0001", "0990", "5820", "9999". |
| xxYY x Î [0, 9] |
Complemented two-digit year. The two
leading digits (xx) in the format string are the century.
Matches any integer in the range [0, 99], left-padded with a zero where necessary to have two digits. For instance, the format string "19YY" will parse "00" as 1900, "09" as 1909, "99" as 1999. |
| xxYYzz x, z Î [0, 9] |
Capped complemented two-digit year. The
two leading digits (xx) in the format string are the high
century. The two trailing digits (zz) in the format
string are the max year in the high century (the
"cap"). Matches any integer in the range [0, 99], left-padded with a zero where necessary to have two digits. If the matched integer <= zz, the high century (xx) is used; otherwise, the previous century (xx - 1) is used. For instance, the format string "20YY50" will parse "00", "01", "02"... "50" as 2000, 2001, 2002... 2050; but it will parse "51", "52", "53"... "99" as 1951, 1952, 1953... 1999. |
| O | Day's opening price. Any real number on standard format, i.e. an optional leading sign ("+" or "-") followed by a number containing an optional decimal separator (see Sx). Examples: "10", "10.5", "+10.5", "-10.5". |
| H | Day's highest price. Any real number on standard format (see O). |
| L | Day's lowest price. Any real number on standard format (see O). |
| C | Day's closing price. Any real number on standard format (see O). |
| V | Day's volume. Any real number on standard format (see O). |
| I | Day's open interest. Any real number on standard format (see O). |
| B | Day's bid price. Any real number on standard format (see O). |
| A | Day's ask price. Any real number on standard format (see O). |
| P | Day's bid size. Any real number on standard format (see O). |
| Q | Day's ask size. Any real number on standard format (see O). |
| ? | Matches a single occurrence of any character. |
| * | Matches any and all characters up to (but not including) the first occurrence of the next wildcard or literal character (reading from left to right). For instance, use "*," to skip all characters in front of the next comma. |
| " " (blank) |
A plain space character (no quotes!). Matches one or more blank spaces. |
Currently, the only status modifier is
Literal characters are anything not listed above, plus
Examples
In the format string
d-mmm-20yy50,o,h,l,c,v#This is a trailing comment
the red parts are symbol fields, the black parts are literal characters, the gray part is a trailing comment.
Using this format string, the data string "1-Jul-02,9239.25,9381.37,9059.88,9109.79,14255000" would be interpreted as "on July 1, 2002, the open was 9239.25, the high was 9381.37, the low was 9059.88, the close was 9109.79 and the volume was 14255000". On the other hand, if the date part of the data string was changed to "1-Jul-51", the year would be interpreted as 1951 (see xxYYzz).
Using the format string
yyyy/mm/dd,c#Japanese style date format example
the data string "2002/07/01,9109.79" would be interpreted as "on July 1, 2002, the close was 9109.79". If the date and the price quote were separated using a tab character instead, and if the decimal separator was a comma instead of a period, the appropriate format string would be
yyyy/mm/ddTS,c#Tab-delimited fields, comma for decimal character
where the green part is the Sx status modifier.