@barchart/portfolio-api-common 1.2.5 → 1.2.6

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) {
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
  }
@@ -115,7 +115,7 @@ module.exports = (() => {
115
115
  * Indicates if the position's symbol is invalid.
116
116
  *
117
117
  * @public
118
- * @returns {Object}
118
+ * @returns {Boolean}
119
119
  */
120
120
  get invalid() {
121
121
  return this._invalid;
@@ -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.5",
3
+ "version": "1.2.6",
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) {
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
  }
@@ -3079,7 +3098,7 @@ module.exports = (() => {
3079
3098
  * Indicates if the position's symbol is invalid.
3080
3099
  *
3081
3100
  * @public
3082
- * @returns {Object}
3101
+ * @returns {Boolean}
3083
3102
  */
3084
3103
  get invalid() {
3085
3104
  return this._invalid;