@barchart/portfolio-api-common 1.0.261 → 1.0.265
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.
- package/lib/data/PositionSummaryFrame.js +21 -5
- package/lib/data/TransactionValidator.js +27 -1
- package/lib/processing/PositionContainer.js +1 -1
- package/lib/processing/PositionGroup.js +2 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +440 -41
- package/test/specs/data/PositionSummaryFrameSpec.js +1 -1
- package/test/specs/data/TransactionValidatorSpec.js +51 -0
|
@@ -20,18 +20,34 @@ module.exports = (() => {
|
|
|
20
20
|
* @param {Function} descriptionCalculator
|
|
21
21
|
*/
|
|
22
22
|
class PositionSummaryFrame extends Enum {
|
|
23
|
-
constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
|
|
23
|
+
constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
|
|
24
24
|
super(code, description);
|
|
25
25
|
|
|
26
|
+
assert.argumentIsRequired(unique, 'unique', Boolean);
|
|
27
|
+
|
|
26
28
|
assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
|
|
27
29
|
assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
|
|
28
30
|
assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
|
|
29
31
|
|
|
32
|
+
this._unique = unique;
|
|
33
|
+
|
|
30
34
|
this._rangeCalculator = rangeCalculator;
|
|
31
35
|
this._startDateCalculator = startDateCalculator;
|
|
32
36
|
this._descriptionCalculator = descriptionCalculator;
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
/**
|
|
40
|
+
* If true, only one summary, of the given type, can exist for a
|
|
41
|
+
* position. If false, multiple summaries, of the given type, can
|
|
42
|
+
* exist for a position.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
* @return {Boolean}
|
|
46
|
+
*/
|
|
47
|
+
get unique() {
|
|
48
|
+
return this._unique;
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
/**
|
|
36
52
|
* Returns a human-readable description of the frame, given
|
|
37
53
|
* start and end dates.
|
|
@@ -129,10 +145,10 @@ module.exports = (() => {
|
|
|
129
145
|
}
|
|
130
146
|
}
|
|
131
147
|
|
|
132
|
-
const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
|
|
133
|
-
const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
|
|
134
|
-
const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
|
|
135
|
-
const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
|
|
148
|
+
const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
|
|
149
|
+
const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
|
|
150
|
+
const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
|
|
151
|
+
const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
|
|
136
152
|
|
|
137
153
|
/**
|
|
138
154
|
* The start and and date for a {@link PositionSummaryFrame}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const assert = require('@barchart/common-js/lang/assert')
|
|
1
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
array = require('@barchart/common-js/lang/array')
|
|
2
3
|
|
|
3
4
|
const InstrumentType = require('./InstrumentType'),
|
|
4
5
|
PositionDirection = require('./PositionDirection'),
|
|
@@ -17,6 +18,31 @@ module.exports = (() => {
|
|
|
17
18
|
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Given a set of transaction, ensures that sequence numbers and dates
|
|
23
|
+
* are properly ordered.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
* @static
|
|
27
|
+
* @param {Array.<Object>} transactions
|
|
28
|
+
* @param {Boolean=} partial - If true, sequence validation starts with the array's first transaction.
|
|
29
|
+
* @return {boolean}
|
|
30
|
+
*/
|
|
31
|
+
static validateOrder(transactions, partial) {
|
|
32
|
+
assert.argumentIsArray(transactions, 'transactions');
|
|
33
|
+
assert.argumentIsOptional(partial, 'partial', Boolean);
|
|
34
|
+
|
|
35
|
+
let startSequence;
|
|
36
|
+
|
|
37
|
+
if (partial && transactions.length !== 0) {
|
|
38
|
+
startSequence = array.first(transactions).sequence;
|
|
39
|
+
} else {
|
|
40
|
+
startSequence = 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return transactions.every((t, i) => t.sequence === (i + startSequence) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
|
|
44
|
+
}
|
|
45
|
+
|
|
20
46
|
/**
|
|
21
47
|
* Given an instrument type, returns all valid transaction types.
|
|
22
48
|
*
|
|
@@ -123,7 +123,7 @@ module.exports = (() => {
|
|
|
123
123
|
|
|
124
124
|
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
125
125
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
126
|
-
symbols.push(`^${
|
|
126
|
+
symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
return symbols;
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -185,7 +185,137 @@ module.exports = (() => {
|
|
|
185
185
|
return InstrumentType;
|
|
186
186
|
})();
|
|
187
187
|
|
|
188
|
-
},{"@barchart/common-js/lang/Enum":
|
|
188
|
+
},{"@barchart/common-js/lang/Enum":21,"@barchart/common-js/lang/assert":24,"uuid":30}],2:[function(require,module,exports){
|
|
189
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
190
|
+
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
191
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
192
|
+
|
|
193
|
+
module.exports = (() => {
|
|
194
|
+
'use strict';
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Describes a position size -- positive values are long, negative values
|
|
198
|
+
* are short and zero values are even.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
* @extends {Enum}
|
|
202
|
+
* @param {String} code
|
|
203
|
+
* @param {String} description
|
|
204
|
+
* @param {sign} sign
|
|
205
|
+
*/
|
|
206
|
+
class PositionDirection extends Enum {
|
|
207
|
+
constructor(code, description, sign) {
|
|
208
|
+
super(code, description);
|
|
209
|
+
|
|
210
|
+
assert.argumentIsRequired(sign, 'sign', String);
|
|
211
|
+
|
|
212
|
+
this._sign = sign;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A description of the positiveness or negativeness of the size of the
|
|
217
|
+
* position.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
* @returns {String}
|
|
221
|
+
*/
|
|
222
|
+
get sign() {
|
|
223
|
+
return this._sign;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Indicates if the position size is positive (i.e. is {@link PositionDirection.LONG}).
|
|
228
|
+
*
|
|
229
|
+
* @public
|
|
230
|
+
* @returns {boolean}
|
|
231
|
+
*/
|
|
232
|
+
get positive() {
|
|
233
|
+
return this === long;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Indicates if the position size is negative (i.e. is {@link PositionDirection.SHORT}).
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
* @returns {boolean}
|
|
241
|
+
*/
|
|
242
|
+
get negative() {
|
|
243
|
+
return this === short;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Indicates if the position size is zero (i.e. is {@link PositionDirection.EVEN}).
|
|
248
|
+
*
|
|
249
|
+
* @public
|
|
250
|
+
* @returns {boolean}
|
|
251
|
+
*/
|
|
252
|
+
get closed() {
|
|
253
|
+
return this === even;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A positive quantity position.
|
|
258
|
+
*
|
|
259
|
+
* @public
|
|
260
|
+
* @static
|
|
261
|
+
* @returns {PositionDirection}
|
|
262
|
+
*/
|
|
263
|
+
static get LONG() {
|
|
264
|
+
return long;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A positive quantity position.
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
* @static
|
|
272
|
+
* @returns {PositionDirection}
|
|
273
|
+
*/
|
|
274
|
+
static get SHORT() {
|
|
275
|
+
return short;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A zero quantity position.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
* @static
|
|
283
|
+
* @returns {PositionDirection}
|
|
284
|
+
*/
|
|
285
|
+
static get EVEN() {
|
|
286
|
+
return even;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Given an open quantity, returns a {@link PositionDirection} that
|
|
291
|
+
* describes the quantity.
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
* @static
|
|
295
|
+
* @param {Decimal} open
|
|
296
|
+
* @returns {PositionDirection}
|
|
297
|
+
*/
|
|
298
|
+
static for(open) {
|
|
299
|
+
assert.argumentIsRequired(open, 'open', Decimal, 'Decimal');
|
|
300
|
+
|
|
301
|
+
if (open.getIsPositive()) {
|
|
302
|
+
return long;
|
|
303
|
+
} else if (open.getIsNegative()) {
|
|
304
|
+
return short;
|
|
305
|
+
} else {
|
|
306
|
+
return even;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const long = new PositionDirection('LONG', 'Long', 'positive');
|
|
312
|
+
const short = new PositionDirection('SHORT', 'Short', 'negative');
|
|
313
|
+
const even = new PositionDirection('EVEN', 'Even', 'zero');
|
|
314
|
+
|
|
315
|
+
return PositionDirection;
|
|
316
|
+
})();
|
|
317
|
+
|
|
318
|
+
},{"@barchart/common-js/lang/Decimal":19,"@barchart/common-js/lang/Enum":21,"@barchart/common-js/lang/assert":24}],3:[function(require,module,exports){
|
|
189
319
|
const array = require('@barchart/common-js/lang/array'),
|
|
190
320
|
assert = require('@barchart/common-js/lang/assert'),
|
|
191
321
|
Day = require('@barchart/common-js/lang/Day'),
|
|
@@ -208,18 +338,34 @@ module.exports = (() => {
|
|
|
208
338
|
* @param {Function} descriptionCalculator
|
|
209
339
|
*/
|
|
210
340
|
class PositionSummaryFrame extends Enum {
|
|
211
|
-
constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
|
|
341
|
+
constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
|
|
212
342
|
super(code, description);
|
|
213
343
|
|
|
344
|
+
assert.argumentIsRequired(unique, 'unique', Boolean);
|
|
345
|
+
|
|
214
346
|
assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
|
|
215
347
|
assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
|
|
216
348
|
assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
|
|
217
349
|
|
|
350
|
+
this._unique = unique;
|
|
351
|
+
|
|
218
352
|
this._rangeCalculator = rangeCalculator;
|
|
219
353
|
this._startDateCalculator = startDateCalculator;
|
|
220
354
|
this._descriptionCalculator = descriptionCalculator;
|
|
221
355
|
}
|
|
222
356
|
|
|
357
|
+
/**
|
|
358
|
+
* If true, only one summary, of the given type, can exist for a
|
|
359
|
+
* position. If false, multiple summaries, of the given type, can
|
|
360
|
+
* exist for a position.
|
|
361
|
+
*
|
|
362
|
+
* @public
|
|
363
|
+
* @return {Boolean}
|
|
364
|
+
*/
|
|
365
|
+
get unique() {
|
|
366
|
+
return this._unique;
|
|
367
|
+
}
|
|
368
|
+
|
|
223
369
|
/**
|
|
224
370
|
* Returns a human-readable description of the frame, given
|
|
225
371
|
* start and end dates.
|
|
@@ -317,10 +463,10 @@ module.exports = (() => {
|
|
|
317
463
|
}
|
|
318
464
|
}
|
|
319
465
|
|
|
320
|
-
const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
|
|
321
|
-
const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
|
|
322
|
-
const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
|
|
323
|
-
const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
|
|
466
|
+
const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
|
|
467
|
+
const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
|
|
468
|
+
const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
|
|
469
|
+
const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
|
|
324
470
|
|
|
325
471
|
/**
|
|
326
472
|
* The start and and date for a {@link PositionSummaryFrame}
|
|
@@ -442,7 +588,7 @@ module.exports = (() => {
|
|
|
442
588
|
return PositionSummaryFrame;
|
|
443
589
|
})();
|
|
444
590
|
|
|
445
|
-
},{"@barchart/common-js/lang/Day":
|
|
591
|
+
},{"@barchart/common-js/lang/Day":18,"@barchart/common-js/lang/Decimal":19,"@barchart/common-js/lang/Enum":21,"@barchart/common-js/lang/array":23,"@barchart/common-js/lang/assert":24,"@barchart/common-js/lang/is":26}],4:[function(require,module,exports){
|
|
446
592
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
447
593
|
Enum = require('@barchart/common-js/lang/Enum');
|
|
448
594
|
|
|
@@ -809,7 +955,205 @@ module.exports = (() => {
|
|
|
809
955
|
return TransactionType;
|
|
810
956
|
})();
|
|
811
957
|
|
|
812
|
-
},{"@barchart/common-js/lang/Enum":
|
|
958
|
+
},{"@barchart/common-js/lang/Enum":21,"@barchart/common-js/lang/assert":24}],5:[function(require,module,exports){
|
|
959
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
960
|
+
array = require('@barchart/common-js/lang/array')
|
|
961
|
+
|
|
962
|
+
const InstrumentType = require('./InstrumentType'),
|
|
963
|
+
PositionDirection = require('./PositionDirection'),
|
|
964
|
+
TransactionType = require('./TransactionType');
|
|
965
|
+
|
|
966
|
+
module.exports = (() => {
|
|
967
|
+
'use strict';
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Static utilities for validating transactions.
|
|
971
|
+
*
|
|
972
|
+
* @public
|
|
973
|
+
*/
|
|
974
|
+
class TransactionValidator {
|
|
975
|
+
constructor() {
|
|
976
|
+
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Given a set of transaction, ensures that sequence numbers and dates
|
|
981
|
+
* are properly ordered.
|
|
982
|
+
*
|
|
983
|
+
* @public
|
|
984
|
+
* @static
|
|
985
|
+
* @param {Array.<Object>} transactions
|
|
986
|
+
* @param {Boolean=} partial - If true, sequence validation starts with the array's first transaction.
|
|
987
|
+
* @return {boolean}
|
|
988
|
+
*/
|
|
989
|
+
static validateOrder(transactions, partial) {
|
|
990
|
+
assert.argumentIsArray(transactions, 'transactions');
|
|
991
|
+
assert.argumentIsOptional(partial, 'partial', Boolean);
|
|
992
|
+
|
|
993
|
+
let startSequence;
|
|
994
|
+
|
|
995
|
+
if (partial && transactions.length !== 0) {
|
|
996
|
+
startSequence = array.first(transactions).sequence;
|
|
997
|
+
} else {
|
|
998
|
+
startSequence = 1;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
return transactions.every((t, i) => t.sequence === (i + startSequence) && (i === 0 || !t.date.getIsBefore(transactions[i - 1].date)));
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Given an instrument type, returns all valid transaction types.
|
|
1006
|
+
*
|
|
1007
|
+
* @static
|
|
1008
|
+
* @public
|
|
1009
|
+
* @param {InstrumentType} instrumentType
|
|
1010
|
+
* @param {Boolean=} userInitiated
|
|
1011
|
+
* @pararm {PositionDirection=} currentDirection
|
|
1012
|
+
* @return {Array.<TransactionType>}
|
|
1013
|
+
*/
|
|
1014
|
+
static getTransactionTypesFor(instrumentType, userInitiated, currentDirection) {
|
|
1015
|
+
assert.argumentIsRequired(instrumentType, 'instrumentType', InstrumentType, 'InstrumentType');
|
|
1016
|
+
assert.argumentIsOptional(userInitiated, 'userInitiated', Boolean);
|
|
1017
|
+
|
|
1018
|
+
let valid = validTransactionTypes[instrumentType.code] || [ ];
|
|
1019
|
+
|
|
1020
|
+
if (userInitiated) {
|
|
1021
|
+
valid = valid.filter(data => data.user === userInitiated);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
if (currentDirection) {
|
|
1025
|
+
valid = valid.filter(data => data.directions.some(d => d === currentDirection));
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
return valid.map(d => d.type);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Checks to see if an transaction type is applicable to an instrument type.
|
|
1033
|
+
*
|
|
1034
|
+
* @static
|
|
1035
|
+
* @public
|
|
1036
|
+
* @param {InstrumentType} instrumentType
|
|
1037
|
+
* @param {TransactionType} transactionType
|
|
1038
|
+
* @param {Boolean=} userInitiated
|
|
1039
|
+
* @return {Boolean}
|
|
1040
|
+
*/
|
|
1041
|
+
static validateTransactionType(instrumentType, transactionType, userInitiated) {
|
|
1042
|
+
assert.argumentIsRequired(transactionType, 'transactionType', TransactionType, 'TransactionType');
|
|
1043
|
+
|
|
1044
|
+
const transactionTypes = TransactionValidator.getTransactionTypesFor(instrumentType, userInitiated);
|
|
1045
|
+
|
|
1046
|
+
return transactionTypes.some(t => t === transactionType);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Checks to see if a position for a given instrument type can exist in
|
|
1051
|
+
* the given direction.
|
|
1052
|
+
*
|
|
1053
|
+
* @static
|
|
1054
|
+
* @public
|
|
1055
|
+
* @param {InstrumentType} instrumentType
|
|
1056
|
+
* @param {PositionDirection} direction
|
|
1057
|
+
* @return {Boolean}
|
|
1058
|
+
*/
|
|
1059
|
+
static validateDirection(instrumentType, direction) {
|
|
1060
|
+
assert.argumentIsRequired(instrumentType, 'instrumentType', InstrumentType, 'InstrumentType');
|
|
1061
|
+
assert.argumentIsRequired(direction, 'direction', PositionDirection, 'PositionDirection');
|
|
1062
|
+
|
|
1063
|
+
return validDirections[instrumentType.code].some(d => d === direction);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Checks to see if the position switches direction and if the direction switch
|
|
1068
|
+
* is valid.
|
|
1069
|
+
*
|
|
1070
|
+
* @static
|
|
1071
|
+
* @public
|
|
1072
|
+
* @param {InstrumentType} instrumentType
|
|
1073
|
+
* @param {PositionDirection|null|undefined} currentDirection
|
|
1074
|
+
* @param {PositionDirection} proposedDirection
|
|
1075
|
+
* @return {Boolean}
|
|
1076
|
+
*/
|
|
1077
|
+
static validateDirectionSwitch(instrumentType, currentDirection, proposedDirection) {
|
|
1078
|
+
return currentDirection === null || instrumentType.canSwitchDirection || (currentDirection.closed || proposedDirection.closed || currentDirection.positive === proposedDirection.positive);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
toString() {
|
|
1082
|
+
return '[TransactionValidator]';
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const validTransactionTypes = { };
|
|
1087
|
+
|
|
1088
|
+
function associateTypes(instrumentType, transactionType, userInitiated, directions) {
|
|
1089
|
+
const instrumentTypeCode = instrumentType.code;
|
|
1090
|
+
|
|
1091
|
+
if (!validTransactionTypes.hasOwnProperty(instrumentTypeCode)) {
|
|
1092
|
+
validTransactionTypes[instrumentTypeCode] = [ ];
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
validTransactionTypes[instrumentTypeCode].push({ type: transactionType, user: userInitiated, directions: directions || [ PositionDirection.LONG, PositionDirection.SHORT, PositionDirection.EVEN ] });
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
|
|
1099
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.SELL, true, [ PositionDirection.LONG ]);
|
|
1100
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.SELL_SHORT, true, [ PositionDirection.SHORT, PositionDirection.EVEN ]);
|
|
1101
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.BUY_SHORT, true, [ PositionDirection.SHORT ]);
|
|
1102
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.FEE, true, [ PositionDirection.LONG, PositionDirection.SHORT ]);
|
|
1103
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND, false);
|
|
1104
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_REINVEST, false);
|
|
1105
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_STOCK, false);
|
|
1106
|
+
associateTypes(InstrumentType.EQUITY, TransactionType.SPLIT, false);
|
|
1107
|
+
|
|
1108
|
+
associateTypes(InstrumentType.FUND, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
|
|
1109
|
+
associateTypes(InstrumentType.FUND, TransactionType.SELL, true, [ PositionDirection.LONG ]);
|
|
1110
|
+
associateTypes(InstrumentType.FUND, TransactionType.FEE, true, [ PositionDirection.LONG ]);
|
|
1111
|
+
associateTypes(InstrumentType.FUND, TransactionType.FEE_UNITS, false);
|
|
1112
|
+
associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_CASH, false);
|
|
1113
|
+
associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_FUND, false);
|
|
1114
|
+
|
|
1115
|
+
associateTypes(InstrumentType.OTHER, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
|
|
1116
|
+
associateTypes(InstrumentType.OTHER, TransactionType.SELL, true, [ PositionDirection.LONG ]);
|
|
1117
|
+
associateTypes(InstrumentType.OTHER, TransactionType.INCOME, true, [ PositionDirection.LONG ]);
|
|
1118
|
+
associateTypes(InstrumentType.OTHER, TransactionType.FEE, true, [ PositionDirection.LONG ]);
|
|
1119
|
+
associateTypes(InstrumentType.OTHER, TransactionType.VALUATION, true, [ PositionDirection.LONG ]);
|
|
1120
|
+
|
|
1121
|
+
associateTypes(InstrumentType.CASH, TransactionType.DEPOSIT, true);
|
|
1122
|
+
associateTypes(InstrumentType.CASH, TransactionType.WITHDRAWAL, true);
|
|
1123
|
+
associateTypes(InstrumentType.CASH, TransactionType.FEE, true);
|
|
1124
|
+
associateTypes(InstrumentType.CASH, TransactionType.DEBIT, false);
|
|
1125
|
+
associateTypes(InstrumentType.CASH, TransactionType.CREDIT, false);
|
|
1126
|
+
|
|
1127
|
+
const validDirections = { };
|
|
1128
|
+
|
|
1129
|
+
function associateDirections(instrumentType, positionDirection) {
|
|
1130
|
+
const instrumentTypeCode = instrumentType.code;
|
|
1131
|
+
|
|
1132
|
+
if (!validDirections.hasOwnProperty(instrumentTypeCode)) {
|
|
1133
|
+
validDirections[instrumentTypeCode] = [ ];
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
validDirections[instrumentTypeCode].push(positionDirection);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
associateDirections(InstrumentType.EQUITY, PositionDirection.EVEN);
|
|
1140
|
+
associateDirections(InstrumentType.EQUITY, PositionDirection.LONG);
|
|
1141
|
+
associateDirections(InstrumentType.EQUITY, PositionDirection.SHORT);
|
|
1142
|
+
|
|
1143
|
+
associateDirections(InstrumentType.FUND, PositionDirection.EVEN);
|
|
1144
|
+
associateDirections(InstrumentType.FUND, PositionDirection.LONG);
|
|
1145
|
+
|
|
1146
|
+
associateDirections(InstrumentType.OTHER, PositionDirection.EVEN);
|
|
1147
|
+
associateDirections(InstrumentType.OTHER, PositionDirection.LONG);
|
|
1148
|
+
|
|
1149
|
+
associateDirections(InstrumentType.CASH, PositionDirection.EVEN);
|
|
1150
|
+
associateDirections(InstrumentType.CASH, PositionDirection.LONG);
|
|
1151
|
+
associateDirections(InstrumentType.CASH, PositionDirection.SHORT);
|
|
1152
|
+
|
|
1153
|
+
return TransactionValidator;
|
|
1154
|
+
})();
|
|
1155
|
+
|
|
1156
|
+
},{"./InstrumentType":1,"./PositionDirection":2,"./TransactionType":4,"@barchart/common-js/lang/array":23,"@barchart/common-js/lang/assert":24}],6:[function(require,module,exports){
|
|
813
1157
|
const array = require('@barchart/common-js/lang/array'),
|
|
814
1158
|
assert = require('@barchart/common-js/lang/assert'),
|
|
815
1159
|
ComparatorBuilder = require('@barchart/common-js/collections/sorting/ComparatorBuilder'),
|
|
@@ -935,7 +1279,7 @@ module.exports = (() => {
|
|
|
935
1279
|
|
|
936
1280
|
this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
|
|
937
1281
|
if (code !== DEFAULT_CURRENCY.code) {
|
|
938
|
-
symbols.push(`^${
|
|
1282
|
+
symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
|
|
939
1283
|
}
|
|
940
1284
|
|
|
941
1285
|
return symbols;
|
|
@@ -1767,7 +2111,7 @@ module.exports = (() => {
|
|
|
1767
2111
|
return PositionContainer;
|
|
1768
2112
|
})();
|
|
1769
2113
|
|
|
1770
|
-
},{"./../data/PositionSummaryFrame":
|
|
2114
|
+
},{"./../data/PositionSummaryFrame":3,"./PositionGroup":7,"./PositionItem":8,"./definitions/PositionLevelDefinition":9,"./definitions/PositionLevelType":10,"./definitions/PositionTreeDefinition":11,"@barchart/common-js/collections/Tree":13,"@barchart/common-js/collections/sorting/ComparatorBuilder":14,"@barchart/common-js/collections/sorting/comparators":15,"@barchart/common-js/collections/specialized/DisposableStack":16,"@barchart/common-js/lang/Currency":17,"@barchart/common-js/lang/Decimal":19,"@barchart/common-js/lang/Rate":22,"@barchart/common-js/lang/array":23,"@barchart/common-js/lang/assert":24,"@barchart/common-js/lang/is":26,"@barchart/common-js/messaging/Event":28}],7:[function(require,module,exports){
|
|
1771
2115
|
const array = require('@barchart/common-js/lang/array'),
|
|
1772
2116
|
assert = require('@barchart/common-js/lang/assert'),
|
|
1773
2117
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
@@ -2577,6 +2921,8 @@ module.exports = (() => {
|
|
|
2577
2921
|
}
|
|
2578
2922
|
|
|
2579
2923
|
function calculateMarketPercent(group, rates, silent) {
|
|
2924
|
+
return;
|
|
2925
|
+
|
|
2580
2926
|
if (group.suspended) {
|
|
2581
2927
|
return;
|
|
2582
2928
|
}
|
|
@@ -2642,7 +2988,7 @@ module.exports = (() => {
|
|
|
2642
2988
|
return PositionGroup;
|
|
2643
2989
|
})();
|
|
2644
2990
|
|
|
2645
|
-
},{"./../data/InstrumentType":1,"./definitions/PositionLevelDefinition":
|
|
2991
|
+
},{"./../data/InstrumentType":1,"./definitions/PositionLevelDefinition":9,"./definitions/PositionLevelType":10,"@barchart/common-js/collections/specialized/DisposableStack":16,"@barchart/common-js/lang/Currency":17,"@barchart/common-js/lang/Decimal":19,"@barchart/common-js/lang/Disposable":20,"@barchart/common-js/lang/Rate":22,"@barchart/common-js/lang/array":23,"@barchart/common-js/lang/assert":24,"@barchart/common-js/lang/formatter":25,"@barchart/common-js/lang/is":26,"@barchart/common-js/messaging/Event":28}],8:[function(require,module,exports){
|
|
2646
2992
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
2647
2993
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
2648
2994
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
@@ -3102,7 +3448,7 @@ module.exports = (() => {
|
|
|
3102
3448
|
return PositionItem;
|
|
3103
3449
|
})();
|
|
3104
3450
|
|
|
3105
|
-
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":
|
|
3451
|
+
},{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":17,"@barchart/common-js/lang/Decimal":19,"@barchart/common-js/lang/Disposable":20,"@barchart/common-js/lang/assert":24,"@barchart/common-js/lang/is":26,"@barchart/common-js/messaging/Event":28}],9:[function(require,module,exports){
|
|
3106
3452
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
3107
3453
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
3108
3454
|
is = require('@barchart/common-js/lang/is');
|
|
@@ -3381,7 +3727,7 @@ module.exports = (() => {
|
|
|
3381
3727
|
return PositionLevelDefinition;
|
|
3382
3728
|
})();
|
|
3383
3729
|
|
|
3384
|
-
},{"./../../data/InstrumentType":1,"./PositionLevelType":
|
|
3730
|
+
},{"./../../data/InstrumentType":1,"./PositionLevelType":10,"@barchart/common-js/lang/Currency":17,"@barchart/common-js/lang/assert":24,"@barchart/common-js/lang/is":26}],10:[function(require,module,exports){
|
|
3385
3731
|
const Enum = require('@barchart/common-js/lang/Enum');
|
|
3386
3732
|
|
|
3387
3733
|
module.exports = (() => {
|
|
@@ -3412,7 +3758,7 @@ module.exports = (() => {
|
|
|
3412
3758
|
return PositionLevelType;
|
|
3413
3759
|
})();
|
|
3414
3760
|
|
|
3415
|
-
},{"@barchart/common-js/lang/Enum":
|
|
3761
|
+
},{"@barchart/common-js/lang/Enum":21}],11:[function(require,module,exports){
|
|
3416
3762
|
const assert = require('@barchart/common-js/lang/assert');
|
|
3417
3763
|
|
|
3418
3764
|
const PositionLevelDefinition = require('./PositionLevelDefinition');
|
|
@@ -3483,7 +3829,7 @@ module.exports = (() => {
|
|
|
3483
3829
|
return PositionTreeDefinitions;
|
|
3484
3830
|
})();
|
|
3485
3831
|
|
|
3486
|
-
},{"./PositionLevelDefinition":
|
|
3832
|
+
},{"./PositionLevelDefinition":9,"@barchart/common-js/lang/assert":24}],12:[function(require,module,exports){
|
|
3487
3833
|
'use strict';
|
|
3488
3834
|
|
|
3489
3835
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -3615,7 +3961,7 @@ module.exports = function () {
|
|
|
3615
3961
|
return Stack;
|
|
3616
3962
|
}();
|
|
3617
3963
|
|
|
3618
|
-
},{"./../lang/assert":
|
|
3964
|
+
},{"./../lang/assert":24}],13:[function(require,module,exports){
|
|
3619
3965
|
'use strict';
|
|
3620
3966
|
|
|
3621
3967
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -3985,7 +4331,7 @@ module.exports = function () {
|
|
|
3985
4331
|
return Tree;
|
|
3986
4332
|
}();
|
|
3987
4333
|
|
|
3988
|
-
},{"./../lang/is":
|
|
4334
|
+
},{"./../lang/is":26}],14:[function(require,module,exports){
|
|
3989
4335
|
'use strict';
|
|
3990
4336
|
|
|
3991
4337
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -4129,7 +4475,7 @@ module.exports = function () {
|
|
|
4129
4475
|
return ComparatorBuilder;
|
|
4130
4476
|
}();
|
|
4131
4477
|
|
|
4132
|
-
},{"./../../lang/assert":
|
|
4478
|
+
},{"./../../lang/assert":24,"./comparators":15}],15:[function(require,module,exports){
|
|
4133
4479
|
'use strict';
|
|
4134
4480
|
|
|
4135
4481
|
var assert = require('./../../lang/assert');
|
|
@@ -4204,7 +4550,7 @@ module.exports = function () {
|
|
|
4204
4550
|
};
|
|
4205
4551
|
}();
|
|
4206
4552
|
|
|
4207
|
-
},{"./../../lang/assert":
|
|
4553
|
+
},{"./../../lang/assert":24}],16:[function(require,module,exports){
|
|
4208
4554
|
'use strict';
|
|
4209
4555
|
|
|
4210
4556
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -4312,7 +4658,7 @@ module.exports = function () {
|
|
|
4312
4658
|
return DisposableStack;
|
|
4313
4659
|
}();
|
|
4314
4660
|
|
|
4315
|
-
},{"./../../lang/Disposable":
|
|
4661
|
+
},{"./../../lang/Disposable":20,"./../../lang/assert":24,"./../../lang/is":26,"./../Stack":12}],17:[function(require,module,exports){
|
|
4316
4662
|
'use strict';
|
|
4317
4663
|
|
|
4318
4664
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -4455,7 +4801,7 @@ module.exports = function () {
|
|
|
4455
4801
|
return Currency;
|
|
4456
4802
|
}();
|
|
4457
4803
|
|
|
4458
|
-
},{"./Enum":
|
|
4804
|
+
},{"./Enum":21,"./assert":24,"./is":26}],18:[function(require,module,exports){
|
|
4459
4805
|
'use strict';
|
|
4460
4806
|
|
|
4461
4807
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -5008,7 +5354,7 @@ module.exports = function () {
|
|
|
5008
5354
|
return Day;
|
|
5009
5355
|
}();
|
|
5010
5356
|
|
|
5011
|
-
},{"./../collections/sorting/ComparatorBuilder":
|
|
5357
|
+
},{"./../collections/sorting/ComparatorBuilder":14,"./../collections/sorting/comparators":15,"./assert":24,"./is":26}],19:[function(require,module,exports){
|
|
5012
5358
|
'use strict';
|
|
5013
5359
|
|
|
5014
5360
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -5616,7 +5962,7 @@ module.exports = function () {
|
|
|
5616
5962
|
return Decimal;
|
|
5617
5963
|
}();
|
|
5618
5964
|
|
|
5619
|
-
},{"./Enum":
|
|
5965
|
+
},{"./Enum":21,"./assert":24,"./is":26,"big.js":29}],20:[function(require,module,exports){
|
|
5620
5966
|
'use strict';
|
|
5621
5967
|
|
|
5622
5968
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -5765,7 +6111,7 @@ module.exports = function () {
|
|
|
5765
6111
|
return Disposable;
|
|
5766
6112
|
}();
|
|
5767
6113
|
|
|
5768
|
-
},{"./assert":
|
|
6114
|
+
},{"./assert":24}],21:[function(require,module,exports){
|
|
5769
6115
|
'use strict';
|
|
5770
6116
|
|
|
5771
6117
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -5907,7 +6253,7 @@ module.exports = function () {
|
|
|
5907
6253
|
return Enum;
|
|
5908
6254
|
}();
|
|
5909
6255
|
|
|
5910
|
-
},{"./assert":
|
|
6256
|
+
},{"./assert":24}],22:[function(require,module,exports){
|
|
5911
6257
|
'use strict';
|
|
5912
6258
|
|
|
5913
6259
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -6162,7 +6508,7 @@ module.exports = function () {
|
|
|
6162
6508
|
return Rate;
|
|
6163
6509
|
}();
|
|
6164
6510
|
|
|
6165
|
-
},{"./Currency":
|
|
6511
|
+
},{"./Currency":17,"./Decimal":19,"./assert":24,"./memoize":27}],23:[function(require,module,exports){
|
|
6166
6512
|
'use strict';
|
|
6167
6513
|
|
|
6168
6514
|
var assert = require('./assert'),
|
|
@@ -6563,7 +6909,7 @@ module.exports = function () {
|
|
|
6563
6909
|
};
|
|
6564
6910
|
}();
|
|
6565
6911
|
|
|
6566
|
-
},{"./assert":
|
|
6912
|
+
},{"./assert":24,"./is":26}],24:[function(require,module,exports){
|
|
6567
6913
|
'use strict';
|
|
6568
6914
|
|
|
6569
6915
|
var is = require('./is');
|
|
@@ -6711,7 +7057,7 @@ module.exports = function () {
|
|
|
6711
7057
|
};
|
|
6712
7058
|
}();
|
|
6713
7059
|
|
|
6714
|
-
},{"./is":
|
|
7060
|
+
},{"./is":26}],25:[function(require,module,exports){
|
|
6715
7061
|
'use strict';
|
|
6716
7062
|
|
|
6717
7063
|
module.exports = function () {
|
|
@@ -6776,7 +7122,7 @@ module.exports = function () {
|
|
|
6776
7122
|
};
|
|
6777
7123
|
}();
|
|
6778
7124
|
|
|
6779
|
-
},{}],
|
|
7125
|
+
},{}],26:[function(require,module,exports){
|
|
6780
7126
|
'use strict';
|
|
6781
7127
|
|
|
6782
7128
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
@@ -6999,7 +7345,7 @@ module.exports = function () {
|
|
|
6999
7345
|
};
|
|
7000
7346
|
}();
|
|
7001
7347
|
|
|
7002
|
-
},{}],
|
|
7348
|
+
},{}],27:[function(require,module,exports){
|
|
7003
7349
|
'use strict';
|
|
7004
7350
|
|
|
7005
7351
|
var assert = require('./assert'),
|
|
@@ -7072,7 +7418,7 @@ module.exports = function () {
|
|
|
7072
7418
|
};
|
|
7073
7419
|
}();
|
|
7074
7420
|
|
|
7075
|
-
},{"./assert":
|
|
7421
|
+
},{"./assert":24,"./is":26}],28:[function(require,module,exports){
|
|
7076
7422
|
'use strict';
|
|
7077
7423
|
|
|
7078
7424
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -7244,7 +7590,7 @@ module.exports = function () {
|
|
|
7244
7590
|
return Event;
|
|
7245
7591
|
}();
|
|
7246
7592
|
|
|
7247
|
-
},{"./../lang/Disposable":
|
|
7593
|
+
},{"./../lang/Disposable":20,"./../lang/assert":24}],29:[function(require,module,exports){
|
|
7248
7594
|
/*
|
|
7249
7595
|
* big.js v5.0.3
|
|
7250
7596
|
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
|
|
@@ -8185,7 +8531,7 @@ module.exports = function () {
|
|
|
8185
8531
|
}
|
|
8186
8532
|
})(this);
|
|
8187
8533
|
|
|
8188
|
-
},{}],
|
|
8534
|
+
},{}],30:[function(require,module,exports){
|
|
8189
8535
|
var v1 = require('./v1');
|
|
8190
8536
|
var v4 = require('./v4');
|
|
8191
8537
|
|
|
@@ -8195,7 +8541,7 @@ uuid.v4 = v4;
|
|
|
8195
8541
|
|
|
8196
8542
|
module.exports = uuid;
|
|
8197
8543
|
|
|
8198
|
-
},{"./v1":
|
|
8544
|
+
},{"./v1":33,"./v4":34}],31:[function(require,module,exports){
|
|
8199
8545
|
/**
|
|
8200
8546
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
8201
8547
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
@@ -8220,7 +8566,7 @@ function bytesToUuid(buf, offset) {
|
|
|
8220
8566
|
|
|
8221
8567
|
module.exports = bytesToUuid;
|
|
8222
8568
|
|
|
8223
|
-
},{}],
|
|
8569
|
+
},{}],32:[function(require,module,exports){
|
|
8224
8570
|
(function (global){
|
|
8225
8571
|
// Unique ID creation requires a high quality random # generator. In the
|
|
8226
8572
|
// browser this is a little complicated due to unknown quality of Math.random()
|
|
@@ -8257,7 +8603,7 @@ if (!rng) {
|
|
|
8257
8603
|
module.exports = rng;
|
|
8258
8604
|
|
|
8259
8605
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
8260
|
-
},{}],
|
|
8606
|
+
},{}],33:[function(require,module,exports){
|
|
8261
8607
|
var rng = require('./lib/rng');
|
|
8262
8608
|
var bytesToUuid = require('./lib/bytesToUuid');
|
|
8263
8609
|
|
|
@@ -8359,7 +8705,7 @@ function v1(options, buf, offset) {
|
|
|
8359
8705
|
|
|
8360
8706
|
module.exports = v1;
|
|
8361
8707
|
|
|
8362
|
-
},{"./lib/bytesToUuid":
|
|
8708
|
+
},{"./lib/bytesToUuid":31,"./lib/rng":32}],34:[function(require,module,exports){
|
|
8363
8709
|
var rng = require('./lib/rng');
|
|
8364
8710
|
var bytesToUuid = require('./lib/bytesToUuid');
|
|
8365
8711
|
|
|
@@ -8390,7 +8736,7 @@ function v4(options, buf, offset) {
|
|
|
8390
8736
|
|
|
8391
8737
|
module.exports = v4;
|
|
8392
8738
|
|
|
8393
|
-
},{"./lib/bytesToUuid":
|
|
8739
|
+
},{"./lib/bytesToUuid":31,"./lib/rng":32}],35:[function(require,module,exports){
|
|
8394
8740
|
const Day = require('@barchart/common-js/lang/Day'),
|
|
8395
8741
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
8396
8742
|
|
|
@@ -8561,7 +8907,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
8561
8907
|
});
|
|
8562
8908
|
});
|
|
8563
8909
|
|
|
8564
|
-
describe('and yearly position summary ranges are processed for a transaction set closed in 2016, but has after-the-
|
|
8910
|
+
describe('and yearly position summary ranges are processed for a transaction set closed in 2016, but has after-the-fact superfluous valuations in 2017 and 2018', () => {
|
|
8565
8911
|
let ranges;
|
|
8566
8912
|
|
|
8567
8913
|
beforeEach(() => {
|
|
@@ -8747,7 +9093,60 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
8747
9093
|
});
|
|
8748
9094
|
});
|
|
8749
9095
|
|
|
8750
|
-
},{"./../../../lib/data/PositionSummaryFrame":
|
|
9096
|
+
},{"./../../../lib/data/PositionSummaryFrame":3,"./../../../lib/data/TransactionType":4,"@barchart/common-js/lang/Day":18,"@barchart/common-js/lang/Decimal":19}],36:[function(require,module,exports){
|
|
9097
|
+
const Day = require('@barchart/common-js/lang/Day');
|
|
9098
|
+
|
|
9099
|
+
const TransactionValidator = require('./../../../lib/data/TransactionValidator');
|
|
9100
|
+
|
|
9101
|
+
describe('When validating transaction order', () => {
|
|
9102
|
+
'use strict';
|
|
9103
|
+
|
|
9104
|
+
const build = (sequence, day) => {
|
|
9105
|
+
return { sequence: sequence, date: Day.parse(day) };
|
|
9106
|
+
};
|
|
9107
|
+
|
|
9108
|
+
it('An array of zero transactions should be valid', () => {
|
|
9109
|
+
expect(TransactionValidator.validateOrder([])).toEqual(true);
|
|
9110
|
+
});
|
|
9111
|
+
|
|
9112
|
+
it('An array of transactions with ordered sequences, on the same day should be valid', () => {
|
|
9113
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(true);
|
|
9114
|
+
});
|
|
9115
|
+
|
|
9116
|
+
it('An array of transactions with ordered sequences, on the sequential days should be valid', () => {
|
|
9117
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-05-01'), build(3, '2018-05-02') ])).toEqual(true);
|
|
9118
|
+
});
|
|
9119
|
+
|
|
9120
|
+
it('An array of transactions with ordered sequences (starting after one), on the same day should not be valid', () => {
|
|
9121
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ])).toEqual(false);
|
|
9122
|
+
});
|
|
9123
|
+
|
|
9124
|
+
it('An array of transactions with duplicate sequences, on the same day should not be valid', () => {
|
|
9125
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(1, '2018-04-30') ])).toEqual(false);
|
|
9126
|
+
});
|
|
9127
|
+
|
|
9128
|
+
it('An array of transactions with with a gap in sequences, on the same day should not be valid', () => {
|
|
9129
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(false);
|
|
9130
|
+
});
|
|
9131
|
+
|
|
9132
|
+
it('An array of transactions with with a reversed sequences, on the same subsequent days should not be valid', () => {
|
|
9133
|
+
expect(TransactionValidator.validateOrder([ build(2, '2018-04-30'), build(1, '2018-05-01') ])).toEqual(false);
|
|
9134
|
+
});
|
|
9135
|
+
|
|
9136
|
+
it('An array of transactions with ordered sequences, on the reversed days should not be valid', () => {
|
|
9137
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-05-02'), build(2, '2018-05-01'), build(3, '2018-04-30') ])).toEqual(false);
|
|
9138
|
+
});
|
|
9139
|
+
|
|
9140
|
+
it('A partial array of transactions with ordered sequences (starting after one), on the same day should be valid', () => {
|
|
9141
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ], true)).toEqual(true);
|
|
9142
|
+
});
|
|
9143
|
+
|
|
9144
|
+
it('A partial array of transactions with gap in sequences (starting after one), on the same day should be not valid', () => {
|
|
9145
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(5, '2018-04-30'), build(6, '2018-04-30') ], true)).toEqual(false);
|
|
9146
|
+
});
|
|
9147
|
+
});
|
|
9148
|
+
|
|
9149
|
+
},{"./../../../lib/data/TransactionValidator":5,"@barchart/common-js/lang/Day":18}],37:[function(require,module,exports){
|
|
8751
9150
|
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
8752
9151
|
Decimal = require('@barchart/common-js/lang/Decimal');
|
|
8753
9152
|
|
|
@@ -8857,4 +9256,4 @@ describe('When a position container data is gathered', () => {
|
|
|
8857
9256
|
});
|
|
8858
9257
|
});
|
|
8859
9258
|
|
|
8860
|
-
},{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":
|
|
9259
|
+
},{"./../../../lib/data/InstrumentType":1,"./../../../lib/processing/PositionContainer":6,"./../../../lib/processing/definitions/PositionLevelDefinition":9,"./../../../lib/processing/definitions/PositionLevelType":10,"./../../../lib/processing/definitions/PositionTreeDefinition":11,"@barchart/common-js/lang/Currency":17,"@barchart/common-js/lang/Decimal":19}]},{},[35,36,37]);
|
|
@@ -168,7 +168,7 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
|
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
describe('and yearly position summary ranges are processed for a transaction set closed in 2016, but has after-the-
|
|
171
|
+
describe('and yearly position summary ranges are processed for a transaction set closed in 2016, but has after-the-fact superfluous valuations in 2017 and 2018', () => {
|
|
172
172
|
let ranges;
|
|
173
173
|
|
|
174
174
|
beforeEach(() => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const Day = require('@barchart/common-js/lang/Day');
|
|
2
|
+
|
|
3
|
+
const TransactionValidator = require('./../../../lib/data/TransactionValidator');
|
|
4
|
+
|
|
5
|
+
describe('When validating transaction order', () => {
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const build = (sequence, day) => {
|
|
9
|
+
return { sequence: sequence, date: Day.parse(day) };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('An array of zero transactions should be valid', () => {
|
|
13
|
+
expect(TransactionValidator.validateOrder([])).toEqual(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('An array of transactions with ordered sequences, on the same day should be valid', () => {
|
|
17
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('An array of transactions with ordered sequences, on the sequential days should be valid', () => {
|
|
21
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-05-01'), build(3, '2018-05-02') ])).toEqual(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('An array of transactions with ordered sequences (starting after one), on the same day should not be valid', () => {
|
|
25
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ])).toEqual(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('An array of transactions with duplicate sequences, on the same day should not be valid', () => {
|
|
29
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(1, '2018-04-30') ])).toEqual(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('An array of transactions with with a gap in sequences, on the same day should not be valid', () => {
|
|
33
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('An array of transactions with with a reversed sequences, on the same subsequent days should not be valid', () => {
|
|
37
|
+
expect(TransactionValidator.validateOrder([ build(2, '2018-04-30'), build(1, '2018-05-01') ])).toEqual(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('An array of transactions with ordered sequences, on the reversed days should not be valid', () => {
|
|
41
|
+
expect(TransactionValidator.validateOrder([ build(1, '2018-05-02'), build(2, '2018-05-01'), build(3, '2018-04-30') ])).toEqual(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('A partial array of transactions with ordered sequences (starting after one), on the same day should be valid', () => {
|
|
45
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(4, '2018-04-30'), build(5, '2018-04-30') ], true)).toEqual(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('A partial array of transactions with gap in sequences (starting after one), on the same day should be not valid', () => {
|
|
49
|
+
expect(TransactionValidator.validateOrder([ build(3, '2018-04-30'), build(5, '2018-04-30'), build(6, '2018-04-30') ], true)).toEqual(false);
|
|
50
|
+
});
|
|
51
|
+
});
|