Skip to content

Commit 90b06dd

Browse files
committed
Added SymbolParser.getIsCash function
1 parent f426d25 commit 90b06dd

File tree

7 files changed

+97
-21765
lines changed

7 files changed

+97
-21765
lines changed

docs/content/release_notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
## 6.0.1
4+
**New Features**
5+
6+
* Added `SymbolParser.getIsCash` function.
7+
38
## 5.27.1
49
**Bug Fixes**
510

docs/content/releases/6.0.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**New Features**
2+
3+
* Added `SymbolParser.getIsCash` function.

lib/utilities/parsers/SymbolParser.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ module.exports = (() => {
5353
return is.string(symbol) && (types.futures.concrete.test(symbol) || types.futures.alias.test(symbol));
5454
}
5555

56+
/**
57+
* Indicates if a symbol represents a "cash" futures contract (a
58+
* proprietary Barchart concept).
59+
*
60+
* @public
61+
* @static
62+
* @param {String} symbol
63+
* @returns {Boolean}
64+
*/
65+
static getIsCash(symbol) {
66+
return SymbolParser.getIsFuture(symbol) && types.futures.cash.test(symbol);
67+
}
68+
5669
/**
5770
* Returns true when a symbol represents futures spread.
5871
*
@@ -469,6 +482,7 @@ module.exports = (() => {
469482
types.futures.alias = /^([A-Z][A-Z0-9\$\-!\.]{0,2})(\*{1})([0-9]{1,2})$/i;
470483
types.futures.concrete = /^([A-Z][A-Z0-9\$\-!\.]{0,2})([A-Z]{1})([0-9]{4}|[0-9]{1,2})$/i;
471484
types.futures.spread = /^_S_/i;
485+
types.futures.cash = /(.*)(Y00)$/;
472486

473487
types.futures.options = {};
474488
types.futures.options.historical = /^([A-Z][A-Z0-9\$\-!\.]{0,2})([A-Z])([0-9]{2})([0-9]{1,5})(C|P)$/i;

test/SpecRunnner.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
1212
<script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
1313

14-
<script src="./dist/barchart-marketdata-api-tests-5.js"></script>
14+
<script src="./dist/barchart-marketdata-api-tests-6.js"></script>
1515
</head>
1616

1717
<body>

0 commit comments

Comments
 (0)