@barchart/portfolio-client-js 1.2.33 → 1.2.36
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 +166 -140
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.js
CHANGED
|
@@ -136,9 +136,9 @@ var assert = require('@barchart/common-js/lang/assert'),
|
|
|
136
136
|
|
|
137
137
|
var TransactionType = require('@barchart/portfolio-api-common/lib/data/TransactionType');
|
|
138
138
|
|
|
139
|
-
var
|
|
139
|
+
var BrokerageReportAvailabilitySchema = require('@barchart/portfolio-api-common/lib/serialization/reports/BrokerageReportAvailabilitySchema'),
|
|
140
|
+
PortfolioSchema = require('@barchart/portfolio-api-common/lib/serialization/PortfolioSchema'),
|
|
140
141
|
PositionSummarySchema = require('@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema'),
|
|
141
|
-
PositionSummaryDefinitionSchema = require('@barchart/portfolio-api-common/lib/serialization/PositionSummaryDefinitionSchema'),
|
|
142
142
|
PositionSchema = require('@barchart/portfolio-api-common/lib/serialization/PositionSchema'),
|
|
143
143
|
TransactionSchema = require('@barchart/portfolio-api-common/lib/serialization/TransactionSchema');
|
|
144
144
|
|
|
@@ -235,16 +235,6 @@ module.exports = function () {
|
|
|
235
235
|
});
|
|
236
236
|
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
237
237
|
|
|
238
|
-
_this._readPositionSummaryDefinitionEndpoint = EndpointBuilder.for('read-position-summary-definitions', 'read position summary definitions').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
239
|
-
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withLiteralParameter('ranges', 'ranges');
|
|
240
|
-
}).withQueryBuilder(function (qb) {
|
|
241
|
-
qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
|
|
242
|
-
return frames.map(function (f) {
|
|
243
|
-
return f.code;
|
|
244
|
-
}).join();
|
|
245
|
-
});
|
|
246
|
-
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDefinitionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
247
|
-
|
|
248
238
|
_this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
249
239
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
|
|
250
240
|
}).withQueryBuilder(function (qb) {
|
|
@@ -291,6 +281,16 @@ module.exports = function () {
|
|
|
291
281
|
}).withVariableParameter('page', 'page', 'page', true).withVariableParameter('sequence', 'sequence', 'sequence', true).withVariableParameter('count', 'count', 'count', true).withVariableParameter('descending', 'descending', 'descending', true);
|
|
292
282
|
}).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
293
283
|
|
|
284
|
+
_this._readBrokerageReportAvailabilityEndpoint = EndpointBuilder.for('read-brokerage-report-availability', 'read brokerage report availability').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
285
|
+
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withLiteralParameter('ranges', 'ranges');
|
|
286
|
+
}).withQueryBuilder(function (qb) {
|
|
287
|
+
qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
|
|
288
|
+
return frames.map(function (f) {
|
|
289
|
+
return f.code;
|
|
290
|
+
}).join();
|
|
291
|
+
});
|
|
292
|
+
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForBrokerageReportAvailabilityDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
293
|
+
|
|
294
294
|
_this._downloadBrokerageReportEndpoint = EndpointBuilder.for('download-brokerage-report', 'download brokerage report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
295
295
|
pb.withLiteralParameter('reports', 'reports').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('frames', 'frames').withVariableParameter('frame', 'frame', 'frame', false, function (x) {
|
|
296
296
|
return x.code;
|
|
@@ -618,31 +618,6 @@ module.exports = function () {
|
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
-
/**
|
|
622
|
-
* Returns all position summary definitions for a portfolio.
|
|
623
|
-
*
|
|
624
|
-
* @public
|
|
625
|
-
* @param {String} portfolio
|
|
626
|
-
* @param {Array.<PositionSummaryFrame>} frames
|
|
627
|
-
*/
|
|
628
|
-
|
|
629
|
-
}, {
|
|
630
|
-
key: 'readPositionSummaryDefinitions',
|
|
631
|
-
value: function readPositionSummaryDefinitions(portfolio, frames) {
|
|
632
|
-
var _this12 = this;
|
|
633
|
-
|
|
634
|
-
return Promise.resolve().then(function () {
|
|
635
|
-
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
636
|
-
|
|
637
|
-
var payload = {};
|
|
638
|
-
|
|
639
|
-
payload.portfolio = portfolio;
|
|
640
|
-
payload.frames = frames;
|
|
641
|
-
|
|
642
|
-
return Gateway.invoke(_this12._readPositionSummaryDefinitionEndpoint, payload);
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
|
|
646
621
|
/**
|
|
647
622
|
* Deletes a position.
|
|
648
623
|
*
|
|
@@ -655,15 +630,15 @@ module.exports = function () {
|
|
|
655
630
|
}, {
|
|
656
631
|
key: 'deletePosition',
|
|
657
632
|
value: function deletePosition(portfolio, position) {
|
|
658
|
-
var
|
|
633
|
+
var _this12 = this;
|
|
659
634
|
|
|
660
635
|
return Promise.resolve().then(function () {
|
|
661
|
-
checkStart.call(
|
|
636
|
+
checkStart.call(_this12);
|
|
662
637
|
|
|
663
638
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
664
639
|
assert.argumentIsRequired(position, 'position', String);
|
|
665
640
|
|
|
666
|
-
return Gateway.invoke(
|
|
641
|
+
return Gateway.invoke(_this12._deletePositionEndpoint, { portfolio: portfolio, position: position });
|
|
667
642
|
});
|
|
668
643
|
}
|
|
669
644
|
|
|
@@ -678,10 +653,10 @@ module.exports = function () {
|
|
|
678
653
|
}, {
|
|
679
654
|
key: 'createTransaction',
|
|
680
655
|
value: function createTransaction(transaction) {
|
|
681
|
-
var
|
|
656
|
+
var _this13 = this;
|
|
682
657
|
|
|
683
658
|
return Promise.resolve().then(function () {
|
|
684
|
-
checkStart.call(
|
|
659
|
+
checkStart.call(_this13);
|
|
685
660
|
|
|
686
661
|
assert.argumentIsRequired(transaction, 'transaction', Object);
|
|
687
662
|
assert.argumentIsRequired(transaction.portfolio, 'transaction.portfolio', String);
|
|
@@ -693,7 +668,7 @@ module.exports = function () {
|
|
|
693
668
|
|
|
694
669
|
var schema = getTransactionSchema(transaction);
|
|
695
670
|
|
|
696
|
-
return Gateway.invoke(
|
|
671
|
+
return Gateway.invoke(_this13._createTransactionEndpoint, schema.schema.format(transaction));
|
|
697
672
|
});
|
|
698
673
|
}
|
|
699
674
|
|
|
@@ -708,10 +683,10 @@ module.exports = function () {
|
|
|
708
683
|
}, {
|
|
709
684
|
key: 'batchTransactions',
|
|
710
685
|
value: function batchTransactions(portfolio, transactions) {
|
|
711
|
-
var
|
|
686
|
+
var _this14 = this;
|
|
712
687
|
|
|
713
688
|
return Promise.resolve().then(function () {
|
|
714
|
-
checkStart.call(
|
|
689
|
+
checkStart.call(_this14);
|
|
715
690
|
|
|
716
691
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
717
692
|
assert.argumentIsArray(transactions, 'transactions', Object);
|
|
@@ -736,7 +711,7 @@ module.exports = function () {
|
|
|
736
711
|
payload.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
|
|
737
712
|
});
|
|
738
713
|
|
|
739
|
-
return Gateway.invoke(
|
|
714
|
+
return Gateway.invoke(_this14._batchTransactionEndpoint, payload);
|
|
740
715
|
});
|
|
741
716
|
}
|
|
742
717
|
|
|
@@ -751,10 +726,10 @@ module.exports = function () {
|
|
|
751
726
|
}, {
|
|
752
727
|
key: 'editTransaction',
|
|
753
728
|
value: function editTransaction(transaction) {
|
|
754
|
-
var
|
|
729
|
+
var _this15 = this;
|
|
755
730
|
|
|
756
731
|
return Promise.resolve().then(function () {
|
|
757
|
-
checkStart.call(
|
|
732
|
+
checkStart.call(_this15);
|
|
758
733
|
|
|
759
734
|
assert.argumentIsRequired(transaction, 'transaction', Object);
|
|
760
735
|
assert.argumentIsRequired(transaction.portfolio, 'transaction.portfolio', String);
|
|
@@ -763,7 +738,7 @@ module.exports = function () {
|
|
|
763
738
|
|
|
764
739
|
var schema = getTransactionSchema(transaction);
|
|
765
740
|
|
|
766
|
-
return Gateway.invoke(
|
|
741
|
+
return Gateway.invoke(_this15._editTransactionEndpoint, schema.schema.format(transaction));
|
|
767
742
|
});
|
|
768
743
|
}
|
|
769
744
|
|
|
@@ -783,10 +758,10 @@ module.exports = function () {
|
|
|
783
758
|
}, {
|
|
784
759
|
key: 'deleteTransaction',
|
|
785
760
|
value: function deleteTransaction(portfolio, position, sequence, force, echoStart, echoEnd) {
|
|
786
|
-
var
|
|
761
|
+
var _this16 = this;
|
|
787
762
|
|
|
788
763
|
return Promise.resolve().then(function () {
|
|
789
|
-
checkStart.call(
|
|
764
|
+
checkStart.call(_this16);
|
|
790
765
|
|
|
791
766
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
792
767
|
assert.argumentIsRequired(position, 'position', String);
|
|
@@ -810,7 +785,7 @@ module.exports = function () {
|
|
|
810
785
|
payload.echoEnd = echoEnd;
|
|
811
786
|
}
|
|
812
787
|
|
|
813
|
-
return Gateway.invoke(
|
|
788
|
+
return Gateway.invoke(_this16._deleteTransactionEndpoint, payload);
|
|
814
789
|
});
|
|
815
790
|
}
|
|
816
791
|
|
|
@@ -826,15 +801,15 @@ module.exports = function () {
|
|
|
826
801
|
}, {
|
|
827
802
|
key: 'readTransactions',
|
|
828
803
|
value: function readTransactions(portfolio, position) {
|
|
829
|
-
var
|
|
804
|
+
var _this17 = this;
|
|
830
805
|
|
|
831
806
|
return Promise.resolve().then(function () {
|
|
832
|
-
checkStart.call(
|
|
807
|
+
checkStart.call(_this17);
|
|
833
808
|
|
|
834
809
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
835
810
|
assert.argumentIsOptional(position, 'position', String);
|
|
836
811
|
|
|
837
|
-
return Gateway.invoke(
|
|
812
|
+
return Gateway.invoke(_this17._readTransactionsEndpoint, { portfolio: portfolio, position: position || '*' });
|
|
838
813
|
});
|
|
839
814
|
}
|
|
840
815
|
|
|
@@ -854,10 +829,10 @@ module.exports = function () {
|
|
|
854
829
|
}, {
|
|
855
830
|
key: 'readTransactionsFormatted',
|
|
856
831
|
value: function readTransactionsFormatted(portfolio, position, startDay, endDay, descending) {
|
|
857
|
-
var
|
|
832
|
+
var _this18 = this;
|
|
858
833
|
|
|
859
834
|
return Promise.resolve().then(function () {
|
|
860
|
-
checkStart.call(
|
|
835
|
+
checkStart.call(_this18);
|
|
861
836
|
|
|
862
837
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
863
838
|
assert.argumentIsOptional(position, 'position', String);
|
|
@@ -880,7 +855,7 @@ module.exports = function () {
|
|
|
880
855
|
|
|
881
856
|
payload.descending = is.boolean(descending) && descending;
|
|
882
857
|
|
|
883
|
-
return Gateway.invoke(
|
|
858
|
+
return Gateway.invoke(_this18._readTransactionsReportEndpoint, payload);
|
|
884
859
|
});
|
|
885
860
|
}
|
|
886
861
|
|
|
@@ -899,10 +874,10 @@ module.exports = function () {
|
|
|
899
874
|
}, {
|
|
900
875
|
key: 'readTransactionsFormattedPage',
|
|
901
876
|
value: function readTransactionsFormattedPage(portfolio, position, sequence, count, descending) {
|
|
902
|
-
var
|
|
877
|
+
var _this19 = this;
|
|
903
878
|
|
|
904
879
|
return Promise.resolve().then(function () {
|
|
905
|
-
checkStart.call(
|
|
880
|
+
checkStart.call(_this19);
|
|
906
881
|
|
|
907
882
|
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
908
883
|
assert.argumentIsRequired(position, 'position', String);
|
|
@@ -927,7 +902,30 @@ module.exports = function () {
|
|
|
927
902
|
|
|
928
903
|
payload.descending = is.boolean(descending) && descending;
|
|
929
904
|
|
|
930
|
-
return Gateway.invoke(
|
|
905
|
+
return Gateway.invoke(_this19._readTransactionsReportEndpoint, payload);
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Returns all position summary definitions for a portfolio.
|
|
911
|
+
*
|
|
912
|
+
* @public
|
|
913
|
+
* @param {String} portfolio
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
}, {
|
|
917
|
+
key: 'readBrokerageReportAvailability',
|
|
918
|
+
value: function readBrokerageReportAvailability(portfolio) {
|
|
919
|
+
var _this20 = this;
|
|
920
|
+
|
|
921
|
+
return Promise.resolve().then(function () {
|
|
922
|
+
assert.argumentIsRequired(portfolio, 'portfolio', String);
|
|
923
|
+
|
|
924
|
+
var payload = {};
|
|
925
|
+
|
|
926
|
+
payload.portfolio = portfolio;
|
|
927
|
+
|
|
928
|
+
return Gateway.invoke(_this20._readBrokerageReportAvailabilityEndpoint, payload);
|
|
931
929
|
});
|
|
932
930
|
}
|
|
933
931
|
|
|
@@ -1130,11 +1128,11 @@ module.exports = function () {
|
|
|
1130
1128
|
}
|
|
1131
1129
|
});
|
|
1132
1130
|
|
|
1133
|
-
var
|
|
1131
|
+
var responseInterceptorForBrokerageReportAvailabilityDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
|
|
1134
1132
|
try {
|
|
1135
|
-
return JSON.parse(response.data,
|
|
1133
|
+
return JSON.parse(response.data, BrokerageReportAvailabilitySchema.COMPLETE.schema.getReviver());
|
|
1136
1134
|
} catch (e) {
|
|
1137
|
-
console.log('Error deserializing
|
|
1135
|
+
console.log('Error deserializing brokerage report availability definition', e);
|
|
1138
1136
|
}
|
|
1139
1137
|
});
|
|
1140
1138
|
|
|
@@ -1205,7 +1203,7 @@ module.exports = function () {
|
|
|
1205
1203
|
return PortfolioGateway;
|
|
1206
1204
|
}();
|
|
1207
1205
|
|
|
1208
|
-
},{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/lang/promise":42,"@barchart/portfolio-api-common/lib/data/PositionSummaryFrame":53,"@barchart/portfolio-api-common/lib/data/TransactionType":54,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":56,"@barchart/portfolio-api-common/lib/serialization/PositionSchema":57,"@barchart/portfolio-api-common/lib/serialization/
|
|
1206
|
+
},{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/lang/promise":42,"@barchart/portfolio-api-common/lib/data/PositionSummaryFrame":53,"@barchart/portfolio-api-common/lib/data/TransactionType":54,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":56,"@barchart/portfolio-api-common/lib/serialization/PositionSchema":57,"@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema":58,"@barchart/portfolio-api-common/lib/serialization/TransactionSchema":59,"@barchart/portfolio-api-common/lib/serialization/reports/BrokerageReportAvailabilitySchema":60}],4:[function(require,module,exports){
|
|
1209
1207
|
'use strict';
|
|
1210
1208
|
|
|
1211
1209
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
@@ -1556,7 +1554,7 @@ module.exports = function () {
|
|
|
1556
1554
|
return {
|
|
1557
1555
|
JwtGateway: JwtGateway,
|
|
1558
1556
|
PortfolioGateway: PortfolioGateway,
|
|
1559
|
-
version: '1.2.
|
|
1557
|
+
version: '1.2.36'
|
|
1560
1558
|
};
|
|
1561
1559
|
}();
|
|
1562
1560
|
|
|
@@ -9107,7 +9105,7 @@ module.exports = function () {
|
|
|
9107
9105
|
* the schema.
|
|
9108
9106
|
*
|
|
9109
9107
|
* @public
|
|
9110
|
-
* @param {
|
|
9108
|
+
* @param {Object} data
|
|
9111
9109
|
* @returns {Object}
|
|
9112
9110
|
*/
|
|
9113
9111
|
|
|
@@ -9189,7 +9187,13 @@ module.exports = function () {
|
|
|
9189
9187
|
};
|
|
9190
9188
|
|
|
9191
9189
|
return function (key, value) {
|
|
9192
|
-
|
|
9190
|
+
var item = advance(key);
|
|
9191
|
+
|
|
9192
|
+
if (key === '') {
|
|
9193
|
+
return value;
|
|
9194
|
+
} else {
|
|
9195
|
+
return item.reviver(value);
|
|
9196
|
+
}
|
|
9193
9197
|
};
|
|
9194
9198
|
}
|
|
9195
9199
|
|
|
@@ -10305,7 +10309,7 @@ module.exports = (() => {
|
|
|
10305
10309
|
'use strict';
|
|
10306
10310
|
|
|
10307
10311
|
/**
|
|
10308
|
-
* An enumeration used to define
|
|
10312
|
+
* An enumeration used to define time frames for position summaries.
|
|
10309
10313
|
*
|
|
10310
10314
|
* @public
|
|
10311
10315
|
* @extends {Enum}
|
|
@@ -10391,22 +10395,44 @@ module.exports = (() => {
|
|
|
10391
10395
|
* @return {Array.<PositionSummaryRange>}
|
|
10392
10396
|
*/
|
|
10393
10397
|
getRangesFromDate(date) {
|
|
10398
|
+
assert.argumentIsRequired(date, 'date', Day, 'Day');
|
|
10399
|
+
|
|
10394
10400
|
const transaction = { date: date, snapshot: { open: Decimal.ONE } };
|
|
10395
10401
|
|
|
10396
10402
|
return this.getRanges([ transaction ]);
|
|
10397
10403
|
}
|
|
10398
10404
|
|
|
10405
|
+
/**
|
|
10406
|
+
* Returns the range immediately prior to the range containing the
|
|
10407
|
+
* date supplied.
|
|
10408
|
+
*
|
|
10409
|
+
* @public
|
|
10410
|
+
* @param {Day} date
|
|
10411
|
+
* @param {Number} periods
|
|
10412
|
+
*/
|
|
10413
|
+
getPriorRanges(date, periods) {
|
|
10414
|
+
assert.argumentIsRequired(date, 'date', Day, 'Day');
|
|
10415
|
+
assert.argumentIsRequired(periods, 'periods', Number, 'Number');
|
|
10416
|
+
|
|
10417
|
+
const transactionOne = { date: this.getStartDate((periods - 1), date), snapshot: { open: Decimal.ONE } };
|
|
10418
|
+
const transactionTwo = { date: date, snapshot: { open: Decimal.ZERO } };
|
|
10419
|
+
|
|
10420
|
+
return this._rangeCalculator([ transactionOne, transactionTwo ]);
|
|
10421
|
+
}
|
|
10422
|
+
|
|
10399
10423
|
/**
|
|
10400
10424
|
* Returns the start date for a frame, a given number of periods ago.
|
|
10401
10425
|
*
|
|
10402
10426
|
* @public
|
|
10403
10427
|
* @param {Number} periods
|
|
10428
|
+
* @param {Day=} start
|
|
10404
10429
|
* @returns {Day}
|
|
10405
10430
|
*/
|
|
10406
|
-
getStartDate(periods) {
|
|
10431
|
+
getStartDate(periods, start) {
|
|
10407
10432
|
assert.argumentIsRequired(periods, 'periods', Number);
|
|
10433
|
+
assert.argumentIsOptional(start, 'start', Day, 'Day');
|
|
10408
10434
|
|
|
10409
|
-
return this._startDateCalculator(periods);
|
|
10435
|
+
return this._startDateCalculator(periods, start);
|
|
10410
10436
|
}
|
|
10411
10437
|
|
|
10412
10438
|
/**
|
|
@@ -10539,29 +10565,29 @@ module.exports = (() => {
|
|
|
10539
10565
|
return ranges;
|
|
10540
10566
|
}
|
|
10541
10567
|
|
|
10542
|
-
function getYearlyStartDate(periods) {
|
|
10543
|
-
const today = Day.getToday();
|
|
10568
|
+
function getYearlyStartDate(periods, date) {
|
|
10569
|
+
const today = date || Day.getToday();
|
|
10544
10570
|
|
|
10545
|
-
return
|
|
10571
|
+
return today
|
|
10546
10572
|
.subtractMonths(today.month - 1)
|
|
10547
10573
|
.subtractDays(today.day)
|
|
10548
10574
|
.subtractYears(periods);
|
|
10549
10575
|
}
|
|
10550
10576
|
|
|
10551
|
-
function getQuarterlyStartDate(periods) {
|
|
10577
|
+
function getQuarterlyStartDate(periods, date) {
|
|
10552
10578
|
return null;
|
|
10553
10579
|
}
|
|
10554
10580
|
|
|
10555
|
-
function getMonthlyStartDate(periods) {
|
|
10581
|
+
function getMonthlyStartDate(periods, date) {
|
|
10556
10582
|
return null;
|
|
10557
10583
|
}
|
|
10558
10584
|
|
|
10559
|
-
function getYearToDateStartDate(periods) {
|
|
10585
|
+
function getYearToDateStartDate(periods, date) {
|
|
10560
10586
|
return null;
|
|
10561
10587
|
}
|
|
10562
10588
|
|
|
10563
10589
|
function getYearlyRangeDescription(start, end) {
|
|
10564
|
-
return end.year.toString()
|
|
10590
|
+
return `Year ended ${end.year.toString()}`;
|
|
10565
10591
|
}
|
|
10566
10592
|
|
|
10567
10593
|
function getQuarterlyRangeDescription(start, end) {
|
|
@@ -11401,66 +11427,6 @@ const DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
|
11401
11427
|
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
11402
11428
|
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
11403
11429
|
|
|
11404
|
-
const PositionSummaryFrame = require('./../data/PositionSummaryFrame');
|
|
11405
|
-
|
|
11406
|
-
module.exports = (() => {
|
|
11407
|
-
'use strict';
|
|
11408
|
-
|
|
11409
|
-
/**
|
|
11410
|
-
* The schemas which can be used to represent position summary objects.
|
|
11411
|
-
*
|
|
11412
|
-
* @public
|
|
11413
|
-
* @extends {Enum}
|
|
11414
|
-
*/
|
|
11415
|
-
class PositionSummaryDefinitionSchema extends Enum {
|
|
11416
|
-
constructor(schema) {
|
|
11417
|
-
super(schema.name, schema.name);
|
|
11418
|
-
|
|
11419
|
-
this._schema = schema;
|
|
11420
|
-
}
|
|
11421
|
-
|
|
11422
|
-
/**
|
|
11423
|
-
* The actual {@link Schema}.
|
|
11424
|
-
*
|
|
11425
|
-
* @public
|
|
11426
|
-
* @returns {Schema}
|
|
11427
|
-
*/
|
|
11428
|
-
get schema() {
|
|
11429
|
-
return this._schema;
|
|
11430
|
-
}
|
|
11431
|
-
|
|
11432
|
-
/**
|
|
11433
|
-
* The complete position summary definition schema.
|
|
11434
|
-
*
|
|
11435
|
-
* @static
|
|
11436
|
-
* @public
|
|
11437
|
-
* @returns {PositionSummaryDefinitionSchema}
|
|
11438
|
-
*/
|
|
11439
|
-
static get COMPLETE() {
|
|
11440
|
-
return complete;
|
|
11441
|
-
}
|
|
11442
|
-
|
|
11443
|
-
toString() {
|
|
11444
|
-
return '[PositionSummaryDefinitionSchema]';
|
|
11445
|
-
}
|
|
11446
|
-
}
|
|
11447
|
-
|
|
11448
|
-
const complete = new PositionSummaryDefinitionSchema(SchemaBuilder.withName('complete')
|
|
11449
|
-
.withField('start', DataType.DAY)
|
|
11450
|
-
.withField('end', DataType.DAY)
|
|
11451
|
-
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
11452
|
-
.schema
|
|
11453
|
-
);
|
|
11454
|
-
|
|
11455
|
-
return PositionSummaryDefinitionSchema;
|
|
11456
|
-
})();
|
|
11457
|
-
|
|
11458
|
-
},{"./../data/PositionSummaryFrame":53,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],59:[function(require,module,exports){
|
|
11459
|
-
const DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
11460
|
-
Enum = require('@barchart/common-js/lang/Enum'),
|
|
11461
|
-
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
11462
|
-
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
11463
|
-
|
|
11464
11430
|
const PositionDirection = require('./../data/PositionDirection'),
|
|
11465
11431
|
PositionSummaryFrame = require('./../data/PositionSummaryFrame');
|
|
11466
11432
|
|
|
@@ -11572,7 +11538,7 @@ module.exports = (() => {
|
|
|
11572
11538
|
return PositionSummarySchema;
|
|
11573
11539
|
})();
|
|
11574
11540
|
|
|
11575
|
-
},{"./../data/PositionDirection":52,"./../data/PositionSummaryFrame":53,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],
|
|
11541
|
+
},{"./../data/PositionDirection":52,"./../data/PositionSummaryFrame":53,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],59:[function(require,module,exports){
|
|
11576
11542
|
const is = require('@barchart/common-js/lang/is'),
|
|
11577
11543
|
Currency = require('@barchart/common-js/lang/Currency'),
|
|
11578
11544
|
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
@@ -11928,7 +11894,67 @@ module.exports = (() => {
|
|
|
11928
11894
|
return TransactionSchema;
|
|
11929
11895
|
})();
|
|
11930
11896
|
|
|
11931
|
-
},{"./../data/InstrumentType":51,"./../data/PositionDirection":52,"./../data/TransactionType":54,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],
|
|
11897
|
+
},{"./../data/InstrumentType":51,"./../data/PositionDirection":52,"./../data/TransactionType":54,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],60:[function(require,module,exports){
|
|
11898
|
+
const DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
11899
|
+
Enum = require('@barchart/common-js/lang/Enum'),
|
|
11900
|
+
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
11901
|
+
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
11902
|
+
|
|
11903
|
+
const PositionSummaryFrame = require('./../../data/PositionSummaryFrame');
|
|
11904
|
+
|
|
11905
|
+
module.exports = (() => {
|
|
11906
|
+
'use strict';
|
|
11907
|
+
|
|
11908
|
+
/**
|
|
11909
|
+
* Schema used to represent availability of a brokerage report.
|
|
11910
|
+
*
|
|
11911
|
+
* @public
|
|
11912
|
+
* @extends {Enum}
|
|
11913
|
+
*/
|
|
11914
|
+
class BrokerageReportAvailabilitySchema extends Enum {
|
|
11915
|
+
constructor(schema) {
|
|
11916
|
+
super(schema.name, schema.name);
|
|
11917
|
+
|
|
11918
|
+
this._schema = schema;
|
|
11919
|
+
}
|
|
11920
|
+
|
|
11921
|
+
/**
|
|
11922
|
+
* The actual {@link Schema}.
|
|
11923
|
+
*
|
|
11924
|
+
* @public
|
|
11925
|
+
* @returns {Schema}
|
|
11926
|
+
*/
|
|
11927
|
+
get schema() {
|
|
11928
|
+
return this._schema;
|
|
11929
|
+
}
|
|
11930
|
+
|
|
11931
|
+
/**
|
|
11932
|
+
* The complete position summary definition schema.
|
|
11933
|
+
*
|
|
11934
|
+
* @static
|
|
11935
|
+
* @public
|
|
11936
|
+
* @returns {BrokerageReportAvailabilitySchema}
|
|
11937
|
+
*/
|
|
11938
|
+
static get COMPLETE() {
|
|
11939
|
+
return complete;
|
|
11940
|
+
}
|
|
11941
|
+
|
|
11942
|
+
toString() {
|
|
11943
|
+
return '[BrokerageReportAvailabilitySchema]';
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11946
|
+
|
|
11947
|
+
const complete = new BrokerageReportAvailabilitySchema(SchemaBuilder.withName('complete')
|
|
11948
|
+
.withField('start', DataType.DAY)
|
|
11949
|
+
.withField('end', DataType.DAY)
|
|
11950
|
+
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
11951
|
+
.schema
|
|
11952
|
+
);
|
|
11953
|
+
|
|
11954
|
+
return BrokerageReportAvailabilitySchema;
|
|
11955
|
+
})();
|
|
11956
|
+
|
|
11957
|
+
},{"./../../data/PositionSummaryFrame":53,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],61:[function(require,module,exports){
|
|
11932
11958
|
'use strict';
|
|
11933
11959
|
|
|
11934
11960
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
package/lib/index.js
CHANGED