@barchart/portfolio-client-js 3.3.1 → 3.4.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/.releases/3.3.0.md +1 -1
- package/.releases/3.4.0.md +3 -0
- package/lib/gateway/PortfolioGateway.js +44 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/.releases/3.3.0.md
CHANGED
|
@@ -44,7 +44,7 @@ module.exports = (() => {
|
|
|
44
44
|
* @param {String} host - The hostname of the Portfolio web service.
|
|
45
45
|
* @param {Number} port - The TCP port number of the Portfolio web service.
|
|
46
46
|
* @param {String} environment - A description of the environment we're connecting to.
|
|
47
|
-
* @param {String=} product - A product
|
|
47
|
+
* @param {String=} product - A code for the product which is using the gateway.
|
|
48
48
|
* @extends {Disposable}
|
|
49
49
|
*/
|
|
50
50
|
class PortfolioGateway extends Disposable {
|
|
@@ -424,6 +424,22 @@ module.exports = (() => {
|
|
|
424
424
|
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
425
425
|
.endpoint;
|
|
426
426
|
|
|
427
|
+
this._readMarketValueEndpoint = EndpointBuilder.for('read-market-value', 'read market value')
|
|
428
|
+
.withVerb(VerbType.POST)
|
|
429
|
+
.withProtocol(protocolType)
|
|
430
|
+
.withHost(host)
|
|
431
|
+
.withPort(port)
|
|
432
|
+
.withPathBuilder((pb) => {
|
|
433
|
+
pb.withLiteralParameter('version', 'v1');
|
|
434
|
+
})
|
|
435
|
+
.withQueryBuilder((qb) => {
|
|
436
|
+
qb.withVariableParameter('symbol', 'symbol', 'symbol', false, x => x.symbol);
|
|
437
|
+
})
|
|
438
|
+
.withRequestInterceptor(requestInterceptor)
|
|
439
|
+
.withResponseInterceptor(responseInterceptorForMarketValues)
|
|
440
|
+
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
441
|
+
.endpoint;
|
|
442
|
+
|
|
427
443
|
this._brokerageReportUrlGenerator = (user, portfolio, frame, end) => {
|
|
428
444
|
return `https://${Configuration.getBrokerageHost(host)}/reports/portfolios/${portfolio}/frames/${frame.code}/date/${end.format()}/${user}`;
|
|
429
445
|
};
|
|
@@ -1129,6 +1145,25 @@ module.exports = (() => {
|
|
|
1129
1145
|
});
|
|
1130
1146
|
}
|
|
1131
1147
|
|
|
1148
|
+
/**
|
|
1149
|
+
* Returns all market value for a symbol.
|
|
1150
|
+
*
|
|
1151
|
+
* @public
|
|
1152
|
+
* @param {String} symbol
|
|
1153
|
+
*/
|
|
1154
|
+
readMarketValue(symbol) {
|
|
1155
|
+
return Promise.resolve()
|
|
1156
|
+
.then(() => {
|
|
1157
|
+
assert.argumentIsRequired(symbol, 'symbol', String);
|
|
1158
|
+
|
|
1159
|
+
const payload = { };
|
|
1160
|
+
|
|
1161
|
+
payload.symbol = symbol;
|
|
1162
|
+
|
|
1163
|
+
return Gateway.invoke(this._readMarketValueEndpoint, payload);
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1132
1167
|
/**
|
|
1133
1168
|
* Generates a URL suitable for downloading a brokerage report (as a PDF).
|
|
1134
1169
|
*
|
|
@@ -1428,6 +1463,14 @@ module.exports = (() => {
|
|
|
1428
1463
|
}
|
|
1429
1464
|
});
|
|
1430
1465
|
|
|
1466
|
+
const responseInterceptorForMarketValues = ResponseInterceptor.fromDelegate((response, ignored) => {
|
|
1467
|
+
try {
|
|
1468
|
+
return JSON.parse(response.data);
|
|
1469
|
+
} catch (e) {
|
|
1470
|
+
console.error('Error deserializing data', e);
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
|
|
1431
1474
|
function start(gateway, jwtProvider) {
|
|
1432
1475
|
return gateway.connect(jwtProvider)
|
|
1433
1476
|
.then(() => {
|
package/lib/index.js
CHANGED