@barchart/portfolio-api-common 7.5.0 → 8.0.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.
@@ -6,6 +6,7 @@ const array = require('@barchart/common-js/lang/array'),
6
6
  CurrencyTranslator = require('@barchart/common-js/lang/CurrencyTranslator'),
7
7
  Day = require('@barchart/common-js/lang/Day'),
8
8
  Decimal = require('@barchart/common-js/lang/Decimal'),
9
+ Disposable = require('@barchart/common-js/lang/Disposable'),
9
10
  DisposableStack = require('@barchart/common-js/collections/specialized/DisposableStack'),
10
11
  Event = require('@barchart/common-js/messaging/Event'),
11
12
  is = require('@barchart/common-js/lang/is'),
@@ -86,6 +87,11 @@ module.exports = (() => {
86
87
 
87
88
  this._groupBindings = { };
88
89
 
90
+ this._calculationSuspensions = new Set();
91
+
92
+ this._suspendedForexQuotes = new Map();
93
+ this._suspendedPositionQuotes = new Map();
94
+
89
95
  this._reporting = reportFrame instanceof PositionSummaryFrame;
90
96
  this._useBarchartPriceFormattingRules = false;
91
97
 
@@ -201,6 +207,48 @@ module.exports = (() => {
201
207
  recalculatePercentages.call(this);
202
208
  }
203
209
 
210
+ /**
211
+ * Suspends recalculation of aggregated position data.
212
+ *
213
+ * @public
214
+ * @returns {Disposable}
215
+ */
216
+ suspendCalculations() {
217
+ const token = { };
218
+
219
+ const disposable = Disposable.fromAction(() => {
220
+ if (this._calculationSuspensions.delete(token) && this._calculationSuspensions.size === 0) {
221
+ const positionQuotes = [ ...this._suspendedPositionQuotes.entries() ];
222
+ const forexQuotes = [ ...this._suspendedForexQuotes.entries() ];
223
+
224
+ this._suspendedPositionQuotes = new Map();
225
+ this._suspendedForexQuotes = new Map();
226
+
227
+ this.setQuotes(positionQuotes, forexQuotes);
228
+
229
+ Object.keys(this._trees).forEach((key) => {
230
+ this._trees[key].walk(group => group.resumeCalculations(), false, false);
231
+ });
232
+ }
233
+ });
234
+
235
+ this._calculationSuspensions.add(token);
236
+
237
+ if (this._calculationSuspensions.size === 1) {
238
+ Object.keys(this._trees).forEach((key) => {
239
+ this._trees[key].walk(group => group.suspendCalculations(), false, false);
240
+ });
241
+
242
+ recalculatePercentages.call(this);
243
+ }
244
+
245
+ return disposable;
246
+ }
247
+
248
+ getCalculationsSuspended() {
249
+ return this._calculationSuspensions.size !== 0;
250
+ }
251
+
204
252
  /**
205
253
  * Returns Barchart's user identifier for the container's portfolios. If
206
254
  * the container has no portfolios, a null value is returned.
@@ -209,18 +257,16 @@ module.exports = (() => {
209
257
  * @returns {String|null}
210
258
  */
211
259
  getBarchartUserId() {
212
- let returnRef = null;
213
-
214
260
  const keys = Object.keys(this._portfolios);
215
261
 
216
262
  if (keys.length > 0) {
217
263
  const firstKey = keys[0];
218
264
  const firstPortfolio = this._portfolios[firstKey];
219
265
 
220
- returnRef = firstPortfolio.user;
266
+ return firstPortfolio.user;
221
267
  }
222
268
 
223
- return returnRef;
269
+ return null;
224
270
  }
225
271
 
226
272
  /**
@@ -232,8 +278,6 @@ module.exports = (() => {
232
278
  * @returns {String|null}
233
279
  */
234
280
  getCustomerUserId() {
235
- let returnRef = null;
236
-
237
281
  const keys = Object.keys(this._portfolios);
238
282
 
239
283
  if (keys.length > 0) {
@@ -241,11 +285,11 @@ module.exports = (() => {
241
285
  const firstPortfolio = this._portfolios[firstKey];
242
286
 
243
287
  if (firstPortfolio.legacy && firstPortfolio.legacy.user) {
244
- returnRef = firstPortfolio.legacy.user;
288
+ return firstPortfolio.legacy.user;
245
289
  }
246
290
  }
247
291
 
248
- return returnRef;
292
+ return null;
249
293
  }
250
294
 
251
295
  /**
@@ -402,14 +446,13 @@ module.exports = (() => {
402
446
  return;
403
447
  }
404
448
 
405
- const existingBarchartSymbols = this.getPositionSymbols(false);
449
+ const existingBarchartSymbols = this.getPositionSymbols(false, false);
406
450
 
407
- let exchange;
451
+ let exchangeCode = extractExchangeCode(position);
452
+ let exchange = null;
408
453
 
409
- if (extractExchangeCode(position)) {
410
- const code = extractExchangeCode(position);
411
-
412
- exchange = this._exchanges[code] || null;
454
+ if (exchangeCode !== null) {
455
+ exchange = this._exchanges[exchangeCode] || null;
413
456
  }
414
457
 
415
458
  let currentQuote = null;
@@ -471,7 +514,7 @@ module.exports = (() => {
471
514
  this._positionSymbolAddedEvent.fire(addedBarchartSymbol);
472
515
  }
473
516
 
474
- if (exchange) {
517
+ if (exchange !== null) {
475
518
  item.setExchangeStatus(exchange);
476
519
  }
477
520
 
@@ -519,7 +562,7 @@ module.exports = (() => {
519
562
  *
520
563
  * @public
521
564
  * @param {Boolean} display - If true, all "display" symbols are returned; otherwise Barchart symbols are returned.
522
- * @param {Boolean} excludeExpired - If true, only non-expired symbols are filtered.
565
+ * @param {Boolean} excludeExpired - If true, only symbols for non-expired positions will be returned.
523
566
  * @returns {String[]}
524
567
  */
525
568
  getPositionSymbols(display, excludeExpired) {
@@ -634,6 +677,22 @@ module.exports = (() => {
634
677
  assert.argumentIsArray(forexQuotes, 'forexQuotes');
635
678
  assert.argumentIsOptional(force, 'force', Boolean);
636
679
 
680
+ if (this.getCalculationsSuspended()) {
681
+ forexQuotes.forEach((quote) => {
682
+ const symbol = quote.symbol;
683
+
684
+ this._suspendedForexQuotes.set(symbol, quote);
685
+ });
686
+
687
+ positionQuotes.forEach((quote) => {
688
+ const symbol = quote.symbol;
689
+
690
+ this._suspendedPositionQuotes.set(symbol, quote);
691
+ });
692
+
693
+ return;
694
+ }
695
+
637
696
  if (forexQuotes.length !== 0) {
638
697
  forexQuotes.forEach((quote) => {
639
698
  const symbol = quote.symbol;
@@ -947,41 +1006,39 @@ module.exports = (() => {
947
1006
  function findParentGroup(group, predicate) {
948
1007
  const groupNode = this._nodes[group.id];
949
1008
 
950
- let returnRef = null;
951
-
952
1009
  if (groupNode) {
953
1010
  const resultNode = groupNode.findParent((candidateGroup, candidateNode) => !candidateNode.getIsRoot() && predicate(candidateGroup));
954
1011
 
955
1012
  if (resultNode) {
956
- returnRef = resultNode.getValue();
1013
+ return resultNode.getValue();
957
1014
  }
958
1015
  }
959
1016
 
960
- return returnRef;
1017
+ return null;
961
1018
  }
962
1019
 
963
1020
  function extractSymbolForBarchart(position) {
964
1021
  if (position.instrument && position.instrument.symbol && position.instrument.symbol.barchart) {
965
1022
  return position.instrument.symbol.barchart;
966
- } else {
967
- return null;
968
1023
  }
1024
+
1025
+ return null;
969
1026
  }
970
1027
 
971
1028
  function extractSymbolForDisplay(position) {
972
1029
  if (position.instrument && position.instrument.symbol && position.instrument.symbol.display) {
973
1030
  return position.instrument.symbol.display;
974
- } else {
975
- return null;
976
1031
  }
1032
+
1033
+ return null;
977
1034
  }
978
1035
 
979
1036
  function extractExchangeCode(position) {
980
1037
  if (position.instrument && position.instrument.exchange) {
981
1038
  return position.instrument.exchange;
982
- } else {
983
- return null;
984
1039
  }
1040
+
1041
+ return null;
985
1042
  }
986
1043
 
987
1044
  function addGroupBinding(group, dispoable) {
@@ -1056,7 +1113,7 @@ module.exports = (() => {
1056
1113
  const items = populatedObjects[key];
1057
1114
  const first = items[0];
1058
1115
 
1059
- const group = new PositionGroup(levelDefinition, items, levelDefinition.currencySelector(first), currencyTranslator, key, levelDefinition.descriptionSelector(first), levelDefinition.aggregateCash);
1116
+ const group = new PositionGroup(levelDefinition, items, levelDefinition.currencySelector(first), currencyTranslator, key, levelDefinition.descriptionSelector(first), this.getCalculationsSuspended());
1060
1117
 
1061
1118
  group.setBarchartPriceFormattingRules(this._useBarchartPriceFormattingRules);
1062
1119
 
@@ -1072,15 +1129,15 @@ module.exports = (() => {
1072
1129
  return requiredGroupsToUse.find(g => g.key === key);
1073
1130
  });
1074
1131
 
1075
- const empty = missingGroups.map((group) => {
1076
- const eg = new PositionGroup(levelDefinition, [ ], group.currency, currencyTranslator, group.key, group.description);
1132
+ const emptyGroups = missingGroups.map((group) => {
1133
+ const empty = new PositionGroup(levelDefinition, [ ], group.currency, currencyTranslator, group.key, group.description, this.getCalculationsSuspended());
1077
1134
 
1078
- eg.setBarchartPriceFormattingRules(this._useBarchartPriceFormattingRules);
1135
+ empty.setBarchartPriceFormattingRules(this._useBarchartPriceFormattingRules);
1079
1136
 
1080
- return eg;
1137
+ return empty;
1081
1138
  });
1082
1139
 
1083
- const compositeGroups = populatedGroups.concat(empty);
1140
+ const compositeGroups = populatedGroups.concat(emptyGroups);
1084
1141
 
1085
1142
  let builder;
1086
1143
 
@@ -1201,22 +1258,16 @@ module.exports = (() => {
1201
1258
  function createPositionItem(position, requireCurrentSummary) {
1202
1259
  const portfolio = this._portfolios[position.portfolio];
1203
1260
 
1204
- let returnRef;
1205
-
1206
1261
  if (portfolio) {
1207
1262
  const currentSummary = this._summariesCurrent[ position.position ] || null;
1208
1263
  const previousSummaries = this._summariesPrevious[ position.position ] || getSummaryArray(this._previousSummaryRanges);
1209
1264
 
1210
1265
  if (!requireCurrentSummary || currentSummary !== null) {
1211
- returnRef = new PositionItem(portfolio, position, currentSummary, previousSummaries, this._reporting, this._reportDate);
1212
- } else {
1213
- returnRef = null;
1266
+ return new PositionItem(portfolio, position, currentSummary, previousSummaries, this._reporting, this._reportDate);
1214
1267
  }
1215
- } else {
1216
- returnRef = null;
1217
1268
  }
1218
1269
 
1219
- return returnRef;
1270
+ return null;
1220
1271
  }
1221
1272
 
1222
1273
  function removePositionItem(positionItem) {
@@ -1258,6 +1309,10 @@ module.exports = (() => {
1258
1309
  }
1259
1310
 
1260
1311
  function recalculatePercentages() {
1312
+ if (this.getCalculationsSuspended()) {
1313
+ return;
1314
+ }
1315
+
1261
1316
  Object.keys(this._trees).forEach((key) => {
1262
1317
  this._trees[key].walk(group => group.refreshMarketPercent(), false, false);
1263
1318
  });
@@ -1297,4 +1352,4 @@ module.exports = (() => {
1297
1352
  */
1298
1353
 
1299
1354
  return PositionContainer;
1300
- })();
1355
+ })();
@@ -32,10 +32,10 @@ module.exports = (() => {
32
32
  * @param {CurrencyTranslator} currencyTranslator
33
33
  * @param {String} key
34
34
  * @param {String} description
35
- * @param {Boolean=} aggregateCash
35
+ * @param {Boolean} calculationsSuspended
36
36
  */
37
37
  class PositionGroup {
38
- constructor(definition, items, currency, currencyTranslator, key, description, aggregateCash) {
38
+ constructor(definition, items, currency, currencyTranslator, key, description, calculationsSuspended) {
39
39
  this._id = counter++;
40
40
 
41
41
  this._definition = definition;
@@ -57,7 +57,7 @@ module.exports = (() => {
57
57
  this._single = this._definition.single;
58
58
  this._homogeneous = this._definition.homogeneous;
59
59
 
60
- this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
60
+ this._calculationsSuspended = calculationsSuspended;
61
61
 
62
62
  this._excluded = false;
63
63
  this._showClosedPositions = false;
@@ -342,6 +342,28 @@ module.exports = (() => {
342
342
  return this._excluded;
343
343
  }
344
344
 
345
+ /**
346
+ * Suspends recalculation of aggregated group data.
347
+ *
348
+ * @public
349
+ */
350
+ suspendCalculations() {
351
+ this._calculationsSuspended = true;
352
+ }
353
+
354
+ /**
355
+ * Resumes recalculation of aggregated group data.
356
+ *
357
+ * @public
358
+ */
359
+ resumeCalculations() {
360
+ if (this._calculationsSuspended) {
361
+ this._calculationsSuspended = false;
362
+
363
+ this.refresh();
364
+ }
365
+ }
366
+
345
367
  /**
346
368
  * Changes the group currency.
347
369
  *
@@ -512,17 +534,25 @@ module.exports = (() => {
512
534
  * @public
513
535
  */
514
536
  refresh() {
537
+ if (this._calculationsSuspended) {
538
+ return;
539
+ }
540
+
515
541
  calculateStaticData(this, this._definition);
516
542
  calculatePriceData(this,null, true);
517
543
  }
518
544
 
519
545
  /**
520
- * Causes the percent of the position, with respect to the parent container's
546
+ * Causes the percent of the group, with respect to the parent group's
521
547
  * total, to be recalculated.
522
548
  *
523
549
  * @public
524
550
  */
525
551
  refreshMarketPercent() {
552
+ if (this._calculationsSuspended) {
553
+ return;
554
+ }
555
+
526
556
  calculateMarketPercent(this, this._parentGroup, this._portfolioGroup);
527
557
  }
528
558
 
@@ -600,6 +630,10 @@ module.exports = (() => {
600
630
 
601
631
  function bindItem(item) {
602
632
  const quoteBinding = item.registerQuoteChangeHandler((quote, sender) => {
633
+ if (this._calculationsSuspended) {
634
+ return;
635
+ }
636
+
603
637
  if (this._single || (this._homogeneous && item === this._items[0])) {
604
638
  const instrument = sender.position.instrument;
605
639
  const currency = instrument.currency;
@@ -1144,6 +1178,7 @@ module.exports = (() => {
1144
1178
 
1145
1179
  if (updates.marketDirection.up || updates.marketDirection.down) {
1146
1180
  format.marketDirection = unchanged;
1181
+
1147
1182
  setTimeout(() => format.marketDirection = updates.marketDirection, 0);
1148
1183
  }
1149
1184
 
@@ -21,11 +21,10 @@ module.exports = (() => {
21
21
  * @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
22
22
  * @param {PositionLevelDefinition~currencySelector} currencySelector
23
23
  * @param {PositionLevelDefinition~RequiredGroup[]=} requiredGroups
24
- * @param {Boolean=} aggregateCash
25
24
  * @param {Function=} requiredGroupGenerator
26
25
  */
27
26
  class PositionLevelDefinition {
28
- constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, aggregateCash, requiredGroupGenerator) {
27
+ constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, requiredGroupGenerator) {
29
28
  assert.argumentIsRequired(name, 'name', String);
30
29
  assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
31
30
  assert.argumentIsRequired(keySelector, 'keySelector', Function);
@@ -36,7 +35,6 @@ module.exports = (() => {
36
35
  assert.argumentIsArray(requiredGroups, 'requiredGroups', String);
37
36
  }
38
37
 
39
- assert.argumentIsOptional(aggregateCash, 'aggregateCash', Boolean);
40
38
  assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
41
39
 
42
40
  this._name = name;
@@ -51,8 +49,6 @@ module.exports = (() => {
51
49
  this._single = type === PositionLevelType.POSITION;
52
50
  this._homogeneous = type === PositionLevelType.INSTRUMENT;
53
51
 
54
- this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
55
-
56
52
  this._requiredGroupGenerator = requiredGroupGenerator || (input => null);
57
53
  }
58
54
 
@@ -140,16 +136,6 @@ module.exports = (() => {
140
136
  return this._homogeneous;
141
137
  }
142
138
 
143
- /**
144
- * Indicates if the grouping level should aggregate cash positions.
145
- *
146
- * @public
147
- * @returns {Boolean}
148
- */
149
- get aggregateCash() {
150
- return this._aggregateCash;
151
- }
152
-
153
139
  /**
154
140
  * Given an input, potentially creates a new {@link PositionLevelDefinition~RequiredGroup}.
155
141
  *
@@ -5,6 +5,7 @@ const Currency = require('@barchart/common-js/lang/Currency'),
5
5
  Timezones = require('@barchart/common-js/lang/Timezones');
6
6
 
7
7
  const SnapTradeLinkStatus = require('./../data/SnapTradeLinkStatus'),
8
+ SnapTradeLinkMode = require('./../data/SnapTradeLinkMode'),
8
9
  ValuationType = require('./../data/ValuationType');
9
10
 
10
11
  module.exports = (() => {
@@ -96,96 +97,123 @@ module.exports = (() => {
96
97
  const complete = new PortfolioSchema(SchemaBuilder.withName('complete')
97
98
  .withField('user', DataType.STRING)
98
99
  .withField('portfolio', DataType.STRING)
100
+
99
101
  .withField('name', DataType.STRING)
100
102
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
103
+ .withField('miscellany', DataType.AD_HOC, true)
104
+ .withField('email', DataType.AD_HOC, true)
105
+
101
106
  .withField('dates.create', DataType.DAY)
102
107
  .withField('dates.access', DataType.TIMESTAMP, true)
108
+
103
109
  .withField('defaults.cash', DataType.BOOLEAN, true)
104
110
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
105
111
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
106
112
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
113
+
114
+ .withField('legacy.system', DataType.STRING, true)
115
+ .withField('legacy.user', DataType.STRING, true)
116
+ .withField('legacy.portfolio', DataType.STRING, true)
117
+ .withField('legacy.warnings', DataType.NUMBER, true)
118
+ .withField('legacy.drops', DataType.NUMBER, true)
119
+
107
120
  .withField('snaptrade.connection', DataType.STRING, true)
108
121
  .withField('snaptrade.account', DataType.STRING, true)
109
122
  .withField('snaptrade.broken', DataType.BOOLEAN, true)
110
123
  .withField('snaptrade.timestamp', DataType.TIMESTAMP, true)
124
+
125
+ .withField('snaptrade.brokerage.display', DataType.STRING, true)
126
+ .withField('snaptrade.brokerage.logo', DataType.STRING, true)
127
+
128
+ .withField('snaptrade.link.mode', DataType.forEnum(SnapTradeLinkMode, 'SnapTradeLinkMode'), true)
111
129
  .withField('snaptrade.link.status', DataType.forEnum(SnapTradeLinkStatus, 'SnapTradeLinkStatus'), true)
112
130
  .withField('snaptrade.link.progress', DataType.NUMBER, true)
113
131
  .withField('snaptrade.link.timestamp', DataType.TIMESTAMP, true)
114
- .withField('snaptrade.brokerage.display', DataType.STRING, true)
115
- .withField('snaptrade.brokerage.logo', DataType.STRING, true)
116
- .withField('legacy.system', DataType.STRING, true)
117
- .withField('legacy.user', DataType.STRING, true)
118
- .withField('legacy.portfolio', DataType.STRING, true)
119
- .withField('legacy.warnings', DataType.NUMBER, true)
120
- .withField('legacy.drops', DataType.NUMBER, true)
121
- .withField('miscellany', DataType.AD_HOC, true)
122
- .withField('email', DataType.AD_HOC, true)
123
- .withField('system.calculate.processors', DataType.NUMBER, true)
132
+
124
133
  .withField('system.sequence', DataType.NUMBER)
125
134
  .withField('system.version', DataType.STRING)
126
135
  .withField('system.timestamp', DataType.TIMESTAMP)
136
+ .withField('system.calculate.processors', DataType.NUMBER, true)
137
+
127
138
  .schema
128
139
  );
129
140
 
130
141
  const client = new PortfolioSchema(SchemaBuilder.withName('client')
131
142
  .withField('user', DataType.STRING)
132
143
  .withField('portfolio', DataType.STRING)
144
+
133
145
  .withField('name', DataType.STRING)
134
146
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
147
+ .withField('miscellany', DataType.AD_HOC, true)
148
+ .withField('email', DataType.AD_HOC, true)
149
+
135
150
  .withField('dates.create', DataType.DAY)
136
151
  .withField('dates.access', DataType.TIMESTAMP, true)
152
+
137
153
  .withField('defaults.cash', DataType.BOOLEAN, true)
138
154
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
139
155
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
140
156
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
157
+
158
+ .withField('legacy.system', DataType.STRING, true)
159
+ .withField('legacy.user', DataType.STRING, true)
160
+ .withField('legacy.portfolio', DataType.STRING, true)
161
+ .withField('legacy.warnings', DataType.NUMBER, true)
162
+ .withField('legacy.drops', DataType.NUMBER, true)
163
+
141
164
  .withField('snaptrade.connection', DataType.STRING, true)
142
165
  .withField('snaptrade.account', DataType.STRING, true)
143
166
  .withField('snaptrade.broken', DataType.BOOLEAN, true)
144
167
  .withField('snaptrade.timestamp', DataType.TIMESTAMP, true)
168
+
169
+ .withField('snaptrade.brokerage.display', DataType.STRING, true)
170
+ .withField('snaptrade.brokerage.logo', DataType.STRING, true)
171
+
172
+ .withField('snaptrade.link.mode', DataType.forEnum(SnapTradeLinkMode, 'SnapTradeLinkMode'), true)
145
173
  .withField('snaptrade.link.status', DataType.forEnum(SnapTradeLinkStatus, 'SnapTradeLinkStatus'), true)
146
174
  .withField('snaptrade.link.progress', DataType.NUMBER, true)
147
175
  .withField('snaptrade.link.timestamp', DataType.TIMESTAMP, true)
148
- .withField('snaptrade.brokerage.display', DataType.STRING, true)
149
- .withField('snaptrade.brokerage.logo', DataType.STRING, true)
150
- .withField('legacy.system', DataType.STRING, true)
151
- .withField('legacy.user', DataType.STRING, true)
152
- .withField('legacy.portfolio', DataType.STRING, true)
153
- .withField('legacy.warnings', DataType.NUMBER, true)
154
- .withField('legacy.drops', DataType.NUMBER, true)
155
- .withField('miscellany', DataType.AD_HOC, true)
156
- .withField('email', DataType.AD_HOC, true)
176
+
157
177
  .withField('system.calculate.processors', DataType.NUMBER, true)
178
+
158
179
  .schema
159
180
  );
160
181
 
161
182
  const name = new PortfolioSchema(SchemaBuilder.withName('name')
162
183
  .withField('user', DataType.STRING)
163
184
  .withField('portfolio', DataType.STRING)
185
+
164
186
  .withField('name', DataType.STRING)
187
+
165
188
  .schema
166
189
  );
167
190
 
168
191
  const create = new PortfolioSchema(SchemaBuilder.withName('create')
169
192
  .withField('name', DataType.STRING)
170
193
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
194
+ .withField('miscellany', DataType.AD_HOC, true)
195
+ .withField('email', DataType.AD_HOC, true)
196
+
171
197
  .withField('defaults.cash', DataType.BOOLEAN, true)
172
198
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'), true)
173
199
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
174
200
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'), true)
175
- .withField('miscellany', DataType.AD_HOC, true)
176
- .withField('email', DataType.AD_HOC, true)
201
+
177
202
  .schema
178
203
  );
179
204
 
180
205
  const update = new PortfolioSchema(SchemaBuilder.withName('update')
181
206
  .withField('portfolio', DataType.STRING)
182
- .withField('name', DataType.STRING)
207
+
183
208
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'), true)
209
+ .withField('name', DataType.STRING)
210
+ .withField('miscellany', DataType.AD_HOC, true)
211
+ .withField('email', DataType.AD_HOC, true)
212
+
184
213
  .withField('defaults.cash', DataType.BOOLEAN, true)
185
214
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'), true)
186
215
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
187
- .withField('miscellany', DataType.AD_HOC, true)
188
- .withField('email', DataType.AD_HOC, true)
216
+
189
217
  .schema
190
218
  );
191
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "7.5.0",
3
+ "version": "8.0.0",
4
4
  "description": "Common JavaScript code used by Barchart's Portfolio Service",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",