|
1 | 1 | ## Contents {docsify-ignore} |
2 | 2 |
|
| 3 | +* [UnitCode](#UnitCode) |
| 4 | + |
3 | 5 | * [getTimezones()](#getTimezones) |
4 | 6 |
|
5 | 7 | * [guessTimezone()](#guessTimezone) |
6 | 8 |
|
| 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 | + |
7 | 178 | ## getTimezones() :id=gettimezones |
8 | 179 | **Kind**: global function |
9 | 180 | **Returns**: <code>Array.<String></code> |
|
0 commit comments