@barchart/portfolio-api-common 1.2.141 → 1.2.145
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/lib/processing/PositionGroup.js +57 -23
- package/lib/processing/PositionItem.js +20 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +238 -88
|
@@ -137,6 +137,7 @@ module.exports = (() => {
|
|
|
137
137
|
this._dataActual.marketChange = null;
|
|
138
138
|
this._dataActual.marketChangePercent = null;
|
|
139
139
|
this._dataActual.cashTotal = null;
|
|
140
|
+
this._dataActual.totalDivisor = null;
|
|
140
141
|
this._dataActual.periodDivisorCurrent = null;
|
|
141
142
|
this._dataActual.periodDivisorPrevious = null;
|
|
142
143
|
this._dataActual.periodDivisorPrevious2 = null;
|
|
@@ -144,6 +145,7 @@ module.exports = (() => {
|
|
|
144
145
|
this._dataFormat.currentPrice = null;
|
|
145
146
|
this._dataFormat.basis = null;
|
|
146
147
|
this._dataFormat.realized = null;
|
|
148
|
+
this._dataFormat.realizedPercent = null;
|
|
147
149
|
this._dataFormat.income = null;
|
|
148
150
|
this._dataFormat.market = null;
|
|
149
151
|
this._dataFormat.marketPercent = null;
|
|
@@ -183,10 +185,12 @@ module.exports = (() => {
|
|
|
183
185
|
this._dataFormat.periodRealized = null;
|
|
184
186
|
this._dataFormat.periodUnrealized = null;
|
|
185
187
|
|
|
188
|
+
this._dataActual.totalPercent = null;
|
|
186
189
|
this._dataActual.periodPercent = null;
|
|
187
190
|
this._dataActual.periodPercentPrevious = null;
|
|
188
191
|
this._dataActual.periodPercentPrevious2 = null;
|
|
189
192
|
|
|
193
|
+
this._dataFormat.totalPercent = null;
|
|
190
194
|
this._dataFormat.periodPercent = null;
|
|
191
195
|
this._dataFormat.periodPercentPrevious = null;
|
|
192
196
|
this._dataFormat.periodPercentPrevious2 = null;
|
|
@@ -695,6 +699,7 @@ module.exports = (() => {
|
|
|
695
699
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
696
700
|
}
|
|
697
701
|
|
|
702
|
+
updates.totalDivisor = updates.periodDivisorCurrent.add(translate(item, item.data.totalDivisor));
|
|
698
703
|
updates.periodDivisorCurrent = updates.periodDivisorCurrent.add(translate(item, item.data.periodDivisor));
|
|
699
704
|
updates.periodDivisorPrevious = updates.periodDivisorPrevious.add(translate(item, item.data.periodDivisorPrevious));
|
|
700
705
|
updates.periodDivisorPrevious2 = updates.periodDivisorPrevious2.add(translate(item, item.data.periodDivisorPrevious2));
|
|
@@ -714,6 +719,7 @@ module.exports = (() => {
|
|
|
714
719
|
periodUnrealized: Decimal.ZERO,
|
|
715
720
|
periodIncome: Decimal.ZERO,
|
|
716
721
|
cashTotal: Decimal.ZERO,
|
|
722
|
+
totalDivisor: Decimal.ZERO,
|
|
717
723
|
periodDivisorCurrent: Decimal.ZERO,
|
|
718
724
|
periodDivisorPrevious: Decimal.ZERO,
|
|
719
725
|
periodDivisorPrevious2: Decimal.ZERO
|
|
@@ -732,6 +738,7 @@ module.exports = (() => {
|
|
|
732
738
|
actual.periodUnrealized = updates.periodUnrealized;
|
|
733
739
|
actual.periodIncome = updates.periodIncome;
|
|
734
740
|
actual.cashTotal = updates.cashTotal;
|
|
741
|
+
actual.totalDivisor = updates.totalDivisor;
|
|
735
742
|
actual.periodDivisorCurrent = updates.periodDivisorCurrent;
|
|
736
743
|
actual.periodDivisorPrevious = updates.periodDivisorPrevious;
|
|
737
744
|
actual.periodDivisorPrevious2 = updates.periodDivisorPrevious2;
|
|
@@ -753,8 +760,17 @@ module.exports = (() => {
|
|
|
753
760
|
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
754
761
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
755
762
|
|
|
763
|
+
calculateRealizedPercent(group);
|
|
756
764
|
calculateUnrealizedPercent(group);
|
|
757
765
|
|
|
766
|
+
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
767
|
+
actual.periodPercentPrevious = calculateGainPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
|
|
768
|
+
actual.periodPercentPrevious2 = calculateGainPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
|
|
769
|
+
|
|
770
|
+
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
771
|
+
format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
|
|
772
|
+
format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
|
|
773
|
+
|
|
758
774
|
const groupItems = group._items;
|
|
759
775
|
|
|
760
776
|
if (group.single && groupItems.length === 1) {
|
|
@@ -762,28 +778,20 @@ module.exports = (() => {
|
|
|
762
778
|
|
|
763
779
|
actual.quantity = item.data.quantity;
|
|
764
780
|
actual.quantityPrevious = item.data.quantityPrevious;
|
|
765
|
-
|
|
766
|
-
actual.basisPrice = item.data.basisPrice;
|
|
767
|
-
|
|
768
|
-
actual.periodPrice = item.data.periodPrice;
|
|
769
|
-
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
770
781
|
|
|
771
782
|
format.quantity = formatDecimal(actual.quantity, 2);
|
|
772
783
|
format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
|
|
773
784
|
|
|
785
|
+
actual.basisPrice = item.data.basisPrice;
|
|
786
|
+
|
|
774
787
|
format.basisPrice = formatCurrency(actual.basisPrice, currency);
|
|
775
788
|
|
|
789
|
+
actual.periodPrice = item.data.periodPrice;
|
|
790
|
+
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
791
|
+
|
|
776
792
|
format.periodPrice = formatCurrency(actual.periodPrice, currency);
|
|
777
793
|
format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
|
|
778
794
|
|
|
779
|
-
actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
780
|
-
actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
|
|
781
|
-
actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
|
|
782
|
-
|
|
783
|
-
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
784
|
-
format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
|
|
785
|
-
format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
|
|
786
|
-
|
|
787
795
|
format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
|
|
788
796
|
format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
|
|
789
797
|
}
|
|
@@ -864,7 +872,9 @@ module.exports = (() => {
|
|
|
864
872
|
actual.unrealized = updates.unrealized;
|
|
865
873
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
866
874
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
875
|
+
|
|
867
876
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
877
|
+
actual.totalPercent = calculateGainPercent(actual.total, actual.totalDivisor);
|
|
868
878
|
|
|
869
879
|
let marketChange = updates.market.subtract(actual.marketPrevious);
|
|
870
880
|
let marketChangePercent;
|
|
@@ -902,17 +912,19 @@ module.exports = (() => {
|
|
|
902
912
|
|
|
903
913
|
format.total = formatCurrency(actual.total, currency);
|
|
904
914
|
format.totalNegative = actual.total.getIsNegative();
|
|
915
|
+
format.totalPercent = formatPercent(actual.totalPercent, 2);
|
|
905
916
|
|
|
906
917
|
format.marketChange = formatCurrency(actual.marketChange, currency);
|
|
907
918
|
format.marketChangePercent = formatPercent(actual.marketChangePercent, 2);
|
|
908
919
|
|
|
920
|
+
calculateRealizedPercent(group);
|
|
909
921
|
calculateUnrealizedPercent(group);
|
|
910
922
|
|
|
923
|
+
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
924
|
+
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
925
|
+
|
|
911
926
|
if (group.single && item) {
|
|
912
927
|
actual.periodUnrealized = item.data.periodUnrealized;
|
|
913
|
-
|
|
914
|
-
actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
915
|
-
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
916
928
|
}
|
|
917
929
|
}
|
|
918
930
|
|
|
@@ -959,21 +971,43 @@ module.exports = (() => {
|
|
|
959
971
|
}
|
|
960
972
|
}
|
|
961
973
|
|
|
974
|
+
function calculateRealizedPercent(group) {
|
|
975
|
+
const actual = group._dataActual;
|
|
976
|
+
const format = group._dataFormat;
|
|
977
|
+
|
|
978
|
+
const openBasis = actual.basis;
|
|
979
|
+
const totalBasis = actual.totalDivisor;
|
|
980
|
+
|
|
981
|
+
const numerator = actual.realized;
|
|
982
|
+
const denominator = totalBasis.subtract(openBasis);
|
|
983
|
+
|
|
984
|
+
if (denominator.getIsZero()) {
|
|
985
|
+
actual.realizedPercent = Decimal.ZERO;
|
|
986
|
+
} else {
|
|
987
|
+
actual.realizedPercent = numerator.divide(denominator);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
format.realizedPercent = formatPercent(actual.realizedPercent, 2);
|
|
991
|
+
}
|
|
992
|
+
|
|
962
993
|
function calculateUnrealizedPercent(group) {
|
|
963
994
|
const actual = group._dataActual;
|
|
964
995
|
const format = group._dataFormat;
|
|
965
996
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
997
|
+
const numerator = actual.unrealized;
|
|
998
|
+
const denominator = actual.basis;
|
|
999
|
+
|
|
1000
|
+
if (denominator.getIsZero()) {
|
|
1001
|
+
actual.unrealizedPercent = Decimal.ZERO;
|
|
969
1002
|
} else {
|
|
970
|
-
actual.unrealizedPercent =
|
|
971
|
-
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
1003
|
+
actual.unrealizedPercent = numerator.divide(denominator);
|
|
972
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
973
1007
|
}
|
|
974
1008
|
|
|
975
|
-
function
|
|
976
|
-
return
|
|
1009
|
+
function calculateGainPercent(gain, basis) {
|
|
1010
|
+
return basis.getIsZero() ? Decimal.ZERO : gain.divide(basis);
|
|
977
1011
|
}
|
|
978
1012
|
|
|
979
1013
|
const unchanged = { up: false, down: false };
|
|
@@ -94,6 +94,8 @@ module.exports = (() => {
|
|
|
94
94
|
|
|
95
95
|
this._data.initiate = null;
|
|
96
96
|
|
|
97
|
+
this._data.totalDivisor = null;
|
|
98
|
+
|
|
97
99
|
this._data.newsExists = false;
|
|
98
100
|
this._data.fundamental = { };
|
|
99
101
|
this._data.locked = getIsLocked(position);
|
|
@@ -447,6 +449,8 @@ module.exports = (() => {
|
|
|
447
449
|
} else {
|
|
448
450
|
data.periodPricePrevious = null;
|
|
449
451
|
}
|
|
452
|
+
|
|
453
|
+
data.totalDivisor = calculateTotalDivisor(position.instrument.type, data.initiate, currentSummary);
|
|
450
454
|
}
|
|
451
455
|
|
|
452
456
|
function calculatePriceData(item, price) {
|
|
@@ -641,6 +645,22 @@ module.exports = (() => {
|
|
|
641
645
|
return returnRef;
|
|
642
646
|
}
|
|
643
647
|
|
|
648
|
+
function calculateTotalDivisor(type, direction, finalSummary) {
|
|
649
|
+
let returnRef;
|
|
650
|
+
|
|
651
|
+
if (finalSummary && type !== InstrumentType.CASH) {
|
|
652
|
+
if (direction === PositionDirection.SHORT) {
|
|
653
|
+
returnRef = finalSummary.period.sells;
|
|
654
|
+
} else {
|
|
655
|
+
returnRef = finalSummary.period.buys.opposite();
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
returnRef = Decimal.ZERO;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
return returnRef;
|
|
662
|
+
}
|
|
663
|
+
|
|
644
664
|
function getPreviousSummary(previousSummaries, count) {
|
|
645
665
|
const index = previousSummaries.length - count;
|
|
646
666
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -2659,6 +2659,7 @@ module.exports = (() => {
|
|
|
2659
2659
|
this._dataActual.marketChange = null;
|
|
2660
2660
|
this._dataActual.marketChangePercent = null;
|
|
2661
2661
|
this._dataActual.cashTotal = null;
|
|
2662
|
+
this._dataActual.totalDivisor = null;
|
|
2662
2663
|
this._dataActual.periodDivisorCurrent = null;
|
|
2663
2664
|
this._dataActual.periodDivisorPrevious = null;
|
|
2664
2665
|
this._dataActual.periodDivisorPrevious2 = null;
|
|
@@ -2666,6 +2667,7 @@ module.exports = (() => {
|
|
|
2666
2667
|
this._dataFormat.currentPrice = null;
|
|
2667
2668
|
this._dataFormat.basis = null;
|
|
2668
2669
|
this._dataFormat.realized = null;
|
|
2670
|
+
this._dataFormat.realizedPercent = null;
|
|
2669
2671
|
this._dataFormat.income = null;
|
|
2670
2672
|
this._dataFormat.market = null;
|
|
2671
2673
|
this._dataFormat.marketPercent = null;
|
|
@@ -2705,10 +2707,12 @@ module.exports = (() => {
|
|
|
2705
2707
|
this._dataFormat.periodRealized = null;
|
|
2706
2708
|
this._dataFormat.periodUnrealized = null;
|
|
2707
2709
|
|
|
2710
|
+
this._dataActual.totalPercent = null;
|
|
2708
2711
|
this._dataActual.periodPercent = null;
|
|
2709
2712
|
this._dataActual.periodPercentPrevious = null;
|
|
2710
2713
|
this._dataActual.periodPercentPrevious2 = null;
|
|
2711
2714
|
|
|
2715
|
+
this._dataFormat.totalPercent = null;
|
|
2712
2716
|
this._dataFormat.periodPercent = null;
|
|
2713
2717
|
this._dataFormat.periodPercentPrevious = null;
|
|
2714
2718
|
this._dataFormat.periodPercentPrevious2 = null;
|
|
@@ -3217,6 +3221,7 @@ module.exports = (() => {
|
|
|
3217
3221
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
3218
3222
|
}
|
|
3219
3223
|
|
|
3224
|
+
updates.totalDivisor = updates.periodDivisorCurrent.add(translate(item, item.data.totalDivisor));
|
|
3220
3225
|
updates.periodDivisorCurrent = updates.periodDivisorCurrent.add(translate(item, item.data.periodDivisor));
|
|
3221
3226
|
updates.periodDivisorPrevious = updates.periodDivisorPrevious.add(translate(item, item.data.periodDivisorPrevious));
|
|
3222
3227
|
updates.periodDivisorPrevious2 = updates.periodDivisorPrevious2.add(translate(item, item.data.periodDivisorPrevious2));
|
|
@@ -3236,6 +3241,7 @@ module.exports = (() => {
|
|
|
3236
3241
|
periodUnrealized: Decimal.ZERO,
|
|
3237
3242
|
periodIncome: Decimal.ZERO,
|
|
3238
3243
|
cashTotal: Decimal.ZERO,
|
|
3244
|
+
totalDivisor: Decimal.ZERO,
|
|
3239
3245
|
periodDivisorCurrent: Decimal.ZERO,
|
|
3240
3246
|
periodDivisorPrevious: Decimal.ZERO,
|
|
3241
3247
|
periodDivisorPrevious2: Decimal.ZERO
|
|
@@ -3254,6 +3260,7 @@ module.exports = (() => {
|
|
|
3254
3260
|
actual.periodUnrealized = updates.periodUnrealized;
|
|
3255
3261
|
actual.periodIncome = updates.periodIncome;
|
|
3256
3262
|
actual.cashTotal = updates.cashTotal;
|
|
3263
|
+
actual.totalDivisor = updates.totalDivisor;
|
|
3257
3264
|
actual.periodDivisorCurrent = updates.periodDivisorCurrent;
|
|
3258
3265
|
actual.periodDivisorPrevious = updates.periodDivisorPrevious;
|
|
3259
3266
|
actual.periodDivisorPrevious2 = updates.periodDivisorPrevious2;
|
|
@@ -3275,8 +3282,17 @@ module.exports = (() => {
|
|
|
3275
3282
|
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
3276
3283
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
3277
3284
|
|
|
3285
|
+
calculateRealizedPercent(group);
|
|
3278
3286
|
calculateUnrealizedPercent(group);
|
|
3279
3287
|
|
|
3288
|
+
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
3289
|
+
actual.periodPercentPrevious = calculateGainPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
|
|
3290
|
+
actual.periodPercentPrevious2 = calculateGainPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
|
|
3291
|
+
|
|
3292
|
+
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
3293
|
+
format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
|
|
3294
|
+
format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
|
|
3295
|
+
|
|
3280
3296
|
const groupItems = group._items;
|
|
3281
3297
|
|
|
3282
3298
|
if (group.single && groupItems.length === 1) {
|
|
@@ -3284,28 +3300,20 @@ module.exports = (() => {
|
|
|
3284
3300
|
|
|
3285
3301
|
actual.quantity = item.data.quantity;
|
|
3286
3302
|
actual.quantityPrevious = item.data.quantityPrevious;
|
|
3287
|
-
|
|
3288
|
-
actual.basisPrice = item.data.basisPrice;
|
|
3289
|
-
|
|
3290
|
-
actual.periodPrice = item.data.periodPrice;
|
|
3291
|
-
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
3292
3303
|
|
|
3293
3304
|
format.quantity = formatDecimal(actual.quantity, 2);
|
|
3294
3305
|
format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
|
|
3295
3306
|
|
|
3307
|
+
actual.basisPrice = item.data.basisPrice;
|
|
3308
|
+
|
|
3296
3309
|
format.basisPrice = formatCurrency(actual.basisPrice, currency);
|
|
3297
3310
|
|
|
3311
|
+
actual.periodPrice = item.data.periodPrice;
|
|
3312
|
+
actual.periodPricePrevious = item.data.periodPricePrevious;
|
|
3313
|
+
|
|
3298
3314
|
format.periodPrice = formatCurrency(actual.periodPrice, currency);
|
|
3299
3315
|
format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
|
|
3300
3316
|
|
|
3301
|
-
actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
3302
|
-
actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
|
|
3303
|
-
actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
|
|
3304
|
-
|
|
3305
|
-
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
3306
|
-
format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
|
|
3307
|
-
format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
|
|
3308
|
-
|
|
3309
3317
|
format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
|
|
3310
3318
|
format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
|
|
3311
3319
|
}
|
|
@@ -3386,7 +3394,9 @@ module.exports = (() => {
|
|
|
3386
3394
|
actual.unrealized = updates.unrealized;
|
|
3387
3395
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
3388
3396
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
3397
|
+
|
|
3389
3398
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
3399
|
+
actual.totalPercent = calculateGainPercent(actual.total, actual.totalDivisor);
|
|
3390
3400
|
|
|
3391
3401
|
let marketChange = updates.market.subtract(actual.marketPrevious);
|
|
3392
3402
|
let marketChangePercent;
|
|
@@ -3424,17 +3434,19 @@ module.exports = (() => {
|
|
|
3424
3434
|
|
|
3425
3435
|
format.total = formatCurrency(actual.total, currency);
|
|
3426
3436
|
format.totalNegative = actual.total.getIsNegative();
|
|
3437
|
+
format.totalPercent = formatPercent(actual.totalPercent, 2);
|
|
3427
3438
|
|
|
3428
3439
|
format.marketChange = formatCurrency(actual.marketChange, currency);
|
|
3429
3440
|
format.marketChangePercent = formatPercent(actual.marketChangePercent, 2);
|
|
3430
3441
|
|
|
3442
|
+
calculateRealizedPercent(group);
|
|
3431
3443
|
calculateUnrealizedPercent(group);
|
|
3432
3444
|
|
|
3445
|
+
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
3446
|
+
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
3447
|
+
|
|
3433
3448
|
if (group.single && item) {
|
|
3434
3449
|
actual.periodUnrealized = item.data.periodUnrealized;
|
|
3435
|
-
|
|
3436
|
-
actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
3437
|
-
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
3438
3450
|
}
|
|
3439
3451
|
}
|
|
3440
3452
|
|
|
@@ -3481,21 +3493,43 @@ module.exports = (() => {
|
|
|
3481
3493
|
}
|
|
3482
3494
|
}
|
|
3483
3495
|
|
|
3496
|
+
function calculateRealizedPercent(group) {
|
|
3497
|
+
const actual = group._dataActual;
|
|
3498
|
+
const format = group._dataFormat;
|
|
3499
|
+
|
|
3500
|
+
const openBasis = actual.basis;
|
|
3501
|
+
const totalBasis = actual.totalDivisor;
|
|
3502
|
+
|
|
3503
|
+
const numerator = actual.realized;
|
|
3504
|
+
const denominator = totalBasis.subtract(openBasis);
|
|
3505
|
+
|
|
3506
|
+
if (denominator.getIsZero()) {
|
|
3507
|
+
actual.realizedPercent = Decimal.ZERO;
|
|
3508
|
+
} else {
|
|
3509
|
+
actual.realizedPercent = numerator.divide(denominator);
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
format.realizedPercent = formatPercent(actual.realizedPercent, 2);
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3484
3515
|
function calculateUnrealizedPercent(group) {
|
|
3485
3516
|
const actual = group._dataActual;
|
|
3486
3517
|
const format = group._dataFormat;
|
|
3487
3518
|
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3519
|
+
const numerator = actual.unrealized;
|
|
3520
|
+
const denominator = actual.basis;
|
|
3521
|
+
|
|
3522
|
+
if (denominator.getIsZero()) {
|
|
3523
|
+
actual.unrealizedPercent = Decimal.ZERO;
|
|
3491
3524
|
} else {
|
|
3492
|
-
actual.unrealizedPercent =
|
|
3493
|
-
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
3525
|
+
actual.unrealizedPercent = numerator.divide(denominator);
|
|
3494
3526
|
}
|
|
3527
|
+
|
|
3528
|
+
format.unrealizedPercent = formatPercent(actual.unrealizedPercent, 2);
|
|
3495
3529
|
}
|
|
3496
3530
|
|
|
3497
|
-
function
|
|
3498
|
-
return
|
|
3531
|
+
function calculateGainPercent(gain, basis) {
|
|
3532
|
+
return basis.getIsZero() ? Decimal.ZERO : gain.divide(basis);
|
|
3499
3533
|
}
|
|
3500
3534
|
|
|
3501
3535
|
const unchanged = { up: false, down: false };
|
|
@@ -3600,6 +3634,8 @@ module.exports = (() => {
|
|
|
3600
3634
|
|
|
3601
3635
|
this._data.initiate = null;
|
|
3602
3636
|
|
|
3637
|
+
this._data.totalDivisor = null;
|
|
3638
|
+
|
|
3603
3639
|
this._data.newsExists = false;
|
|
3604
3640
|
this._data.fundamental = { };
|
|
3605
3641
|
this._data.locked = getIsLocked(position);
|
|
@@ -3953,6 +3989,8 @@ module.exports = (() => {
|
|
|
3953
3989
|
} else {
|
|
3954
3990
|
data.periodPricePrevious = null;
|
|
3955
3991
|
}
|
|
3992
|
+
|
|
3993
|
+
data.totalDivisor = calculateTotalDivisor(position.instrument.type, data.initiate, currentSummary);
|
|
3956
3994
|
}
|
|
3957
3995
|
|
|
3958
3996
|
function calculatePriceData(item, price) {
|
|
@@ -4147,6 +4185,22 @@ module.exports = (() => {
|
|
|
4147
4185
|
return returnRef;
|
|
4148
4186
|
}
|
|
4149
4187
|
|
|
4188
|
+
function calculateTotalDivisor(type, direction, finalSummary) {
|
|
4189
|
+
let returnRef;
|
|
4190
|
+
|
|
4191
|
+
if (finalSummary && type !== InstrumentType.CASH) {
|
|
4192
|
+
if (direction === PositionDirection.SHORT) {
|
|
4193
|
+
returnRef = finalSummary.period.sells;
|
|
4194
|
+
} else {
|
|
4195
|
+
returnRef = finalSummary.period.buys.opposite();
|
|
4196
|
+
}
|
|
4197
|
+
} else {
|
|
4198
|
+
returnRef = Decimal.ZERO;
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
return returnRef;
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4150
4204
|
function getPreviousSummary(previousSummaries, count) {
|
|
4151
4205
|
const index = previousSummaries.length - count;
|
|
4152
4206
|
|
|
@@ -13997,22 +14051,36 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
13997
14051
|
function createDate (y, m, d, h, M, s, ms) {
|
|
13998
14052
|
// can't just apply() to create a date:
|
|
13999
14053
|
// https://stackoverflow.com/q/181348
|
|
14000
|
-
var date
|
|
14001
|
-
|
|
14054
|
+
var date;
|
|
14002
14055
|
// the date constructor remaps years 0-99 to 1900-1999
|
|
14003
|
-
if (y < 100 && y >= 0
|
|
14004
|
-
|
|
14056
|
+
if (y < 100 && y >= 0) {
|
|
14057
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
14058
|
+
date = new Date(y + 400, m, d, h, M, s, ms);
|
|
14059
|
+
if (isFinite(date.getFullYear())) {
|
|
14060
|
+
date.setFullYear(y);
|
|
14061
|
+
}
|
|
14062
|
+
} else {
|
|
14063
|
+
date = new Date(y, m, d, h, M, s, ms);
|
|
14005
14064
|
}
|
|
14065
|
+
|
|
14006
14066
|
return date;
|
|
14007
14067
|
}
|
|
14008
14068
|
|
|
14009
14069
|
function createUTCDate (y) {
|
|
14010
|
-
var date
|
|
14011
|
-
|
|
14070
|
+
var date;
|
|
14012
14071
|
// the Date.UTC function remaps years 0-99 to 1900-1999
|
|
14013
|
-
if (y < 100 && y >= 0
|
|
14014
|
-
|
|
14072
|
+
if (y < 100 && y >= 0) {
|
|
14073
|
+
var args = Array.prototype.slice.call(arguments);
|
|
14074
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
14075
|
+
args[0] = y + 400;
|
|
14076
|
+
date = new Date(Date.UTC.apply(null, args));
|
|
14077
|
+
if (isFinite(date.getUTCFullYear())) {
|
|
14078
|
+
date.setUTCFullYear(y);
|
|
14079
|
+
}
|
|
14080
|
+
} else {
|
|
14081
|
+
date = new Date(Date.UTC.apply(null, arguments));
|
|
14015
14082
|
}
|
|
14083
|
+
|
|
14016
14084
|
return date;
|
|
14017
14085
|
}
|
|
14018
14086
|
|
|
@@ -14114,7 +14182,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14114
14182
|
|
|
14115
14183
|
var defaultLocaleWeek = {
|
|
14116
14184
|
dow : 0, // Sunday is the first day of the week.
|
|
14117
|
-
doy : 6 // The week that contains Jan
|
|
14185
|
+
doy : 6 // The week that contains Jan 6th is the first week of the year.
|
|
14118
14186
|
};
|
|
14119
14187
|
|
|
14120
14188
|
function localeFirstDayOfWeek () {
|
|
@@ -14223,25 +14291,28 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14223
14291
|
}
|
|
14224
14292
|
|
|
14225
14293
|
// LOCALES
|
|
14294
|
+
function shiftWeekdays (ws, n) {
|
|
14295
|
+
return ws.slice(n, 7).concat(ws.slice(0, n));
|
|
14296
|
+
}
|
|
14226
14297
|
|
|
14227
14298
|
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
|
14228
14299
|
function localeWeekdays (m, format) {
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
return isArray(this._weekdays) ? this._weekdays[m.day()] :
|
|
14234
|
-
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
|
|
14300
|
+
var weekdays = isArray(this._weekdays) ? this._weekdays :
|
|
14301
|
+
this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
|
|
14302
|
+
return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
|
|
14303
|
+
: (m) ? weekdays[m.day()] : weekdays;
|
|
14235
14304
|
}
|
|
14236
14305
|
|
|
14237
14306
|
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
|
14238
14307
|
function localeWeekdaysShort (m) {
|
|
14239
|
-
return (m) ? this._weekdaysShort
|
|
14308
|
+
return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
|
|
14309
|
+
: (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
|
14240
14310
|
}
|
|
14241
14311
|
|
|
14242
14312
|
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
|
14243
14313
|
function localeWeekdaysMin (m) {
|
|
14244
|
-
return (m) ? this._weekdaysMin
|
|
14314
|
+
return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
|
|
14315
|
+
: (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
|
14245
14316
|
}
|
|
14246
14317
|
|
|
14247
14318
|
function handleStrictParse$1(weekdayName, format, strict) {
|
|
@@ -14990,13 +15061,13 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14990
15061
|
weekdayOverflow = true;
|
|
14991
15062
|
}
|
|
14992
15063
|
} else if (w.e != null) {
|
|
14993
|
-
// local weekday -- counting starts from
|
|
15064
|
+
// local weekday -- counting starts from beginning of week
|
|
14994
15065
|
weekday = w.e + dow;
|
|
14995
15066
|
if (w.e < 0 || w.e > 6) {
|
|
14996
15067
|
weekdayOverflow = true;
|
|
14997
15068
|
}
|
|
14998
15069
|
} else {
|
|
14999
|
-
// default to
|
|
15070
|
+
// default to beginning of week
|
|
15000
15071
|
weekday = dow;
|
|
15001
15072
|
}
|
|
15002
15073
|
}
|
|
@@ -15590,7 +15661,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15590
15661
|
years = normalizedInput.year || 0,
|
|
15591
15662
|
quarters = normalizedInput.quarter || 0,
|
|
15592
15663
|
months = normalizedInput.month || 0,
|
|
15593
|
-
weeks = normalizedInput.week || 0,
|
|
15664
|
+
weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
|
15594
15665
|
days = normalizedInput.day || 0,
|
|
15595
15666
|
hours = normalizedInput.hour || 0,
|
|
15596
15667
|
minutes = normalizedInput.minute || 0,
|
|
@@ -15894,7 +15965,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15894
15965
|
ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
|
|
15895
15966
|
};
|
|
15896
15967
|
} else if (!!(match = isoRegex.exec(input))) {
|
|
15897
|
-
sign = (match[1] === '-') ? -1 :
|
|
15968
|
+
sign = (match[1] === '-') ? -1 : 1;
|
|
15898
15969
|
duration = {
|
|
15899
15970
|
y : parseIso(match[2], sign),
|
|
15900
15971
|
M : parseIso(match[3], sign),
|
|
@@ -15936,7 +16007,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15936
16007
|
}
|
|
15937
16008
|
|
|
15938
16009
|
function positiveMomentsDifference(base, other) {
|
|
15939
|
-
var res = {
|
|
16010
|
+
var res = {};
|
|
15940
16011
|
|
|
15941
16012
|
res.months = other.month() - base.month() +
|
|
15942
16013
|
(other.year() - base.year()) * 12;
|
|
@@ -16045,7 +16116,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16045
16116
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16046
16117
|
return false;
|
|
16047
16118
|
}
|
|
16048
|
-
units = normalizeUnits(
|
|
16119
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16049
16120
|
if (units === 'millisecond') {
|
|
16050
16121
|
return this.valueOf() > localInput.valueOf();
|
|
16051
16122
|
} else {
|
|
@@ -16058,7 +16129,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16058
16129
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16059
16130
|
return false;
|
|
16060
16131
|
}
|
|
16061
|
-
units = normalizeUnits(
|
|
16132
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16062
16133
|
if (units === 'millisecond') {
|
|
16063
16134
|
return this.valueOf() < localInput.valueOf();
|
|
16064
16135
|
} else {
|
|
@@ -16067,9 +16138,14 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16067
16138
|
}
|
|
16068
16139
|
|
|
16069
16140
|
function isBetween (from, to, units, inclusivity) {
|
|
16141
|
+
var localFrom = isMoment(from) ? from : createLocal(from),
|
|
16142
|
+
localTo = isMoment(to) ? to : createLocal(to);
|
|
16143
|
+
if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
|
16144
|
+
return false;
|
|
16145
|
+
}
|
|
16070
16146
|
inclusivity = inclusivity || '()';
|
|
16071
|
-
return (inclusivity[0] === '(' ? this.isAfter(
|
|
16072
|
-
(inclusivity[1] === ')' ? this.isBefore(
|
|
16147
|
+
return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
|
|
16148
|
+
(inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
|
16073
16149
|
}
|
|
16074
16150
|
|
|
16075
16151
|
function isSame (input, units) {
|
|
@@ -16078,7 +16154,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16078
16154
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16079
16155
|
return false;
|
|
16080
16156
|
}
|
|
16081
|
-
units = normalizeUnits(units || 'millisecond'
|
|
16157
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16082
16158
|
if (units === 'millisecond') {
|
|
16083
16159
|
return this.valueOf() === localInput.valueOf();
|
|
16084
16160
|
} else {
|
|
@@ -16088,11 +16164,11 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16088
16164
|
}
|
|
16089
16165
|
|
|
16090
16166
|
function isSameOrAfter (input, units) {
|
|
16091
|
-
return this.isSame(input, units) || this.isAfter(input,units);
|
|
16167
|
+
return this.isSame(input, units) || this.isAfter(input, units);
|
|
16092
16168
|
}
|
|
16093
16169
|
|
|
16094
16170
|
function isSameOrBefore (input, units) {
|
|
16095
|
-
return this.isSame(input, units) || this.isBefore(input,units);
|
|
16171
|
+
return this.isSame(input, units) || this.isBefore(input, units);
|
|
16096
16172
|
}
|
|
16097
16173
|
|
|
16098
16174
|
function diff (input, units, asFloat) {
|
|
@@ -16269,62 +16345,130 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16269
16345
|
return this._locale;
|
|
16270
16346
|
}
|
|
16271
16347
|
|
|
16348
|
+
var MS_PER_SECOND = 1000;
|
|
16349
|
+
var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
|
16350
|
+
var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
16351
|
+
var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
|
16352
|
+
|
|
16353
|
+
// actual modulo - handles negative numbers (for dates before 1970):
|
|
16354
|
+
function mod$1(dividend, divisor) {
|
|
16355
|
+
return (dividend % divisor + divisor) % divisor;
|
|
16356
|
+
}
|
|
16357
|
+
|
|
16358
|
+
function localStartOfDate(y, m, d) {
|
|
16359
|
+
// the date constructor remaps years 0-99 to 1900-1999
|
|
16360
|
+
if (y < 100 && y >= 0) {
|
|
16361
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
16362
|
+
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
|
16363
|
+
} else {
|
|
16364
|
+
return new Date(y, m, d).valueOf();
|
|
16365
|
+
}
|
|
16366
|
+
}
|
|
16367
|
+
|
|
16368
|
+
function utcStartOfDate(y, m, d) {
|
|
16369
|
+
// Date.UTC remaps years 0-99 to 1900-1999
|
|
16370
|
+
if (y < 100 && y >= 0) {
|
|
16371
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
16372
|
+
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
|
16373
|
+
} else {
|
|
16374
|
+
return Date.UTC(y, m, d);
|
|
16375
|
+
}
|
|
16376
|
+
}
|
|
16377
|
+
|
|
16272
16378
|
function startOf (units) {
|
|
16379
|
+
var time;
|
|
16273
16380
|
units = normalizeUnits(units);
|
|
16274
|
-
|
|
16275
|
-
|
|
16381
|
+
if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
|
16382
|
+
return this;
|
|
16383
|
+
}
|
|
16384
|
+
|
|
16385
|
+
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
|
16386
|
+
|
|
16276
16387
|
switch (units) {
|
|
16277
16388
|
case 'year':
|
|
16278
|
-
this.
|
|
16279
|
-
|
|
16389
|
+
time = startOfDate(this.year(), 0, 1);
|
|
16390
|
+
break;
|
|
16280
16391
|
case 'quarter':
|
|
16392
|
+
time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
|
16393
|
+
break;
|
|
16281
16394
|
case 'month':
|
|
16282
|
-
this.
|
|
16283
|
-
|
|
16395
|
+
time = startOfDate(this.year(), this.month(), 1);
|
|
16396
|
+
break;
|
|
16284
16397
|
case 'week':
|
|
16398
|
+
time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
|
16399
|
+
break;
|
|
16285
16400
|
case 'isoWeek':
|
|
16401
|
+
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
|
16402
|
+
break;
|
|
16286
16403
|
case 'day':
|
|
16287
16404
|
case 'date':
|
|
16288
|
-
this.
|
|
16289
|
-
|
|
16405
|
+
time = startOfDate(this.year(), this.month(), this.date());
|
|
16406
|
+
break;
|
|
16290
16407
|
case 'hour':
|
|
16291
|
-
this.
|
|
16292
|
-
|
|
16408
|
+
time = this._d.valueOf();
|
|
16409
|
+
time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
|
16410
|
+
break;
|
|
16293
16411
|
case 'minute':
|
|
16294
|
-
this.
|
|
16295
|
-
|
|
16412
|
+
time = this._d.valueOf();
|
|
16413
|
+
time -= mod$1(time, MS_PER_MINUTE);
|
|
16414
|
+
break;
|
|
16296
16415
|
case 'second':
|
|
16297
|
-
this.
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
// weeks are a special case
|
|
16301
|
-
if (units === 'week') {
|
|
16302
|
-
this.weekday(0);
|
|
16303
|
-
}
|
|
16304
|
-
if (units === 'isoWeek') {
|
|
16305
|
-
this.isoWeekday(1);
|
|
16306
|
-
}
|
|
16307
|
-
|
|
16308
|
-
// quarters are also special
|
|
16309
|
-
if (units === 'quarter') {
|
|
16310
|
-
this.month(Math.floor(this.month() / 3) * 3);
|
|
16416
|
+
time = this._d.valueOf();
|
|
16417
|
+
time -= mod$1(time, MS_PER_SECOND);
|
|
16418
|
+
break;
|
|
16311
16419
|
}
|
|
16312
16420
|
|
|
16421
|
+
this._d.setTime(time);
|
|
16422
|
+
hooks.updateOffset(this, true);
|
|
16313
16423
|
return this;
|
|
16314
16424
|
}
|
|
16315
16425
|
|
|
16316
16426
|
function endOf (units) {
|
|
16427
|
+
var time;
|
|
16317
16428
|
units = normalizeUnits(units);
|
|
16318
|
-
if (units === undefined || units === 'millisecond') {
|
|
16429
|
+
if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
|
16319
16430
|
return this;
|
|
16320
16431
|
}
|
|
16321
16432
|
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16433
|
+
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
|
16434
|
+
|
|
16435
|
+
switch (units) {
|
|
16436
|
+
case 'year':
|
|
16437
|
+
time = startOfDate(this.year() + 1, 0, 1) - 1;
|
|
16438
|
+
break;
|
|
16439
|
+
case 'quarter':
|
|
16440
|
+
time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
|
16441
|
+
break;
|
|
16442
|
+
case 'month':
|
|
16443
|
+
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
|
16444
|
+
break;
|
|
16445
|
+
case 'week':
|
|
16446
|
+
time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
|
16447
|
+
break;
|
|
16448
|
+
case 'isoWeek':
|
|
16449
|
+
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
|
16450
|
+
break;
|
|
16451
|
+
case 'day':
|
|
16452
|
+
case 'date':
|
|
16453
|
+
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
|
16454
|
+
break;
|
|
16455
|
+
case 'hour':
|
|
16456
|
+
time = this._d.valueOf();
|
|
16457
|
+
time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
|
16458
|
+
break;
|
|
16459
|
+
case 'minute':
|
|
16460
|
+
time = this._d.valueOf();
|
|
16461
|
+
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
|
16462
|
+
break;
|
|
16463
|
+
case 'second':
|
|
16464
|
+
time = this._d.valueOf();
|
|
16465
|
+
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
|
16466
|
+
break;
|
|
16325
16467
|
}
|
|
16326
16468
|
|
|
16327
|
-
|
|
16469
|
+
this._d.setTime(time);
|
|
16470
|
+
hooks.updateOffset(this, true);
|
|
16471
|
+
return this;
|
|
16328
16472
|
}
|
|
16329
16473
|
|
|
16330
16474
|
function valueOf () {
|
|
@@ -17030,10 +17174,14 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17030
17174
|
|
|
17031
17175
|
units = normalizeUnits(units);
|
|
17032
17176
|
|
|
17033
|
-
if (units === 'month' || units === 'year') {
|
|
17034
|
-
days
|
|
17177
|
+
if (units === 'month' || units === 'quarter' || units === 'year') {
|
|
17178
|
+
days = this._days + milliseconds / 864e5;
|
|
17035
17179
|
months = this._months + daysToMonths(days);
|
|
17036
|
-
|
|
17180
|
+
switch (units) {
|
|
17181
|
+
case 'month': return months;
|
|
17182
|
+
case 'quarter': return months / 3;
|
|
17183
|
+
case 'year': return months / 12;
|
|
17184
|
+
}
|
|
17037
17185
|
} else {
|
|
17038
17186
|
// handle milliseconds separately because of floating point math errors (issue #1867)
|
|
17039
17187
|
days = this._days + Math.round(monthsToDays(this._months));
|
|
@@ -17076,6 +17224,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17076
17224
|
var asDays = makeAs('d');
|
|
17077
17225
|
var asWeeks = makeAs('w');
|
|
17078
17226
|
var asMonths = makeAs('M');
|
|
17227
|
+
var asQuarters = makeAs('Q');
|
|
17079
17228
|
var asYears = makeAs('y');
|
|
17080
17229
|
|
|
17081
17230
|
function clone$1 () {
|
|
@@ -17267,6 +17416,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17267
17416
|
proto$2.asDays = asDays;
|
|
17268
17417
|
proto$2.asWeeks = asWeeks;
|
|
17269
17418
|
proto$2.asMonths = asMonths;
|
|
17419
|
+
proto$2.asQuarters = asQuarters;
|
|
17270
17420
|
proto$2.asYears = asYears;
|
|
17271
17421
|
proto$2.valueOf = valueOf$1;
|
|
17272
17422
|
proto$2._bubble = bubble;
|
|
@@ -17311,7 +17461,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17311
17461
|
// Side effect imports
|
|
17312
17462
|
|
|
17313
17463
|
|
|
17314
|
-
hooks.version = '2.
|
|
17464
|
+
hooks.version = '2.24.0';
|
|
17315
17465
|
|
|
17316
17466
|
setHookCallback(createLocal);
|
|
17317
17467
|
|
|
@@ -17352,7 +17502,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17352
17502
|
TIME: 'HH:mm', // <input type="time" />
|
|
17353
17503
|
TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
|
|
17354
17504
|
TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
|
|
17355
|
-
WEEK: '
|
|
17505
|
+
WEEK: 'GGGG-[W]WW', // <input type="week" />
|
|
17356
17506
|
MONTH: 'YYYY-MM' // <input type="month" />
|
|
17357
17507
|
};
|
|
17358
17508
|
|