@barchart/portfolio-api-common 1.2.4 → 1.2.8

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.
@@ -155,8 +155,8 @@ module.exports = (() => {
155
155
  /**
156
156
  * Generates an identifier for the instrument.
157
157
  *
158
- * @static
159
158
  * @public
159
+ * @static
160
160
  * @param {Object} instrument
161
161
  * @returns {String}
162
162
  */
@@ -164,6 +164,25 @@ module.exports = (() => {
164
164
  return map[instrument.type.code].generateIdentifier(instrument);
165
165
  }
166
166
 
167
+ /**
168
+ *
169
+ * @public
170
+ * @static
171
+ * @param code
172
+ * @return {InstrumentType}
173
+ */
174
+ static fromSymbolType(code) {
175
+ assert.argumentIsRequired(code, 'code', Number);
176
+
177
+ if (code === 1 || code === 6 || code === 7 || code === 11) {
178
+ return InstrumentType.EQUITY;
179
+ } else if (code === 5 || code == 15) {
180
+ return InstrumentType.FUND;
181
+ } else {
182
+ throw new Error('Unable to determine InstrumentType for [', code, ']');
183
+ }
184
+ }
185
+
167
186
  toString() {
168
187
  return '[InstrumentType]';
169
188
  }
@@ -111,6 +111,16 @@ module.exports = (() => {
111
111
  return this._currency;
112
112
  }
113
113
 
114
+ /**
115
+ * Indicates if the position's symbol is invalid.
116
+ *
117
+ * @public
118
+ * @returns {Boolean}
119
+ */
120
+ get invalid() {
121
+ return this._invalid;
122
+ }
123
+
114
124
  /**
115
125
  * The year-to-date position summary of the encapsulated position.
116
126
  *
@@ -138,6 +138,11 @@ module.exports = (() => {
138
138
  const update = new PositionSchema(SchemaBuilder.withName('update')
139
139
  .withField('portfolio', DataType.STRING)
140
140
  .withField('position', DataType.STRING)
141
+ .withField('mapping.name', DataType.STRING, true)
142
+ .withField('mapping.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
143
+ .withField('mapping.currency', DataType.forEnum(Currency, 'Currency'), true)
144
+ .withField('mapping.symbol.barchart', DataType.STRING, true)
145
+ .withField('mapping.symbol.display', DataType.STRING, true)
141
146
  .withField('reinvest', DataType.BOOLEAN, true)
142
147
  .schema
143
148
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.4",
3
+ "version": "1.2.8",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -156,8 +156,8 @@ module.exports = (() => {
156
156
  /**
157
157
  * Generates an identifier for the instrument.
158
158
  *
159
- * @static
160
159
  * @public
160
+ * @static
161
161
  * @param {Object} instrument
162
162
  * @returns {String}
163
163
  */
@@ -165,6 +165,25 @@ module.exports = (() => {
165
165
  return map[instrument.type.code].generateIdentifier(instrument);
166
166
  }
167
167
 
168
+ /**
169
+ *
170
+ * @public
171
+ * @static
172
+ * @param code
173
+ * @return {InstrumentType}
174
+ */
175
+ static fromSymbolType(code) {
176
+ assert.argumentIsRequired(code, 'code', Number);
177
+
178
+ if (code === 1 || code === 6 || code === 7 || code === 11) {
179
+ return InstrumentType.EQUITY;
180
+ } else if (code === 5 || code == 15) {
181
+ return InstrumentType.FUND;
182
+ } else {
183
+ throw new Error('Unable to determine InstrumentType for [', code, ']');
184
+ }
185
+ }
186
+
168
187
  toString() {
169
188
  return '[InstrumentType]';
170
189
  }
@@ -3075,6 +3094,16 @@ module.exports = (() => {
3075
3094
  return this._currency;
3076
3095
  }
3077
3096
 
3097
+ /**
3098
+ * Indicates if the position's symbol is invalid.
3099
+ *
3100
+ * @public
3101
+ * @returns {Boolean}
3102
+ */
3103
+ get invalid() {
3104
+ return this._invalid;
3105
+ }
3106
+
3078
3107
  /**
3079
3108
  * The year-to-date position summary of the encapsulated position.
3080
3109
  *