@barchart/portfolio-client-js 10.1.0 → 10.3.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.
- package/lib/data/.meta.js +11 -0
- package/lib/gateway/PortfolioGateway.js +77 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/data/.meta.js
CHANGED
|
@@ -298,6 +298,17 @@ const InstrumentType = require('@barchart/portfolio-api-common/lib/data/Instrume
|
|
|
298
298
|
* @property {String[]} positions - Array of position identifiers for which are currently being calculated. An empty result indicates all position valuations are up-to-date.
|
|
299
299
|
*/
|
|
300
300
|
|
|
301
|
+
/**
|
|
302
|
+
* The result of recalculating aggregate values in a requested currency for the authorized user.
|
|
303
|
+
*
|
|
304
|
+
* @typedef UpdateValuesCurrencyResult
|
|
305
|
+
* @type {Object}
|
|
306
|
+
* @memberOf Schema
|
|
307
|
+
* @property {Boolean} success - Indicates the aggregate values were successfully recalculated.
|
|
308
|
+
* @property {String} userId - The identifier of the authorized user whose values were recalculated.
|
|
309
|
+
* @property {String} currency - The currency code used for the recalculation.
|
|
310
|
+
*/
|
|
311
|
+
|
|
301
312
|
/**
|
|
302
313
|
* Instructions for connecting to a brokerage via SnapTrade.
|
|
303
314
|
*
|
|
@@ -108,6 +108,25 @@ module.exports = (() => {
|
|
|
108
108
|
|
|
109
109
|
const protocolType = Enum.fromCode(ProtocolType, protocol.toUpperCase());
|
|
110
110
|
|
|
111
|
+
this._readInstrumentEndpoint = EndpointBuilder.for('read-instrument', 'read instrument')
|
|
112
|
+
.withVerb(VerbType.GET)
|
|
113
|
+
.withProtocol(protocolType)
|
|
114
|
+
.withHost(host)
|
|
115
|
+
.withPort(port)
|
|
116
|
+
.withPathBuilder((pb) => {
|
|
117
|
+
pb.withLiteralParameter('version', REST_API_VERSION)
|
|
118
|
+
.withLiteralParameter('instruments', 'instruments')
|
|
119
|
+
.withVariableParameter('symbol', 'symbol', 'symbol', false);
|
|
120
|
+
})
|
|
121
|
+
.withQueryBuilder((qb) => {
|
|
122
|
+
qb.withVariableParameter('day', 'day', 'day', true, x => x.format());
|
|
123
|
+
})
|
|
124
|
+
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
125
|
+
.withRequestInterceptor(requestInterceptor)
|
|
126
|
+
.withResponseInterceptor(responseInterceptorForDeserialization)
|
|
127
|
+
.withErrorInterceptor(errorInterceptor)
|
|
128
|
+
.endpoint;
|
|
129
|
+
|
|
111
130
|
this._readPortfoliosEndpoint = EndpointBuilder.for('read-portfolios', 'read portfolios')
|
|
112
131
|
.withVerb(VerbType.GET)
|
|
113
132
|
.withProtocol(protocolType)
|
|
@@ -330,6 +349,23 @@ module.exports = (() => {
|
|
|
330
349
|
.withErrorInterceptor(errorInterceptor)
|
|
331
350
|
.endpoint;
|
|
332
351
|
|
|
352
|
+
this._updateValuesCurrencyEndpoint = EndpointBuilder.for('update-values-currency', 'update values currency')
|
|
353
|
+
.withVerb(VerbType.PUT)
|
|
354
|
+
.withProtocol(protocolType)
|
|
355
|
+
.withHost(host)
|
|
356
|
+
.withPort(port)
|
|
357
|
+
.withPathBuilder((pb) => {
|
|
358
|
+
pb.withLiteralParameter('version', REST_API_VERSION)
|
|
359
|
+
.withLiteralParameter('values', 'values')
|
|
360
|
+
.withLiteralParameter('currency', 'currency');
|
|
361
|
+
})
|
|
362
|
+
.withBody('currency')
|
|
363
|
+
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
364
|
+
.withRequestInterceptor(requestInterceptor)
|
|
365
|
+
.withResponseInterceptor(responseInterceptorForDeserialization)
|
|
366
|
+
.withErrorInterceptor(errorInterceptor)
|
|
367
|
+
.endpoint;
|
|
368
|
+
|
|
333
369
|
this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions')
|
|
334
370
|
.withVerb(VerbType.GET)
|
|
335
371
|
.withProtocol(protocolType)
|
|
@@ -695,6 +731,30 @@ module.exports = (() => {
|
|
|
695
731
|
return this._startPromise;
|
|
696
732
|
}
|
|
697
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Resolves an instrument.
|
|
736
|
+
*
|
|
737
|
+
* @public
|
|
738
|
+
* @async
|
|
739
|
+
* @param {String} symbol - The symbol used to resolve the instrument.
|
|
740
|
+
* @param {Day=} day - The day used for symbol resolution.
|
|
741
|
+
* @returns {Promise<Object>}
|
|
742
|
+
*/
|
|
743
|
+
async readInstrument(symbol, day) {
|
|
744
|
+
checkStart.call(this);
|
|
745
|
+
|
|
746
|
+
assert.argumentIsRequired(symbol, 'symbol', String);
|
|
747
|
+
assert.argumentIsOptional(day, 'day', Day, 'Day');
|
|
748
|
+
|
|
749
|
+
const payload = { symbol };
|
|
750
|
+
|
|
751
|
+
if (day) {
|
|
752
|
+
payload.day = day;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return Gateway.invoke(this._readInstrumentEndpoint, payload);
|
|
756
|
+
}
|
|
757
|
+
|
|
698
758
|
/**
|
|
699
759
|
* Creates a new portfolio for the current user.
|
|
700
760
|
*
|
|
@@ -1055,6 +1115,22 @@ module.exports = (() => {
|
|
|
1055
1115
|
return Gateway.invoke(this._queryPositionValuationsEndpoint, { symbol });
|
|
1056
1116
|
}
|
|
1057
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* Recalculates aggregate values for the authorized user in the requested currency.
|
|
1120
|
+
*
|
|
1121
|
+
* @public
|
|
1122
|
+
* @async
|
|
1123
|
+
* @param {String} currency - The target currency code (e.g. `USD`).
|
|
1124
|
+
* @returns {Promise<Schema.UpdateValuesCurrencyResult>}
|
|
1125
|
+
*/
|
|
1126
|
+
async updateValuesCurrency(currency) {
|
|
1127
|
+
checkStart.call(this);
|
|
1128
|
+
|
|
1129
|
+
assert.argumentIsRequired(currency, 'currency', String);
|
|
1130
|
+
|
|
1131
|
+
return Gateway.invoke(this._updateValuesCurrencyEndpoint, { currency });
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1058
1134
|
/**
|
|
1059
1135
|
* Creates a new transaction.
|
|
1060
1136
|
*
|
|
@@ -1920,4 +1996,4 @@ module.exports = (() => {
|
|
|
1920
1996
|
*/
|
|
1921
1997
|
|
|
1922
1998
|
return PortfolioGateway;
|
|
1923
|
-
})();
|
|
1999
|
+
})();
|
package/lib/index.js
CHANGED