@barchart/portfolio-client-js 1.2.23 → 1.2.26
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 +41 -18
- package/lib/gateway/PortfolioGateway.js +34 -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,7 +507,7 @@ 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
|
-
scheduleCheck(
|
|
510
|
+
scheduleCheck(delay + 1000);
|
|
509
511
|
} else {
|
|
510
512
|
resolveCallback(p);
|
|
511
513
|
}
|
|
@@ -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 = {};
|
|
749
755
|
|
|
750
|
-
|
|
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
|
+
}
|
|
768
|
+
|
|
769
|
+
return Gateway.invoke(_this16._deleteTransactionEndpoint, payload);
|
|
751
770
|
});
|
|
752
771
|
}
|
|
753
772
|
|
|
@@ -784,12 +803,13 @@ module.exports = function () {
|
|
|
784
803
|
* @param {String=} position
|
|
785
804
|
* @param {Day=} startDay
|
|
786
805
|
* @param {Day=} endDay
|
|
806
|
+
* @oaram {Boolean=} descending
|
|
787
807
|
* @returns {Promise.<Object[]>}
|
|
788
808
|
*/
|
|
789
809
|
|
|
790
810
|
}, {
|
|
791
811
|
key: 'readTransactionsFormatted',
|
|
792
|
-
value: function readTransactionsFormatted(portfolio, position, startDay, endDay) {
|
|
812
|
+
value: function readTransactionsFormatted(portfolio, position, startDay, endDay, descending) {
|
|
793
813
|
var _this18 = this;
|
|
794
814
|
|
|
795
815
|
return Promise.resolve().then(function () {
|
|
@@ -799,6 +819,7 @@ module.exports = function () {
|
|
|
799
819
|
assert.argumentIsOptional(position, 'position', String);
|
|
800
820
|
assert.argumentIsOptional(startDay, 'startDay', Day, 'Day');
|
|
801
821
|
assert.argumentIsOptional(endDay, 'endDay', Day, 'Day');
|
|
822
|
+
assert.argumentIsOptional(descending, 'descending', Boolean);
|
|
802
823
|
|
|
803
824
|
var payload = {};
|
|
804
825
|
|
|
@@ -813,6 +834,8 @@ module.exports = function () {
|
|
|
813
834
|
payload.end = endDay;
|
|
814
835
|
}
|
|
815
836
|
|
|
837
|
+
payload.descending = is.boolean(descending) && descending;
|
|
838
|
+
|
|
816
839
|
return Gateway.invoke(_this18._readTransactionsReportEndpoint, payload);
|
|
817
840
|
});
|
|
818
841
|
}
|
|
@@ -1438,7 +1461,7 @@ module.exports = function () {
|
|
|
1438
1461
|
return {
|
|
1439
1462
|
JwtGateway: JwtGateway,
|
|
1440
1463
|
PortfolioGateway: PortfolioGateway,
|
|
1441
|
-
version: '1.2.
|
|
1464
|
+
version: '1.2.26'
|
|
1442
1465
|
};
|
|
1443
1466
|
}();
|
|
1444
1467
|
|
|
@@ -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,7 +518,7 @@ 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
|
-
scheduleCheck(
|
|
521
|
+
scheduleCheck(delay + 1000);
|
|
523
522
|
} else {
|
|
524
523
|
resolveCallback(p);
|
|
525
524
|
}
|
|
@@ -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
|
|
|
@@ -770,9 +786,10 @@ module.exports = (() => {
|
|
|
770
786
|
* @param {String=} position
|
|
771
787
|
* @param {Day=} startDay
|
|
772
788
|
* @param {Day=} endDay
|
|
789
|
+
* @oaram {Boolean=} descending
|
|
773
790
|
* @returns {Promise.<Object[]>}
|
|
774
791
|
*/
|
|
775
|
-
readTransactionsFormatted(portfolio, position, startDay, endDay) {
|
|
792
|
+
readTransactionsFormatted(portfolio, position, startDay, endDay, descending) {
|
|
776
793
|
return Promise.resolve()
|
|
777
794
|
.then(() => {
|
|
778
795
|
checkStart.call(this);
|
|
@@ -781,6 +798,7 @@ module.exports = (() => {
|
|
|
781
798
|
assert.argumentIsOptional(position, 'position', String);
|
|
782
799
|
assert.argumentIsOptional(startDay, 'startDay', Day, 'Day');
|
|
783
800
|
assert.argumentIsOptional(endDay, 'endDay', Day, 'Day');
|
|
801
|
+
assert.argumentIsOptional(descending, 'descending', Boolean);
|
|
784
802
|
|
|
785
803
|
const payload = { };
|
|
786
804
|
|
|
@@ -795,6 +813,8 @@ module.exports = (() => {
|
|
|
795
813
|
payload.end = endDay;
|
|
796
814
|
}
|
|
797
815
|
|
|
816
|
+
payload.descending = is.boolean(descending) && descending;
|
|
817
|
+
|
|
798
818
|
return Gateway.invoke(this._readTransactionsReportEndpoint, payload);
|
|
799
819
|
});
|
|
800
820
|
}
|
package/lib/index.js
CHANGED