Skip to content

Commit 346aa4d

Browse files
BryanBryan
authored andcommitted
Update documentation
1 parent a49ee41 commit 346aa4d

File tree

4 files changed

+197
-19
lines changed

4 files changed

+197
-19
lines changed

docs/_coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Barchart Market Data SDK <small>JavaScript 4.0.25</small>
1+
# Barchart Market Data SDK <small>JavaScript 4.1.0</small>
22

33
> Inject real-time market data into your JavaScript applications
44

docs/content/sdk/lib-utilities-data.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,180 @@
11
## Contents {docsify-ignore}
22

3+
* [UnitCode](#UnitCode)
4+
35
* [getTimezones()](#getTimezones)
46

57
* [guessTimezone()](#guessTimezone)
68

9+
## UnitCode :id=unitcode
10+
**Kind**: global class
11+
**Extends**: <code>Enum</code>
12+
**Access**: public
13+
**Import**: @barchart/marketdata-api-js/lib/utilities/data/UnitCode
14+
**File**: /lib/utilities/data/UnitCode.js
15+
>Describes how an instrument's price is formatted. In most cases, unit codes are stored as a
16+
single character; however, this enumeration adds additional information. There are fourteen
17+
distinct unit codes.
18+
19+
20+
* [UnitCode](#UnitCode) ⇐ <code>Enum</code>
21+
* _instance_
22+
* [.baseCode](#UnitCodebaseCode) ⇒ <code>Number</code>
23+
* [.unitCode](#UnitCodeunitCode) ⇒ <code>String</code>
24+
* [.decimalDigits](#UnitCodedecimalDigits) ⇒ <code>Number</code>
25+
* [.supportsFractions](#UnitCodesupportsFractions) ⇒ <code>Boolean</code>
26+
* [.fractionFactor](#UnitCodefractionFactor) ⇒ <code>Number</code> \| <code>undefined</code>
27+
* [.fractionDigits](#UnitCodefractionDigits) ⇒ <code>Number</code> \| <code>undefined</code>
28+
* [.fractionFactorSpecial](#UnitCodefractionFactorSpecial) ⇒ <code>Number</code> \| <code>undefined</code>
29+
* [.fractionDigitsSpecial](#UnitCodefractionDigitsSpecial) ⇒ <code>Number</code> \| <code>undefined</code>
30+
* [.getFractionFactor([special])](#UnitCodegetFractionFactor) ⇒ <code>Number</code> \| <code>undefined</code>
31+
* [.getFractionDigits([special])](#UnitCodegetFractionDigits) ⇒ <code>Number</code> \| <code>undefined</code>
32+
* _static_
33+
* [.parse(code)](#UnitCodeparse) ⇒ <code>UnitCode</code> \| <code>null</code>
34+
* [.fromBaseCode(code)](#UnitCodefromBaseCode) ⇒ <code>UnitCode</code> \| <code>null</code>
35+
36+
37+
* * *
38+
39+
### unitCode.baseCode :id=unitcodebasecode
40+
**Kind**: instance property of <code>UnitCode</code>
41+
**Returns**: <code>Number</code>
42+
**Access**: public
43+
>The numeric counterpart of a "unit" code.
44+
45+
46+
* * *
47+
48+
### unitCode.unitCode :id=unitcodeunitcode
49+
**Kind**: instance property of <code>UnitCode</code>
50+
**Returns**: <code>String</code>
51+
**Access**: public
52+
>The single character "unit" code.
53+
54+
55+
* * *
56+
57+
### unitCode.decimalDigits :id=unitcodedecimaldigits
58+
**Kind**: instance property of <code>UnitCode</code>
59+
**Returns**: <code>Number</code>
60+
**Access**: public
61+
>When formatting in decimal mode, the number of digits to show after the
62+
decimal point.
63+
64+
65+
* * *
66+
67+
### unitCode.supportsFractions :id=unitcodesupportsfractions
68+
**Kind**: instance property of <code>UnitCode</code>
69+
**Returns**: <code>Boolean</code>
70+
**Access**: public
71+
>Indicates if formatting can use the alternative to decimal notation -- that
72+
is, fractional notation.
73+
74+
75+
* * *
76+
77+
### unitCode.fractionFactor :id=unitcodefractionfactor
78+
**Kind**: instance property of <code>UnitCode</code>
79+
**Returns**: <code>Number</code> \| <code>undefined</code>
80+
**Access**: public
81+
>When formatting with fractional notation (instead of decimal notation), multiply the
82+
decimal part of the value by this factor to get the fractional (i.e. numerator) value.
83+
In other words, this factor is the denominator.
84+
85+
For example, the value 9.5 will be formatted as "9-4" with a fractional factor of eight.
86+
This is because 8 * 0.5 = 4. In other words, the price is quoted in eighths and 0.5 is
87+
four eighths. Using the same logic, the value of 9.75 will be formatted as "9-6" with
88+
a fractional factor of eight.
89+
90+
91+
* * *
92+
93+
### unitCode.fractionDigits :id=unitcodefractiondigits
94+
**Kind**: instance property of <code>UnitCode</code>
95+
**Returns**: <code>Number</code> \| <code>undefined</code>
96+
**Access**: public
97+
>In fractional notation, the number of digits to which appear after the fraction separator.
98+
For example, two digits are used in "9-01" and "9-11" (where a dash is the fraction
99+
separator).
100+
101+
102+
* * *
103+
104+
### unitCode.fractionFactorSpecial :id=unitcodefractionfactorspecial
105+
**Kind**: instance property of <code>UnitCode</code>
106+
**Returns**: <code>Number</code> \| <code>undefined</code>
107+
**Access**: public
108+
>Same as [fractionFactor](#UnitCodefractionFactor) for "special" fractions.
109+
110+
111+
* * *
112+
113+
### unitCode.fractionDigitsSpecial :id=unitcodefractiondigitsspecial
114+
**Kind**: instance property of <code>UnitCode</code>
115+
**Returns**: <code>Number</code> \| <code>undefined</code>
116+
**Access**: public
117+
>Same as [fractionDigits](#UnitCodefractionDigits) for "special" fractions.
118+
119+
120+
* * *
121+
122+
### unitCode.getFractionFactor([special]) :id=unitcodegetfractionfactor
123+
**Kind**: instance method of <code>UnitCode</code>
124+
**Returns**: <code>Number</code> \| <code>undefined</code>
125+
**Access**: public
126+
127+
| Param | Type |
128+
| --- | --- |
129+
| [special] | <code>Boolean</code> |
130+
131+
>Returns the [fractionFactor](#UnitCodefractionFactor) or [fractionFactorSpecial](#UnitCodefractionFactorSpecial) value.
132+
133+
134+
* * *
135+
136+
### unitCode.getFractionDigits([special]) :id=unitcodegetfractiondigits
137+
**Kind**: instance method of <code>UnitCode</code>
138+
**Returns**: <code>Number</code> \| <code>undefined</code>
139+
**Access**: public
140+
141+
| Param | Type |
142+
| --- | --- |
143+
| [special] | <code>Boolean</code> |
144+
145+
>Returns the [fractionDigits](#UnitCodefractionDigits) or [fractionDigitsSpecial](#UnitCodefractionDigitsSpecial) value.
146+
147+
148+
* * *
149+
150+
### UnitCode.parse(code) :id=unitcodeparse
151+
**Kind**: static method of <code>UnitCode</code>
152+
**Returns**: <code>UnitCode</code> \| <code>null</code>
153+
**Access**: public
154+
155+
| Param | Type |
156+
| --- | --- |
157+
| code | <code>String</code> |
158+
159+
>Converts a unit code character into a [UnitCode](/content/sdk/lib-utilities-data?id=unitcode) enumeration item.
160+
161+
162+
* * *
163+
164+
### UnitCode.fromBaseCode(code) :id=unitcodefrombasecode
165+
**Kind**: static method of <code>UnitCode</code>
166+
**Returns**: <code>UnitCode</code> \| <code>null</code>
167+
**Access**: public
168+
169+
| Param | Type |
170+
| --- | --- |
171+
| code | <code>Number</code> |
172+
173+
>Converts a numeric "base" code into a [UnitCode](/content/sdk/lib-utilities-data?id=unitcode) item.
174+
175+
176+
* * *
177+
7178
## getTimezones() :id=gettimezones
8179
**Kind**: global function
9180
**Returns**: <code>Array.&lt;String&gt;</code>

docs/content/sdk/lib-utilities-format.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* [Functions](#Functions) : <code>object</code>
77
* [.formatDate([date], [utc])](#FunctionsformatDate) ⇒ <code>String</code>
88
* [.formatDecimal(value, digits, [thousandsSeparator], [useParenthesis])](#FunctionsformatDecimal) ⇒ <code>String</code>
9-
* [.formatPrice(value, unitcode, [fractionSeparator], [specialFractions], [thousandsSeparator], [useParenthesis])](#FunctionsformatPrice) ⇒ <code>String</code>
9+
* [.formatPrice(value, unitCode, [fractionSeparator], [specialFractions], [thousandsSeparator], [useParenthesis])](#FunctionsformatPrice) ⇒ <code>String</code>
1010
* [.formatQuoteDateTime(quote, [useTwelveHourClock], [short], [timezone])](#FunctionsformatQuoteDateTime) ⇒ <code>String</code>
1111
* [.formatSymbol(symbol)](#FunctionsformatSymbol) ⇒ <code>String</code> \| <code>\*</code>
1212
* [.formatTime(date, [timezone], [useTwelveHourClock], [short], [utc])](#FunctionsformatTime) ⇒ <code>String</code>
@@ -48,22 +48,25 @@
4848

4949
* * *
5050

51-
### Functions.formatPrice(value, unitcode, [fractionSeparator], [specialFractions], [thousandsSeparator], [useParenthesis]) :id=functionsformatprice
51+
### Functions.formatPrice(value, unitCode, [fractionSeparator], [specialFractions], [thousandsSeparator], [useParenthesis]) :id=functionsformatprice
5252
**Kind**: static method of <code>Functions</code>
5353
**Returns**: <code>String</code>
5454
**Import**: @barchart/marketdata-api-js/lib/utilities/format/price
5555
**File**: /lib/utilities/format/price.js
5656

57-
| Param | Type |
58-
| --- | --- |
59-
| value | <code>Number</code> |
60-
| unitcode | <code>String</code> |
61-
| [fractionSeparator] | <code>String</code> |
62-
| [specialFractions] | <code>Boolean</code> |
63-
| [thousandsSeparator] | <code>String</code> |
64-
| [useParenthesis] | <code>Boolean</code> |
65-
66-
>Formats a number as a string.
57+
| Param | Type | Description |
58+
| --- | --- | --- |
59+
| value | <code>Number</code> | |
60+
| unitCode | <code>String</code> | |
61+
| [fractionSeparator] | <code>String</code> | Can be zero or one character in length. If invalid or omitted, a decimal notation is used. If non-decimal, then fractional notation is used (assuming supported by unit code). |
62+
| [specialFractions] | <code>Boolean</code> | If fractional notation is used, indicates is "special" factor (i.e. denominator) is used to calculate numerator. |
63+
| [thousandsSeparator] | <code>String</code> | Can be zero or one character in length. If invalid or omitted, a zero-length string is used. |
64+
| [useParenthesis] | <code>Boolean</code> | If true, negative values will be represented with parenthesis (instead of a leading minus sign). |
65+
66+
>Converts a numeric price into a human-readable string. One of two modes
67+
may be used, depending on the unit code and fraction separator. For example,
68+
using unit code "2" the value 9.5432 is formatted as "9.543" in decimal
69+
mode and "9-4" in fractional mode.
6770

6871

6972
* * *

docs/content/sdk/lib-utilities-parse.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55

66
* * *
77

8-
### Functions.parsePrice(value, unitCode) :id=functionsparseprice
8+
### Functions.parsePrice(value, unitCode, [fractionSeparator], [specialFractions], [thousandsSeparator]) :id=functionsparseprice
99
**Kind**: static method of <code>Functions</code>
1010
**Returns**: <code>Number</code>
1111
**Import**: @barchart/marketdata-api-js/lib/utilities/parse/price
1212
**File**: /lib/utilities/parse/price.js
1313

14-
| Param | Type |
15-
| --- | --- |
16-
| value | <code>String</code> |
17-
| unitCode | <code>String</code> |
14+
| Param | Type | Description |
15+
| --- | --- | --- |
16+
| value | <code>String</code> \| <code>Number</code> | |
17+
| unitCode | <code>String</code> | |
18+
| [fractionSeparator] | <code>String</code> | Can be zero or one character in length. If invalid or omitted, the separator will be inferred based on the value being parsed. |
19+
| [specialFractions] | <code>Boolean</code> | If fractional notation is used, indicates is "special" factor (i.e. denominator) was used to calculate the numerator of the value being parsed. |
20+
| [thousandsSeparator] | <code>String</code> | = Can be zero or one character in length. If invalid or omitted, the parameter will be ignored. |
1821

19-
>Converts a string-formatted price into a number.
22+
>Converts a string-formatted price into a number. If the value cannot be parsed,
23+
the [Number.NaN](Number.NaN) value is returned.
2024

2125

2226
* * *

0 commit comments

Comments
 (0)