@barchart/portfolio-api-common 1.2.63 → 1.2.67
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.
|
@@ -143,6 +143,17 @@ module.exports = (() => {
|
|
|
143
143
|
return transactionCreateFailedReinvestPriceUnavailable;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* The transaction failed because the position has been locked.
|
|
148
|
+
*
|
|
149
|
+
* @public
|
|
150
|
+
* @static
|
|
151
|
+
* @returns {FailureType}
|
|
152
|
+
*/
|
|
153
|
+
static get TRANSACTION_CREATE_FAILED_POSITION_LOCKED() {
|
|
154
|
+
return transactionCreateFailedPositionLocked;
|
|
155
|
+
}
|
|
156
|
+
|
|
146
157
|
/**
|
|
147
158
|
* Deleting any transaction except for the most recent requires
|
|
148
159
|
* re-writing transaction history.
|
|
@@ -219,6 +230,7 @@ module.exports = (() => {
|
|
|
219
230
|
const transactionCreateFailedInvalidInitialType = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_INITIAL_TYPE', 'Unable to process operation because the first transaction would to be a {U|transactionType.description}, which is not allowed -- since {U|transactionType.description} transactions cannot open a position.');
|
|
220
231
|
const transactionCreateFailedTypeReserved = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_RESERVED', 'Unable to create {U|type.description} transaction, this type of transaction is managed by the system.');
|
|
221
232
|
const transactionCreateFailedReinvestPriceUnavailable = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_PRICE_UNAVAILABLE', 'Unable to create transaction, a dividend was paid on {L|day}; however no historical price is available for this day. To successfully create this transaction, please turn off dividend reinvestment for this position.');
|
|
233
|
+
const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction, are being recalculated for this position (or the linked cash position). Please re-enter the transaction in a minute or two.');
|
|
222
234
|
|
|
223
235
|
const transactionDeleteFailedOutOfSequence = new FailureType('TRANSACTION_DELETE_FAILED_OUT_OF_SEQUENCE', 'Deleting any transaction, except for the most recent, will cause transaction history to be re-written. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
|
|
224
236
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
|
|
@@ -21,10 +21,11 @@ module.exports = (() => {
|
|
|
21
21
|
* @param {Boolean} hasCorporateActions
|
|
22
22
|
* @param {Boolean} closeFractional
|
|
23
23
|
* @param {Boolean} roundQuantity
|
|
24
|
+
* @param {Boolean} strictOrdering
|
|
24
25
|
* @param {Function} generator
|
|
25
26
|
*/
|
|
26
27
|
class InstrumentType extends Enum {
|
|
27
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, generator) {
|
|
28
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
|
|
28
29
|
super(code, description);
|
|
29
30
|
|
|
30
31
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -35,6 +36,7 @@ module.exports = (() => {
|
|
|
35
36
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
36
37
|
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
37
38
|
assert.argumentIsRequired(roundQuantity, 'roundQuantity', Boolean);
|
|
39
|
+
assert.argumentIsRequired(roundQuantity, 'strictOrdering', Boolean);
|
|
38
40
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
39
41
|
|
|
40
42
|
this._alternateDescription = alternateDescription;
|
|
@@ -44,7 +46,9 @@ module.exports = (() => {
|
|
|
44
46
|
this._usesSymbols = usesSymbols;
|
|
45
47
|
this._hasCorporateActions = hasCorporateActions;
|
|
46
48
|
this._closeFractional = closeFractional;
|
|
49
|
+
this._closeFractional = strictOrdering;
|
|
47
50
|
this._roundQuantity = roundQuantity;
|
|
51
|
+
this._strictOrdering = strictOrdering;
|
|
48
52
|
|
|
49
53
|
this._generator = generator;
|
|
50
54
|
}
|
|
@@ -121,6 +125,17 @@ module.exports = (() => {
|
|
|
121
125
|
return this._closeFractional;
|
|
122
126
|
}
|
|
123
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Indicates if transaction sequences must be honored before calculating position
|
|
130
|
+
* totals.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
* @returns {Boolean}
|
|
134
|
+
*/
|
|
135
|
+
get strictOrdering() {
|
|
136
|
+
return this._strictOrdering;
|
|
137
|
+
}
|
|
138
|
+
|
|
124
139
|
/**
|
|
125
140
|
* Indicates transaction quantities should be rounded.
|
|
126
141
|
*
|
|
@@ -228,10 +243,10 @@ module.exports = (() => {
|
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
245
|
|
|
231
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
232
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true,
|
|
233
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
234
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
246
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
247
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
248
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
249
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
235
250
|
|
|
236
251
|
const map = { };
|
|
237
252
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
2
|
+
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
2
3
|
Enum = require('@barchart/common-js/lang/Enum'),
|
|
3
4
|
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
4
5
|
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
@@ -63,15 +64,6 @@ module.exports = (() => {
|
|
|
63
64
|
.withField('user', DataType.STRING)
|
|
64
65
|
.withField('portfolio', DataType.STRING)
|
|
65
66
|
.withField('position', DataType.STRING)
|
|
66
|
-
|
|
67
|
-
.withField('instrument.id', DataType.STRING, true)
|
|
68
|
-
.withField('instrument.name', DataType.STRING, true)
|
|
69
|
-
.withField('instrument.type', DataType.STRING, true)
|
|
70
|
-
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
71
|
-
.withField('instrument.delist', DataType.DAY, true)
|
|
72
|
-
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
73
|
-
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
74
|
-
|
|
75
67
|
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
76
68
|
.withField('start.date', DataType.DAY)
|
|
77
69
|
.withField('start.sequence', DataType.NUMBER)
|
|
@@ -99,15 +91,6 @@ module.exports = (() => {
|
|
|
99
91
|
.withField('user', DataType.STRING)
|
|
100
92
|
.withField('portfolio', DataType.STRING)
|
|
101
93
|
.withField('position', DataType.STRING)
|
|
102
|
-
|
|
103
|
-
.withField('instrument.id', DataType.STRING, true)
|
|
104
|
-
.withField('instrument.name', DataType.STRING, true)
|
|
105
|
-
.withField('instrument.type', DataType.STRING, true)
|
|
106
|
-
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
107
|
-
.withField('instrument.delist', DataType.DAY, true)
|
|
108
|
-
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
109
|
-
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
110
|
-
|
|
111
94
|
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
112
95
|
.withField('start.date', DataType.DAY)
|
|
113
96
|
.withField('start.sequence', DataType.NUMBER)
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -22,10 +22,11 @@ module.exports = (() => {
|
|
|
22
22
|
* @param {Boolean} hasCorporateActions
|
|
23
23
|
* @param {Boolean} closeFractional
|
|
24
24
|
* @param {Boolean} roundQuantity
|
|
25
|
+
* @param {Boolean} strictOrdering
|
|
25
26
|
* @param {Function} generator
|
|
26
27
|
*/
|
|
27
28
|
class InstrumentType extends Enum {
|
|
28
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, generator) {
|
|
29
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
|
|
29
30
|
super(code, description);
|
|
30
31
|
|
|
31
32
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -36,6 +37,7 @@ module.exports = (() => {
|
|
|
36
37
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
37
38
|
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
38
39
|
assert.argumentIsRequired(roundQuantity, 'roundQuantity', Boolean);
|
|
40
|
+
assert.argumentIsRequired(roundQuantity, 'strictOrdering', Boolean);
|
|
39
41
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
40
42
|
|
|
41
43
|
this._alternateDescription = alternateDescription;
|
|
@@ -45,7 +47,9 @@ module.exports = (() => {
|
|
|
45
47
|
this._usesSymbols = usesSymbols;
|
|
46
48
|
this._hasCorporateActions = hasCorporateActions;
|
|
47
49
|
this._closeFractional = closeFractional;
|
|
50
|
+
this._closeFractional = strictOrdering;
|
|
48
51
|
this._roundQuantity = roundQuantity;
|
|
52
|
+
this._strictOrdering = strictOrdering;
|
|
49
53
|
|
|
50
54
|
this._generator = generator;
|
|
51
55
|
}
|
|
@@ -122,6 +126,17 @@ module.exports = (() => {
|
|
|
122
126
|
return this._closeFractional;
|
|
123
127
|
}
|
|
124
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Indicates if transaction sequences must be honored before calculating position
|
|
131
|
+
* totals.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @returns {Boolean}
|
|
135
|
+
*/
|
|
136
|
+
get strictOrdering() {
|
|
137
|
+
return this._strictOrdering;
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
/**
|
|
126
141
|
* Indicates transaction quantities should be rounded.
|
|
127
142
|
*
|
|
@@ -229,10 +244,10 @@ module.exports = (() => {
|
|
|
229
244
|
}
|
|
230
245
|
}
|
|
231
246
|
|
|
232
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
233
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true,
|
|
234
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
235
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
247
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
248
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
249
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
250
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
236
251
|
|
|
237
252
|
const map = { };
|
|
238
253
|
|