@barchart/portfolio-client-js 1.2.28 → 1.2.29
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 +68 -17
- package/lib/gateway/PortfolioGateway.js +72 -16
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.js
CHANGED
|
@@ -290,6 +290,14 @@ module.exports = function () {
|
|
|
290
290
|
return x.format();
|
|
291
291
|
}).withVariableParameter('page', 'page', 'page', true).withVariableParameter('sequence', 'sequence', 'sequence', true).withVariableParameter('count', 'count', 'count', true).withVariableParameter('descending', 'descending', 'descending', true);
|
|
292
292
|
}).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
293
|
+
|
|
294
|
+
_this._downloadBrokerageReportEndpoint = EndpointBuilder.for('download-brokerage-report', 'download brokerage report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
295
|
+
pb.withLiteralParameter('reports', 'reports').withLiteralParameter('pdf', 'pdf').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('brokerage', 'brokerage').withLiteralParameter('frames', 'frames').withVariableParameter('frame', 'frame', 'frame', false, function (x) {
|
|
296
|
+
return x.code;
|
|
297
|
+
}).withLiteralParameter('date', 'date').withVariableParameter('start', 'start', 'start', false, function (x) {
|
|
298
|
+
return x.format();
|
|
299
|
+
});
|
|
300
|
+
}).withRequestInterceptor(requestInterceptorToUse).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
293
301
|
return _this;
|
|
294
302
|
}
|
|
295
303
|
|
|
@@ -575,13 +583,13 @@ module.exports = function () {
|
|
|
575
583
|
assert.argumentIsOptional(periods, 'periods', Number);
|
|
576
584
|
assert.argumentIsOptional(start, 'start', Day);
|
|
577
585
|
|
|
578
|
-
var
|
|
586
|
+
var payload = {
|
|
579
587
|
portfolio: portfolio || '*',
|
|
580
588
|
position: position || '*'
|
|
581
589
|
};
|
|
582
590
|
|
|
583
591
|
if (frames) {
|
|
584
|
-
|
|
592
|
+
payload.frames = frames.map(function (frame) {
|
|
585
593
|
if (is.string(frame)) {
|
|
586
594
|
return Enum.fromCode(PositionSummaryFrame, frame);
|
|
587
595
|
} else {
|
|
@@ -591,7 +599,7 @@ module.exports = function () {
|
|
|
591
599
|
}
|
|
592
600
|
|
|
593
601
|
if (periods) {
|
|
594
|
-
|
|
602
|
+
payload.periods = periods;
|
|
595
603
|
}
|
|
596
604
|
|
|
597
605
|
if (start) {
|
|
@@ -603,10 +611,10 @@ module.exports = function () {
|
|
|
603
611
|
s = start;
|
|
604
612
|
}
|
|
605
613
|
|
|
606
|
-
|
|
614
|
+
payload.start = s;
|
|
607
615
|
}
|
|
608
616
|
|
|
609
|
-
return Gateway.invoke(_this11._readPositionSummariesEndpoint,
|
|
617
|
+
return Gateway.invoke(_this11._readPositionSummariesEndpoint, payload);
|
|
610
618
|
});
|
|
611
619
|
}
|
|
612
620
|
|
|
@@ -626,12 +634,12 @@ module.exports = function () {
|
|
|
626
634
|
return Promise.resolve().then(function () {
|
|
627
635
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
628
636
|
|
|
629
|
-
var
|
|
637
|
+
var payload = {};
|
|
630
638
|
|
|
631
|
-
|
|
632
|
-
|
|
639
|
+
payload.portfolio = portfolio;
|
|
640
|
+
payload.frames = frames;
|
|
633
641
|
|
|
634
|
-
return Gateway.invoke(_this12._readPositionSummaryDefinitionEndpoint,
|
|
642
|
+
return Gateway.invoke(_this12._readPositionSummaryDefinitionEndpoint, payload);
|
|
635
643
|
});
|
|
636
644
|
}
|
|
637
645
|
|
|
@@ -708,11 +716,11 @@ module.exports = function () {
|
|
|
708
716
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
709
717
|
assert.argumentIsArray(transactions, 'transactions', Object);
|
|
710
718
|
|
|
711
|
-
var
|
|
719
|
+
var payload = {};
|
|
712
720
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
721
|
+
payload.portfolio = portfolio.portfolio;
|
|
722
|
+
payload.transactionTypes = [];
|
|
723
|
+
payload.transactionItems = [];
|
|
716
724
|
|
|
717
725
|
transactions.forEach(function (transaction) {
|
|
718
726
|
transaction.portfolio = portfolio.portfolio;
|
|
@@ -724,11 +732,11 @@ module.exports = function () {
|
|
|
724
732
|
var code = getTransactionTypeCode(transaction);
|
|
725
733
|
var schema = getTransactionSchema(transaction);
|
|
726
734
|
|
|
727
|
-
|
|
728
|
-
|
|
735
|
+
payload.transactionTypes.push(code);
|
|
736
|
+
payload.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
|
|
729
737
|
});
|
|
730
738
|
|
|
731
|
-
return Gateway.invoke(_this15._batchTransactionEndpoint,
|
|
739
|
+
return Gateway.invoke(_this15._batchTransactionEndpoint, payload);
|
|
732
740
|
});
|
|
733
741
|
}
|
|
734
742
|
|
|
@@ -875,6 +883,19 @@ module.exports = function () {
|
|
|
875
883
|
return Gateway.invoke(_this19._readTransactionsReportEndpoint, payload);
|
|
876
884
|
});
|
|
877
885
|
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Reads a single page of formatted transactions.
|
|
889
|
+
*
|
|
890
|
+
* @public
|
|
891
|
+
* @param {String} portfolio
|
|
892
|
+
* @param {String} position
|
|
893
|
+
* @param {Number=} sequence
|
|
894
|
+
* @param {Number=} count
|
|
895
|
+
* @param {Boolean=} descending
|
|
896
|
+
* @returns {Promise<Object[]>}
|
|
897
|
+
*/
|
|
898
|
+
|
|
878
899
|
}, {
|
|
879
900
|
key: 'readTransactionsFormattedPage',
|
|
880
901
|
value: function readTransactionsFormattedPage(portfolio, position, sequence, count, descending) {
|
|
@@ -910,6 +931,36 @@ module.exports = function () {
|
|
|
910
931
|
});
|
|
911
932
|
}
|
|
912
933
|
|
|
934
|
+
/**
|
|
935
|
+
* @public
|
|
936
|
+
* @param {String=} portfolio
|
|
937
|
+
* @param {PositionSummaryFrame} frame
|
|
938
|
+
* @param {Day} start
|
|
939
|
+
* @returns {Promise}
|
|
940
|
+
*/
|
|
941
|
+
|
|
942
|
+
}, {
|
|
943
|
+
key: 'downloadBrokerageReport',
|
|
944
|
+
value: function downloadBrokerageReport(portfolio, frame, start) {
|
|
945
|
+
var _this21 = this;
|
|
946
|
+
|
|
947
|
+
return Promise.resolve().then(function () {
|
|
948
|
+
checkStart.call(_this21);
|
|
949
|
+
|
|
950
|
+
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
951
|
+
assert.argumentIsRequired(frame, 'frame', String);
|
|
952
|
+
assert.argumentIsRequired(start, 'start', Day, 'Day');
|
|
953
|
+
|
|
954
|
+
var payload = {};
|
|
955
|
+
|
|
956
|
+
payload.portfolio = portfolio;
|
|
957
|
+
payload.frame = frame;
|
|
958
|
+
payload.start = start;
|
|
959
|
+
|
|
960
|
+
return Gateway.invoke(_this21._downloadBrokerageReportEndpoint, payload);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
|
|
913
964
|
/**
|
|
914
965
|
* Creates and starts a new {@link PortfolioGateway} for use in the development environment.
|
|
915
966
|
*
|
|
@@ -1505,7 +1556,7 @@ module.exports = function () {
|
|
|
1505
1556
|
return {
|
|
1506
1557
|
JwtGateway: JwtGateway,
|
|
1507
1558
|
PortfolioGateway: PortfolioGateway,
|
|
1508
|
-
version: '1.2.
|
|
1559
|
+
version: '1.2.29'
|
|
1509
1560
|
};
|
|
1510
1561
|
}();
|
|
1511
1562
|
|
|
@@ -347,6 +347,25 @@ module.exports = (() => {
|
|
|
347
347
|
.withResponseInterceptor(ResponseInterceptor.DATA)
|
|
348
348
|
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
349
349
|
.endpoint;
|
|
350
|
+
|
|
351
|
+
this._downloadBrokerageReportEndpoint = EndpointBuilder.for('download-brokerage-report', 'download brokerage report')
|
|
352
|
+
.withVerb(VerbType.GET)
|
|
353
|
+
.withProtocol(protocolType)
|
|
354
|
+
.withHost(host)
|
|
355
|
+
.withPort(port)
|
|
356
|
+
.withPathBuilder((pb) => {
|
|
357
|
+
pb.withLiteralParameter('reports', 'reports')
|
|
358
|
+
.withLiteralParameter('pdf', 'pdf')
|
|
359
|
+
.withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
|
|
360
|
+
.withLiteralParameter('brokerage', 'brokerage')
|
|
361
|
+
.withLiteralParameter('frames', 'frames')
|
|
362
|
+
.withVariableParameter('frame', 'frame', 'frame', false, x => x.code)
|
|
363
|
+
.withLiteralParameter('date', 'date')
|
|
364
|
+
.withVariableParameter('start', 'start', 'start', false, x => x.format());
|
|
365
|
+
})
|
|
366
|
+
.withRequestInterceptor(requestInterceptorToUse)
|
|
367
|
+
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
368
|
+
.endpoint;
|
|
350
369
|
}
|
|
351
370
|
|
|
352
371
|
/**
|
|
@@ -592,13 +611,13 @@ module.exports = (() => {
|
|
|
592
611
|
assert.argumentIsOptional(periods, 'periods', Number);
|
|
593
612
|
assert.argumentIsOptional(start, 'start', Day);
|
|
594
613
|
|
|
595
|
-
const
|
|
614
|
+
const payload = {
|
|
596
615
|
portfolio: portfolio || '*',
|
|
597
616
|
position: position || '*'
|
|
598
617
|
};
|
|
599
618
|
|
|
600
619
|
if (frames) {
|
|
601
|
-
|
|
620
|
+
payload.frames = frames.map((frame) => {
|
|
602
621
|
if (is.string(frame)) {
|
|
603
622
|
return Enum.fromCode(PositionSummaryFrame, frame);
|
|
604
623
|
} else {
|
|
@@ -608,7 +627,7 @@ module.exports = (() => {
|
|
|
608
627
|
}
|
|
609
628
|
|
|
610
629
|
if (periods) {
|
|
611
|
-
|
|
630
|
+
payload.periods = periods;
|
|
612
631
|
}
|
|
613
632
|
|
|
614
633
|
if (start) {
|
|
@@ -620,10 +639,10 @@ module.exports = (() => {
|
|
|
620
639
|
s = start;
|
|
621
640
|
}
|
|
622
641
|
|
|
623
|
-
|
|
642
|
+
payload.start = s;
|
|
624
643
|
}
|
|
625
644
|
|
|
626
|
-
return Gateway.invoke(this._readPositionSummariesEndpoint,
|
|
645
|
+
return Gateway.invoke(this._readPositionSummariesEndpoint, payload);
|
|
627
646
|
});
|
|
628
647
|
}
|
|
629
648
|
|
|
@@ -639,12 +658,12 @@ module.exports = (() => {
|
|
|
639
658
|
.then(() => {
|
|
640
659
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
641
660
|
|
|
642
|
-
const
|
|
661
|
+
const payload = { };
|
|
643
662
|
|
|
644
|
-
|
|
645
|
-
|
|
663
|
+
payload.portfolio = portfolio;
|
|
664
|
+
payload.frames = frames;
|
|
646
665
|
|
|
647
|
-
return Gateway.invoke(this._readPositionSummaryDefinitionEndpoint,
|
|
666
|
+
return Gateway.invoke(this._readPositionSummaryDefinitionEndpoint, payload);
|
|
648
667
|
});
|
|
649
668
|
}
|
|
650
669
|
|
|
@@ -709,11 +728,11 @@ module.exports = (() => {
|
|
|
709
728
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
710
729
|
assert.argumentIsArray(transactions, 'transactions', Object);
|
|
711
730
|
|
|
712
|
-
const
|
|
731
|
+
const payload = { };
|
|
713
732
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
733
|
+
payload.portfolio = portfolio.portfolio;
|
|
734
|
+
payload.transactionTypes = [ ];
|
|
735
|
+
payload.transactionItems = [ ];
|
|
717
736
|
|
|
718
737
|
transactions.forEach((transaction) => {
|
|
719
738
|
transaction.portfolio = portfolio.portfolio;
|
|
@@ -725,11 +744,11 @@ module.exports = (() => {
|
|
|
725
744
|
const code = getTransactionTypeCode(transaction);
|
|
726
745
|
const schema = getTransactionSchema(transaction);
|
|
727
746
|
|
|
728
|
-
|
|
729
|
-
|
|
747
|
+
payload.transactionTypes.push(code);
|
|
748
|
+
payload.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
|
|
730
749
|
});
|
|
731
750
|
|
|
732
|
-
return Gateway.invoke(this._batchTransactionEndpoint,
|
|
751
|
+
return Gateway.invoke(this._batchTransactionEndpoint, payload);
|
|
733
752
|
});
|
|
734
753
|
}
|
|
735
754
|
|
|
@@ -861,6 +880,17 @@ module.exports = (() => {
|
|
|
861
880
|
});
|
|
862
881
|
}
|
|
863
882
|
|
|
883
|
+
/**
|
|
884
|
+
* Reads a single page of formatted transactions.
|
|
885
|
+
*
|
|
886
|
+
* @public
|
|
887
|
+
* @param {String} portfolio
|
|
888
|
+
* @param {String} position
|
|
889
|
+
* @param {Number=} sequence
|
|
890
|
+
* @param {Number=} count
|
|
891
|
+
* @param {Boolean=} descending
|
|
892
|
+
* @returns {Promise<Object[]>}
|
|
893
|
+
*/
|
|
864
894
|
readTransactionsFormattedPage(portfolio, position, sequence, count, descending) {
|
|
865
895
|
return Promise.resolve()
|
|
866
896
|
.then(() => {
|
|
@@ -893,6 +923,32 @@ module.exports = (() => {
|
|
|
893
923
|
});
|
|
894
924
|
}
|
|
895
925
|
|
|
926
|
+
/**
|
|
927
|
+
* @public
|
|
928
|
+
* @param {String=} portfolio
|
|
929
|
+
* @param {PositionSummaryFrame} frame
|
|
930
|
+
* @param {Day} start
|
|
931
|
+
* @returns {Promise}
|
|
932
|
+
*/
|
|
933
|
+
downloadBrokerageReport(portfolio, frame, start) {
|
|
934
|
+
return Promise.resolve()
|
|
935
|
+
.then(() => {
|
|
936
|
+
checkStart.call(this);
|
|
937
|
+
|
|
938
|
+
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
939
|
+
assert.argumentIsRequired(frame, 'frame', String);
|
|
940
|
+
assert.argumentIsRequired(start, 'start', Day, 'Day');
|
|
941
|
+
|
|
942
|
+
const payload = { };
|
|
943
|
+
|
|
944
|
+
payload.portfolio = portfolio;
|
|
945
|
+
payload.frame = frame;
|
|
946
|
+
payload.start = start;
|
|
947
|
+
|
|
948
|
+
return Gateway.invoke(this._downloadBrokerageReportEndpoint, payload);
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
|
|
896
952
|
/**
|
|
897
953
|
* Creates and starts a new {@link PortfolioGateway} for use in the development environment.
|
|
898
954
|
*
|
package/lib/index.js
CHANGED