@barchart/portfolio-api-common 1.0.19 → 1.0.23

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.
@@ -3,6 +3,7 @@ const assert = require('@barchart/common-js/lang/assert'),
3
3
  DataType = require('@barchart/common-js/serialization/json/DataType'),
4
4
  Enum = require('@barchart/common-js/lang/Enum'),
5
5
  is = require('@barchart/common-js/lang/is'),
6
+ Schema = require('@barchart/common-js/serialization/json/Schema'),
6
7
  SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder'),
7
8
  Timezones = require('@barchart/common-js/lang/Timezones');
8
9
 
@@ -24,18 +25,46 @@ module.exports = (() => {
24
25
  this._schema = schema;
25
26
  }
26
27
 
28
+ /**
29
+ * @public
30
+ * @returns {Schema}
31
+ */
27
32
  get schema() {
28
33
  return this._schema;
29
34
  }
30
35
 
36
+ /**
37
+ * @static
38
+ * @public
39
+ * @returns {PortfolioSchema}
40
+ */
31
41
  static get CREATE() {
32
42
  return create;
33
43
  }
34
44
 
45
+ /**
46
+ * @static
47
+ * @public
48
+ * @returns {PortfolioSchema}
49
+ */
50
+ static get CLIENT() {
51
+ return client;
52
+ }
53
+
54
+ /**
55
+ * @static
56
+ * @public
57
+ * @returns {PortfolioSchema}
58
+ */
35
59
  static get COMPLETE() {
36
60
  return complete;
37
61
  }
38
62
 
63
+ /**
64
+ * @static
65
+ * @public
66
+ * @returns {PortfolioSchema}
67
+ */
39
68
  static get UPDATE() {
40
69
  return update;
41
70
  }
@@ -45,7 +74,29 @@ module.exports = (() => {
45
74
  }
46
75
  }
47
76
 
48
- const complete = new PortfolioSchema(SchemaBuilder.withName('Complete')
77
+ const complete = new PortfolioSchema(SchemaBuilder.withName('complete')
78
+ .withField('user', DataType.STRING)
79
+ .withField('portfolio', DataType.STRING)
80
+ .withField('name', DataType.STRING)
81
+ .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
82
+ .withField('dates.create', DataType.DAY)
83
+ .withField('dates.cash', DataType.DAY, true)
84
+ .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
85
+ .withField('defaults.reinvest', DataType.BOOLEAN, true)
86
+ .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
87
+ .withField('legacy.system', DataType.STRING, true)
88
+ .withField('legacy.user', DataType.STRING, true)
89
+ .withField('legacy.portfolio', DataType.STRING, true)
90
+ .withField('legacy.warnings', DataType.NUMBER, true)
91
+ .withField('legacy.drops', DataType.NUMBER, true)
92
+ .withField('miscellany', DataType.AD_HOC, true)
93
+ .withField('system.sequence', DataType.NUMBER)
94
+ .withField('system.version', DataType.STRING)
95
+ .withField('system.timestamp', DataType.TIMESTAMP)
96
+ .schema
97
+ );
98
+
99
+ const client = new PortfolioSchema(SchemaBuilder.withName('client')
49
100
  .withField('user', DataType.STRING)
50
101
  .withField('portfolio', DataType.STRING)
51
102
  .withField('name', DataType.STRING)
@@ -60,12 +111,11 @@ module.exports = (() => {
60
111
  .withField('legacy.portfolio', DataType.STRING, true)
61
112
  .withField('legacy.warnings', DataType.NUMBER, true)
62
113
  .withField('legacy.drops', DataType.NUMBER, true)
63
- .withField('system.version', DataType.NUMBER, true)
64
- .withField('data', DataType.OBJECT, true)
114
+ .withField('miscellany', DataType.AD_HOC, true)
65
115
  .schema
66
116
  );
67
117
 
68
- const create = new PortfolioSchema(SchemaBuilder.withName('Create')
118
+ const create = new PortfolioSchema(SchemaBuilder.withName('create')
69
119
  .withField('name', DataType.STRING)
70
120
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
71
121
  .withField('dates.create', DataType.DAY)
@@ -73,18 +123,18 @@ module.exports = (() => {
73
123
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
74
124
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
75
125
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
76
- .withField('data', DataType.OBJECT, true)
126
+ .withField('miscellany', DataType.AD_HOC, true)
77
127
  .schema
78
128
  );
79
129
 
80
- const update = new PortfolioSchema(SchemaBuilder.withName('Update')
130
+ const update = new PortfolioSchema(SchemaBuilder.withName('update')
81
131
  .withField('name', DataType.STRING)
82
132
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
83
133
  .withField('dates.cash', DataType.DAY, true)
84
134
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
85
135
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
86
136
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
87
- .withField('data', DataType.OBJECT, true)
137
+ .withField('miscellany', DataType.AD_HOC, true)
88
138
  .schema
89
139
  );
90
140
 
@@ -3,6 +3,7 @@ const assert = require('@barchart/common-js/lang/assert'),
3
3
  DataType = require('@barchart/common-js/serialization/json/DataType'),
4
4
  Enum = require('@barchart/common-js/lang/Enum'),
5
5
  is = require('@barchart/common-js/lang/is'),
6
+ Schema = require('@barchart/common-js/serialization/json/Schema'),
6
7
  SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
7
8
 
8
9
  const ValuationType = require('./../data/ValuationType');
@@ -23,10 +24,19 @@ module.exports = (() => {
23
24
  this._schema = schema;
24
25
  }
25
26
 
27
+ /**
28
+ * @public
29
+ * @returns {Schema}
30
+ */
26
31
  get schema() {
27
32
  return this._schema;
28
33
  }
29
34
 
35
+ /**
36
+ * @static
37
+ * @public
38
+ * @returns {PositionSchema}
39
+ */
30
40
  static get COMPLETE() {
31
41
  return complete;
32
42
  }
@@ -2,6 +2,7 @@ const assert = require('@barchart/common-js/lang/assert'),
2
2
  Currency = require('@barchart/common-js/lang/Currency'),
3
3
  DataType = require('@barchart/common-js/serialization/json/DataType'),
4
4
  Enum = require('@barchart/common-js/lang/Enum'),
5
+ Schema = require('@barchart/common-js/serialization/json/Schema'),
5
6
  SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
6
7
 
7
8
  const TransactionType = require('./../data/TransactionType');
@@ -22,6 +23,10 @@ module.exports = (() => {
22
23
  this._schema = schema;
23
24
  }
24
25
 
26
+ /**
27
+ * @public
28
+ * @returns {Schema}
29
+ */
25
30
  get schema() {
26
31
  return this._schema;
27
32
  }
@@ -102,7 +107,6 @@ module.exports = (() => {
102
107
  return income;
103
108
  }
104
109
 
105
-
106
110
  toString() {
107
111
  return '[TransactionSchema]';
108
112
  }
@@ -150,146 +154,202 @@ module.exports = (() => {
150
154
 
151
155
  const buy = new TransactionSchema(SchemaBuilder.withName('B')
152
156
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
157
+ .withField('position', DataType.STRING, true)
158
+ .withField('instrument.name', DataType.STRING, true)
159
+ .withField('instrument.type', DataType.STRING, true)
160
+ .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
161
+ .withField('instrument.symbol.barchart', DataType.STRING, true)
162
+ .withField('instrument.symbol.display', DataType.STRING, true)
153
163
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
154
164
  .withField('date', DataType.DAY)
155
- .withField('fee', DataType.DECIMAL, true)
156
165
  .withField('price', DataType.DECIMAL)
157
166
  .withField('quantity', DataType.DECIMAL)
167
+ .withField('fee', DataType.DECIMAL, true)
158
168
  .schema
159
169
  );
160
170
 
161
171
  const sell = new TransactionSchema(SchemaBuilder.withName('S')
162
172
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
173
+ .withField('position', DataType.STRING, true)
163
174
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
164
175
  .withField('date', DataType.DAY)
176
+ .withField('price', DataType.DECIMAL)
177
+ .withField('quantity', DataType.DECIMAL)
165
178
  .withField('fee', DataType.DECIMAL, true)
166
179
  .schema
167
180
  );
168
181
 
169
182
  const buyShort = new TransactionSchema(SchemaBuilder.withName('BS')
170
183
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
184
+ .withField('position', DataType.STRING, true)
171
185
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
172
186
  .withField('date', DataType.DAY)
187
+ .withField('price', DataType.DECIMAL)
188
+ .withField('quantity', DataType.DECIMAL)
173
189
  .withField('fee', DataType.DECIMAL, true)
174
190
  .schema
175
191
  );
176
192
 
177
193
  const sellShort = new TransactionSchema(SchemaBuilder.withName('SS')
178
194
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
195
+ .withField('position', DataType.STRING, true)
179
196
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
180
197
  .withField('date', DataType.DAY)
198
+ .withField('price', DataType.DECIMAL)
199
+ .withField('quantity', DataType.DECIMAL)
181
200
  .withField('fee', DataType.DECIMAL, true)
182
201
  .schema
183
202
  );
184
203
 
185
204
  const dividend = new TransactionSchema(SchemaBuilder.withName('DV')
186
205
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
206
+ .withField('position', DataType.STRING, true)
187
207
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
188
208
  .withField('date', DataType.DAY)
209
+ .withField('rate', DataType.DECIMAL)
210
+ .withField('open', DataType.DECIMAL, true)
211
+ .withField('effective', DataType.DAY, true)
189
212
  .withField('fee', DataType.DECIMAL, true)
190
213
  .schema
191
214
  );
192
215
 
193
216
  const dividendReinvest = new TransactionSchema(SchemaBuilder.withName('DX')
194
217
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
218
+ .withField('position', DataType.STRING, true)
195
219
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
196
220
  .withField('date', DataType.DAY)
221
+ .withField('rate', DataType.DECIMAL)
222
+ .withField('open', DataType.DECIMAL, true)
223
+ .withField('effective', DataType.DAY, true)
224
+ .withField('price', DataType.DECIMAL)
197
225
  .withField('fee', DataType.DECIMAL, true)
198
226
  .schema
199
227
  );
200
228
 
201
229
  const dividendStock = new TransactionSchema(SchemaBuilder.withName('DS')
202
230
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
231
+ .withField('position', DataType.STRING, true)
203
232
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
204
233
  .withField('date', DataType.DAY)
234
+ .withField('rate', DataType.DECIMAL)
235
+ .withField('open', DataType.DECIMAL, true)
236
+ .withField('effective', DataType.DAY, true)
237
+ .withField('price', DataType.DECIMAL)
205
238
  .withField('fee', DataType.DECIMAL, true)
206
239
  .schema
207
240
  );
208
241
 
209
242
  const distributionCash = new TransactionSchema(SchemaBuilder.withName('DC')
210
243
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
244
+ .withField('position', DataType.STRING, true)
211
245
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
212
246
  .withField('date', DataType.DAY)
247
+ .withField('rate', DataType.DECIMAL)
248
+ .withField('open', DataType.DECIMAL, true)
249
+ .withField('effective', DataType.DAY, true)
213
250
  .withField('fee', DataType.DECIMAL, true)
214
251
  .schema
215
252
  );
216
253
 
217
254
  const distributionFund = new TransactionSchema(SchemaBuilder.withName('DF')
218
255
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
256
+ .withField('position', DataType.STRING, true)
219
257
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
220
258
  .withField('date', DataType.DAY)
259
+ .withField('rate', DataType.DECIMAL)
260
+ .withField('open', DataType.DECIMAL, true)
261
+ .withField('effective', DataType.DAY, true)
221
262
  .withField('fee', DataType.DECIMAL, true)
222
263
  .schema
223
264
  );
224
265
 
225
266
  const split = new TransactionSchema(SchemaBuilder.withName('SP')
226
267
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
268
+ .withField('position', DataType.STRING, true)
227
269
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
228
270
  .withField('date', DataType.DAY)
271
+ .withField('numerator', DataType.DECIMAL)
272
+ .withField('denominator', DataType.DECIMAL)
273
+ .withField('effective', DataType.DAY, true)
229
274
  .withField('fee', DataType.DECIMAL, true)
230
275
  .schema
231
276
  );
232
277
 
233
278
  const fee = new TransactionSchema(SchemaBuilder.withName('F')
234
279
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
280
+ .withField('position', DataType.STRING, true)
235
281
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
236
282
  .withField('date', DataType.DAY)
237
- .withField('fee', DataType.DECIMAL, true)
283
+ .withField('fee', DataType.DECIMAL)
238
284
  .schema
239
285
  );
240
286
 
241
287
  const feeUnits = new TransactionSchema(SchemaBuilder.withName('FU')
242
288
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
289
+ .withField('position', DataType.STRING, true)
243
290
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
244
291
  .withField('date', DataType.DAY)
245
- .withField('fee', DataType.DECIMAL, true)
292
+ .withField('fee', DataType.DECIMAL)
293
+ .withField('price', DataType.DECIMAL)
246
294
  .schema
247
295
  );
248
296
 
249
297
  const deposit = new TransactionSchema(SchemaBuilder.withName('D')
250
298
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
299
+ .withField('position', DataType.STRING, true)
251
300
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
252
301
  .withField('date', DataType.DAY)
302
+ .withField('amount', DataType.DECIMAL)
253
303
  .withField('fee', DataType.DECIMAL, true)
254
304
  .schema
255
305
  );
256
306
 
257
307
  const withdrawal = new TransactionSchema(SchemaBuilder.withName('W')
258
308
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
309
+ .withField('position', DataType.STRING, true)
259
310
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
260
311
  .withField('date', DataType.DAY)
312
+ .withField('amount', DataType.DECIMAL)
261
313
  .withField('fee', DataType.DECIMAL, true)
262
314
  .schema
263
315
  );
264
316
 
265
317
  const debit = new TransactionSchema(SchemaBuilder.withName('DR')
266
318
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
319
+ .withField('position', DataType.STRING, true)
267
320
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
268
321
  .withField('date', DataType.DAY)
322
+ .withField('amount', DataType.DECIMAL)
269
323
  .withField('fee', DataType.DECIMAL, true)
270
324
  .schema
271
325
  );
272
326
 
273
327
  const credit = new TransactionSchema(SchemaBuilder.withName('CR')
274
328
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
329
+ .withField('position', DataType.STRING, true)
275
330
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
276
331
  .withField('date', DataType.DAY)
332
+ .withField('amount', DataType.DECIMAL)
277
333
  .withField('fee', DataType.DECIMAL, true)
278
334
  .schema
279
335
  );
280
336
 
281
337
  const valuation = new TransactionSchema(SchemaBuilder.withName('V')
282
338
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
339
+ .withField('position', DataType.STRING, true)
283
340
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
284
341
  .withField('date', DataType.DAY)
342
+ .withField('value', DataType.DECIMAL)
285
343
  .withField('fee', DataType.DECIMAL, true)
286
344
  .schema
287
345
  );
288
346
 
289
347
  const income = new TransactionSchema(SchemaBuilder.withName('I')
290
348
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
349
+ .withField('position', DataType.STRING, true)
291
350
  .withField('currency', DataType.forEnum(Currency, 'Currency'))
292
351
  .withField('date', DataType.DAY)
352
+ .withField('income', DataType.DECIMAL)
293
353
  .withField('fee', DataType.DECIMAL, true)
294
354
  .schema
295
355
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.19",
3
+ "version": "1.0.23",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",