@barchart/portfolio-api-common 7.0.1 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ const Enum = require('@barchart/common-js/lang/Enum');
2
+
3
+ module.exports = (() => {
4
+ 'use strict';
5
+
6
+ /**
7
+ * An enumeration item that describes the source of the positions (Manual vs Linked).
8
+ *
9
+ * @public
10
+ * @extends {Enum}
11
+ * @param {String} code
12
+ * @param {String} description
13
+ */
14
+ class SourceMode extends Enum {
15
+ constructor(code, description) {
16
+ super(code, description);
17
+ }
18
+
19
+ /**
20
+ * Show all positions (both manual and linked).
21
+ *
22
+ * @returns {SourceMode}
23
+ */
24
+ static get ALL() {
25
+ return all;
26
+ }
27
+
28
+ /**
29
+ * Show manually created (paper trading) positions only.
30
+ *
31
+ * @returns {SourceMode}
32
+ */
33
+ static get MANUAL() {
34
+ return manual;
35
+ }
36
+
37
+ /**
38
+ * Show brokerage linked (SnapTrade) positions only.
39
+ *
40
+ * @returns {SourceMode}
41
+ */
42
+ static get LINKED() {
43
+ return linked;
44
+ }
45
+
46
+ /**
47
+ * Given a code, returns the enumeration item.
48
+ *
49
+ * @public
50
+ * @param {String} code
51
+ * @returns {SourceMode|null}
52
+ */
53
+ static parse(code) {
54
+ return Enum.fromCode(SourceMode, code);
55
+ }
56
+
57
+ toString() {
58
+ return `[SourceMode (code=${this.code})]`;
59
+ }
60
+ }
61
+
62
+
63
+ const all = new SourceMode('ALL', 'All Accounts');
64
+ const manual = new SourceMode('MANUAL', 'Paper Trading');
65
+ const linked = new SourceMode('LINKED', 'Brokerage Linked');
66
+
67
+ return SourceMode;
68
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
4
4
  "description": "Common JavaScript code used by Barchart's Portfolio Service",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",