@barchart/portfolio-client-js 1.2.22 → 1.2.25
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/example/example.js +37 -18
- package/lib/gateway/PortfolioGateway.js +30 -14
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.js
CHANGED
|
@@ -192,8 +192,6 @@ module.exports = function () {
|
|
|
192
192
|
requestInterceptorToUse = RequestInterceptor.EMPTY;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
_this._positionObservers = {};
|
|
196
|
-
|
|
197
195
|
_this._readPortfoliosEndpoint = EndpointBuilder.for('read-portfolios', 'read portfolios').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
198
196
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
|
|
199
197
|
}).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
@@ -231,8 +229,8 @@ module.exports = function () {
|
|
|
231
229
|
return frames.map(function (f) {
|
|
232
230
|
return f.code;
|
|
233
231
|
}).join();
|
|
234
|
-
}).withVariableParameter('periods', 'periods', 'periods', true).withVariableParameter('start', 'start', 'start', true, function (
|
|
235
|
-
return
|
|
232
|
+
}).withVariableParameter('periods', 'periods', 'periods', true).withVariableParameter('start', 'start', 'start', true, function (x) {
|
|
233
|
+
return x.format();
|
|
236
234
|
});
|
|
237
235
|
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
238
236
|
|
|
@@ -245,8 +243,8 @@ module.exports = function () {
|
|
|
245
243
|
_this._createTransactionEndpoint = EndpointBuilder.for('create-transaction', 'create transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
246
244
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
|
|
247
245
|
}).withQueryBuilder(function (qb) {
|
|
248
|
-
qb.withVariableParameter('type', 'type', 'type', false, function (
|
|
249
|
-
return
|
|
246
|
+
qb.withVariableParameter('type', 'type', 'type', false, function (x) {
|
|
247
|
+
return x.code;
|
|
250
248
|
});
|
|
251
249
|
}).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
252
250
|
|
|
@@ -257,15 +255,19 @@ module.exports = function () {
|
|
|
257
255
|
_this._editTransactionEndpoint = EndpointBuilder.for('edit-transaction', 'edit transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
258
256
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
|
|
259
257
|
}).withQueryBuilder(function (qb) {
|
|
260
|
-
qb.withVariableParameter('type', 'type', 'type', false, function (
|
|
261
|
-
return
|
|
258
|
+
qb.withVariableParameter('type', 'type', 'type', false, function (x) {
|
|
259
|
+
return x.code;
|
|
262
260
|
});
|
|
263
261
|
}).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
264
262
|
|
|
265
263
|
_this._deleteTransactionEndpoint = EndpointBuilder.for('delete-transaction', 'delete transaction').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
266
264
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
|
|
267
265
|
}).withQueryBuilder(function (qb) {
|
|
268
|
-
qb.withVariableParameter('force', 'force', 'force', false).withVariableParameter('
|
|
266
|
+
qb.withVariableParameter('force', 'force', 'force', false).withVariableParameter('echoStart', 'echoStart', 'echoStart', true, function (x) {
|
|
267
|
+
return x.format();
|
|
268
|
+
}).withVariableParameter('echoEnd', 'echoEnd', 'echoEnd', true, function (x) {
|
|
269
|
+
return x.format();
|
|
270
|
+
});
|
|
269
271
|
}).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
270
272
|
|
|
271
273
|
_this._readTransactionsReportEndpoint = EndpointBuilder.for('read-transaction-report', 'read transaction report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
@@ -493,8 +495,8 @@ module.exports = function () {
|
|
|
493
495
|
var _this10 = this;
|
|
494
496
|
|
|
495
497
|
return promise.build(function (resolveCallback) {
|
|
496
|
-
assert.
|
|
497
|
-
assert.
|
|
498
|
+
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
499
|
+
assert.argumentIsRequired(position, 'position', String);
|
|
498
500
|
|
|
499
501
|
var scheduleCheck = function scheduleCheck(delay) {
|
|
500
502
|
setTimeout(function () {
|
|
@@ -505,9 +507,9 @@ module.exports = function () {
|
|
|
505
507
|
|
|
506
508
|
if (is.object(p)) {
|
|
507
509
|
if (is.object(p.system) && is.object(p.system) && is.boolean(p.system.locked) && p.system.locked) {
|
|
508
|
-
|
|
510
|
+
scheduleCheck(delay + 1000);
|
|
509
511
|
} else {
|
|
510
|
-
|
|
512
|
+
resolveCallback(p);
|
|
511
513
|
}
|
|
512
514
|
} else {
|
|
513
515
|
resolveCallback(null);
|
|
@@ -729,13 +731,14 @@ module.exports = function () {
|
|
|
729
731
|
* @param {String} position
|
|
730
732
|
* @param {Number} sequence
|
|
731
733
|
* @param {Boolean=} force
|
|
732
|
-
* @param {
|
|
734
|
+
* @param {Day=} echoStart
|
|
735
|
+
* @param {Day=} echoEnd
|
|
733
736
|
* @returns {Promise.<TransactionMutateResult>}
|
|
734
737
|
*/
|
|
735
738
|
|
|
736
739
|
}, {
|
|
737
740
|
key: 'deleteTransaction',
|
|
738
|
-
value: function deleteTransaction(portfolio, position, sequence, force,
|
|
741
|
+
value: function deleteTransaction(portfolio, position, sequence, force, echoStart, echoEnd) {
|
|
739
742
|
var _this16 = this;
|
|
740
743
|
|
|
741
744
|
return Promise.resolve().then(function () {
|
|
@@ -745,9 +748,25 @@ module.exports = function () {
|
|
|
745
748
|
assert.argumentIsRequired(position, 'position', String);
|
|
746
749
|
assert.argumentIsRequired(sequence, 'sequence', Number);
|
|
747
750
|
assert.argumentIsOptional(force, 'force', Boolean);
|
|
748
|
-
assert.argumentIsOptional(
|
|
751
|
+
assert.argumentIsOptional(echoStart, 'echoStart', Day, 'Day');
|
|
752
|
+
assert.argumentIsOptional(echoEnd, 'echoEnd', Day, 'Day');
|
|
753
|
+
|
|
754
|
+
var payload = {};
|
|
755
|
+
|
|
756
|
+
payload.portfolio = portfolio;
|
|
757
|
+
payload.position = position;
|
|
758
|
+
payload.sequence = sequence;
|
|
759
|
+
payload.force = is.boolean(force) && force;
|
|
760
|
+
|
|
761
|
+
if (echoStart) {
|
|
762
|
+
payload.echoStart = echoStart;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (echoEnd) {
|
|
766
|
+
payload.echoEnd = echoEnd;
|
|
767
|
+
}
|
|
749
768
|
|
|
750
|
-
return Gateway.invoke(_this16._deleteTransactionEndpoint,
|
|
769
|
+
return Gateway.invoke(_this16._deleteTransactionEndpoint, payload);
|
|
751
770
|
});
|
|
752
771
|
}
|
|
753
772
|
|
|
@@ -1438,7 +1457,7 @@ module.exports = function () {
|
|
|
1438
1457
|
return {
|
|
1439
1458
|
JwtGateway: JwtGateway,
|
|
1440
1459
|
PortfolioGateway: PortfolioGateway,
|
|
1441
|
-
version: '1.2.
|
|
1460
|
+
version: '1.2.25'
|
|
1442
1461
|
};
|
|
1443
1462
|
}();
|
|
1444
1463
|
|
|
@@ -58,8 +58,6 @@ module.exports = (() => {
|
|
|
58
58
|
requestInterceptorToUse = RequestInterceptor.EMPTY;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
this._positionObservers = { };
|
|
62
|
-
|
|
63
61
|
this._readPortfoliosEndpoint = EndpointBuilder.for('read-portfolios', 'read portfolios')
|
|
64
62
|
.withVerb(VerbType.GET)
|
|
65
63
|
.withProtocol(protocolType)
|
|
@@ -190,7 +188,7 @@ module.exports = (() => {
|
|
|
190
188
|
.withQueryBuilder((qb) => {
|
|
191
189
|
qb.withVariableParameter('frames', 'frames', 'frames', true, frames => frames.map(f => f.code).join())
|
|
192
190
|
.withVariableParameter('periods', 'periods', 'periods', true)
|
|
193
|
-
.withVariableParameter('start', 'start', 'start', true,
|
|
191
|
+
.withVariableParameter('start', 'start', 'start', true, x => x.format());
|
|
194
192
|
})
|
|
195
193
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
196
194
|
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
@@ -232,7 +230,7 @@ module.exports = (() => {
|
|
|
232
230
|
.withLiteralParameter('transactions', 'transactions');
|
|
233
231
|
})
|
|
234
232
|
.withQueryBuilder((qb) => {
|
|
235
|
-
qb.withVariableParameter('type', 'type', 'type', false,
|
|
233
|
+
qb.withVariableParameter('type', 'type', 'type', false, x => x.code);
|
|
236
234
|
})
|
|
237
235
|
.withBody('transaction')
|
|
238
236
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
@@ -272,7 +270,7 @@ module.exports = (() => {
|
|
|
272
270
|
.withVariableParameter('sequence', 'sequence', 'sequence', false);
|
|
273
271
|
})
|
|
274
272
|
.withQueryBuilder((qb) => {
|
|
275
|
-
qb.withVariableParameter('type', 'type', 'type', false,
|
|
273
|
+
qb.withVariableParameter('type', 'type', 'type', false, x => x.code);
|
|
276
274
|
})
|
|
277
275
|
.withBody('transaction')
|
|
278
276
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
@@ -295,7 +293,8 @@ module.exports = (() => {
|
|
|
295
293
|
})
|
|
296
294
|
.withQueryBuilder((qb) => {
|
|
297
295
|
qb.withVariableParameter('force', 'force', 'force', false)
|
|
298
|
-
.withVariableParameter('
|
|
296
|
+
.withVariableParameter('echoStart', 'echoStart', 'echoStart', true, x => x.format())
|
|
297
|
+
.withVariableParameter('echoEnd', 'echoEnd', 'echoEnd', true, x => x.format());
|
|
299
298
|
})
|
|
300
299
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
301
300
|
.withResponseInterceptor(responseInterceptorForPositionMutateDeserialization)
|
|
@@ -508,8 +507,8 @@ module.exports = (() => {
|
|
|
508
507
|
*/
|
|
509
508
|
observePositionLock(portfolio, position) {
|
|
510
509
|
return promise.build((resolveCallback) => {
|
|
511
|
-
assert.
|
|
512
|
-
assert.
|
|
510
|
+
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
511
|
+
assert.argumentIsRequired(position, 'position', String);
|
|
513
512
|
|
|
514
513
|
const scheduleCheck = (delay) => {
|
|
515
514
|
setTimeout(() => {
|
|
@@ -519,9 +518,9 @@ module.exports = (() => {
|
|
|
519
518
|
|
|
520
519
|
if (is.object(p)) {
|
|
521
520
|
if (is.object(p.system) && is.object(p.system) && is.boolean(p.system.locked) && p.system.locked) {
|
|
522
|
-
|
|
521
|
+
scheduleCheck(delay + 1000);
|
|
523
522
|
} else {
|
|
524
|
-
|
|
523
|
+
resolveCallback(p);
|
|
525
524
|
}
|
|
526
525
|
} else {
|
|
527
526
|
resolveCallback(null);
|
|
@@ -723,10 +722,11 @@ module.exports = (() => {
|
|
|
723
722
|
* @param {String} position
|
|
724
723
|
* @param {Number} sequence
|
|
725
724
|
* @param {Boolean=} force
|
|
726
|
-
* @param {
|
|
725
|
+
* @param {Day=} echoStart
|
|
726
|
+
* @param {Day=} echoEnd
|
|
727
727
|
* @returns {Promise.<TransactionMutateResult>}
|
|
728
728
|
*/
|
|
729
|
-
deleteTransaction(portfolio, position, sequence, force,
|
|
729
|
+
deleteTransaction(portfolio, position, sequence, force, echoStart, echoEnd) {
|
|
730
730
|
return Promise.resolve()
|
|
731
731
|
.then(() => {
|
|
732
732
|
checkStart.call(this);
|
|
@@ -735,9 +735,25 @@ module.exports = (() => {
|
|
|
735
735
|
assert.argumentIsRequired(position, 'position', String);
|
|
736
736
|
assert.argumentIsRequired(sequence, 'sequence', Number);
|
|
737
737
|
assert.argumentIsOptional(force, 'force', Boolean);
|
|
738
|
-
assert.argumentIsOptional(
|
|
738
|
+
assert.argumentIsOptional(echoStart, 'echoStart', Day, 'Day');
|
|
739
|
+
assert.argumentIsOptional(echoEnd, 'echoEnd', Day, 'Day');
|
|
740
|
+
|
|
741
|
+
let payload = { };
|
|
742
|
+
|
|
743
|
+
payload.portfolio = portfolio;
|
|
744
|
+
payload.position = position;
|
|
745
|
+
payload.sequence = sequence;
|
|
746
|
+
payload.force = is.boolean(force) && force;
|
|
747
|
+
|
|
748
|
+
if (echoStart) {
|
|
749
|
+
payload.echoStart = echoStart;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (echoEnd) {
|
|
753
|
+
payload.echoEnd = echoEnd;
|
|
754
|
+
}
|
|
739
755
|
|
|
740
|
-
return Gateway.invoke(this._deleteTransactionEndpoint,
|
|
756
|
+
return Gateway.invoke(this._deleteTransactionEndpoint, payload);
|
|
741
757
|
});
|
|
742
758
|
}
|
|
743
759
|
|
package/lib/index.js
CHANGED