@oanda/labs-crowd-view-widget 1.0.52 → 1.0.53
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/CHANGELOG.md +216 -0
- package/dist/main/CrowdViewWidget/Main.js +1 -5
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +16 -6
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +15 -6
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +69 -29
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +49 -26
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +9 -10
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/index.js +0 -33
- package/dist/main/CrowdViewWidget/components/Chart/utils/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +54 -12
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +49 -27
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js +32 -17
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js +8 -2
- package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +2 -3
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +2 -2
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +2 -6
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/gql/getOrderPositionBooks.js +1 -1
- package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/main/gql/getPriceCandles.js +1 -1
- package/dist/main/gql/getPriceCandles.js.map +1 -1
- package/dist/main/gql/types/gql.js +2 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +111 -18
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/module/CrowdViewWidget/Main.js +2 -6
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +17 -7
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +15 -6
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +70 -30
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +50 -27
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +10 -11
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.js +0 -3
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +54 -12
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +49 -27
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js +32 -17
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js +8 -2
- package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +2 -3
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +2 -2
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +1 -5
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/gql/getOrderPositionBooks.js +1 -1
- package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/module/gql/getPriceCandles.js +1 -1
- package/dist/module/gql/getPriceCandles.js.map +1 -1
- package/dist/module/gql/types/gql.js +2 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +111 -18
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +28 -11
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +3 -4
- package/dist/types/CrowdViewWidget/components/Chart/utils/index.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.d.ts +10 -7
- package/dist/types/CrowdViewWidget/components/Chart/utils/processPriceCandles.d.ts +6 -21
- package/dist/types/CrowdViewWidget/components/Chart/utils/processSentiments.d.ts +5 -2
- package/dist/types/CrowdViewWidget/components/Chart/utils/validateData.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +2 -2
- package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +1 -1
- package/dist/types/CrowdViewWidget/constants.d.ts +1 -5
- package/dist/types/gql/types/gql.d.ts +6 -4
- package/dist/types/gql/types/graphql.d.ts +30 -11
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +2 -4
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +15 -6
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +21 -4
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +78 -30
- package/src/CrowdViewWidget/components/Chart/types.ts +30 -19
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +82 -65
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +32 -20
- package/src/CrowdViewWidget/components/Chart/utils/index.ts +0 -3
- package/src/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.ts +84 -22
- package/src/CrowdViewWidget/components/Chart/utils/processPriceCandles.ts +52 -38
- package/src/CrowdViewWidget/components/Chart/utils/processSentiments.ts +45 -32
- package/src/CrowdViewWidget/components/Chart/utils/validateData.ts +10 -2
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +4 -5
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +3 -3
- package/src/CrowdViewWidget/constants.ts +1 -6
- package/src/gql/getOrderPositionBooks.ts +13 -5
- package/src/gql/getPriceCandles.ts +1 -0
- package/src/gql/types/gql.ts +6 -6
- package/src/gql/types/graphql.ts +98 -16
- package/test/components/Chart/utils/chartUtils.test.ts +32 -14
- package/test/components/Chart/utils/processSentiments.test.ts +137 -29
- package/test/utils/processOrderPositionBooks.test.ts +201 -84
- package/test/utils/processPriceCandles.test.ts +93 -67
- package/test/utils/validateData.test.ts +136 -38
- package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -37
- package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js +0 -14
- package/dist/main/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -29
- package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -29
- package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js +0 -7
- package/dist/module/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -22
- package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
- package/dist/types/CrowdViewWidget/components/Chart/utils/aggregateBuckets.d.ts +0 -2
- package/dist/types/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/processBuckets.d.ts +0 -3
- package/src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts +0 -44
- package/src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts +0 -13
- package/src/CrowdViewWidget/components/Chart/utils/processBuckets.ts +0 -43
- package/test/utils/aggregateBuckets.test.ts +0 -82
- package/test/utils/getTargetBucketWidth.test.ts +0 -37
- package/test/utils/processBuckets.test.ts +0 -153
|
@@ -27,40 +27,55 @@ describe('validateData', () => {
|
|
|
27
27
|
close: 1.3,
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
|
+
pipsLocation: 0,
|
|
30
31
|
},
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
const createMockOrderPositionData = (
|
|
34
35
|
books?: Array<{
|
|
35
|
-
|
|
36
|
-
price?: number | null;
|
|
36
|
+
__typename?: 'OrderPositionData';
|
|
37
37
|
time: string;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
price?: number | null;
|
|
39
|
+
buckets: Array<{
|
|
40
|
+
__typename?: 'OrderPositionBucket';
|
|
41
|
+
price: number;
|
|
42
|
+
sentiment?: number | null;
|
|
43
|
+
} | null>;
|
|
44
|
+
}>
|
|
40
45
|
): GetOrderPositionBooksQuery => ({
|
|
41
|
-
orderPositionBooks:
|
|
42
|
-
books
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
orderPositionBooks: {
|
|
47
|
+
books:
|
|
48
|
+
books !== undefined
|
|
49
|
+
? books
|
|
50
|
+
: [
|
|
51
|
+
{
|
|
52
|
+
time: '2025-01-01T00:00:00Z',
|
|
53
|
+
price: 1.0,
|
|
54
|
+
buckets: [{ price: 1.0, sentiment: 0.2 }],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
bucketWidth: 0.0005,
|
|
58
|
+
sentimentThresholdMin: 0.15,
|
|
59
|
+
sentimentThresholdMax: 0.55,
|
|
60
|
+
},
|
|
52
61
|
});
|
|
53
62
|
|
|
54
63
|
it('should return null when all data is valid', () => {
|
|
55
64
|
const priceCandlesData = createMockPriceCandlesData();
|
|
56
65
|
const orderPositionData = createMockOrderPositionData();
|
|
57
|
-
const result = validateData(
|
|
66
|
+
const result = validateData(
|
|
67
|
+
priceCandlesData,
|
|
68
|
+
orderPositionData,
|
|
69
|
+
true,
|
|
70
|
+
true,
|
|
71
|
+
true
|
|
72
|
+
);
|
|
58
73
|
expect(result).toBeNull();
|
|
59
74
|
});
|
|
60
75
|
|
|
61
76
|
it('should return error when priceCandlesData is undefined', () => {
|
|
62
77
|
const orderPositionData = createMockOrderPositionData();
|
|
63
|
-
const result = validateData(undefined, orderPositionData, true);
|
|
78
|
+
const result = validateData(undefined, orderPositionData, true, true, true);
|
|
64
79
|
expect(result).toBeInstanceOf(Error);
|
|
65
80
|
expect(result?.message).toBe('Insufficient price candle data');
|
|
66
81
|
});
|
|
@@ -70,7 +85,13 @@ describe('validateData', () => {
|
|
|
70
85
|
priceCandles: {} as any,
|
|
71
86
|
};
|
|
72
87
|
const orderPositionData = createMockOrderPositionData();
|
|
73
|
-
const result = validateData(
|
|
88
|
+
const result = validateData(
|
|
89
|
+
priceCandlesData,
|
|
90
|
+
orderPositionData,
|
|
91
|
+
true,
|
|
92
|
+
true,
|
|
93
|
+
true
|
|
94
|
+
);
|
|
74
95
|
expect(result).toBeInstanceOf(Error);
|
|
75
96
|
expect(result?.message).toBe('Insufficient price candle data');
|
|
76
97
|
});
|
|
@@ -78,7 +99,13 @@ describe('validateData', () => {
|
|
|
78
99
|
it('should return error when candle array is empty', () => {
|
|
79
100
|
const priceCandlesData = createMockPriceCandlesData([]);
|
|
80
101
|
const orderPositionData = createMockOrderPositionData();
|
|
81
|
-
const result = validateData(
|
|
102
|
+
const result = validateData(
|
|
103
|
+
priceCandlesData,
|
|
104
|
+
orderPositionData,
|
|
105
|
+
true,
|
|
106
|
+
true,
|
|
107
|
+
true
|
|
108
|
+
);
|
|
82
109
|
expect(result).toBeInstanceOf(Error);
|
|
83
110
|
expect(result?.message).toBe('Insufficient price candle data');
|
|
84
111
|
});
|
|
@@ -89,24 +116,41 @@ describe('validateData', () => {
|
|
|
89
116
|
// The hasValidCandles parameter handles content validation
|
|
90
117
|
const priceCandlesData = createMockPriceCandlesData([null, null]);
|
|
91
118
|
const orderPositionData = createMockOrderPositionData();
|
|
92
|
-
const result = validateData(
|
|
93
|
-
|
|
119
|
+
const result = validateData(
|
|
120
|
+
priceCandlesData,
|
|
121
|
+
orderPositionData,
|
|
122
|
+
true,
|
|
123
|
+
true,
|
|
124
|
+
true
|
|
125
|
+
);
|
|
126
|
+
// Array length >= 1, so it passes length check
|
|
94
127
|
expect(result).toBeNull();
|
|
95
128
|
});
|
|
96
129
|
|
|
97
130
|
it('should return error when orderPositionData is undefined', () => {
|
|
98
131
|
const priceCandlesData = createMockPriceCandlesData();
|
|
99
|
-
const result = validateData(priceCandlesData, undefined, true);
|
|
132
|
+
const result = validateData(priceCandlesData, undefined, true, true, true);
|
|
100
133
|
expect(result).toBeInstanceOf(Error);
|
|
101
134
|
expect(result?.message).toBe('Insufficient order position data');
|
|
102
135
|
});
|
|
103
136
|
|
|
104
|
-
it('should return error when orderPositionBooks is empty', () => {
|
|
137
|
+
it('should return error when orderPositionBooks.books is empty', () => {
|
|
105
138
|
const priceCandlesData = createMockPriceCandlesData();
|
|
106
139
|
const orderPositionData: GetOrderPositionBooksQuery = {
|
|
107
|
-
orderPositionBooks:
|
|
140
|
+
orderPositionBooks: {
|
|
141
|
+
books: [],
|
|
142
|
+
bucketWidth: 0.0005,
|
|
143
|
+
sentimentThresholdMin: 0.15,
|
|
144
|
+
sentimentThresholdMax: 0.55,
|
|
145
|
+
},
|
|
108
146
|
};
|
|
109
|
-
const result = validateData(
|
|
147
|
+
const result = validateData(
|
|
148
|
+
priceCandlesData,
|
|
149
|
+
orderPositionData,
|
|
150
|
+
true,
|
|
151
|
+
true,
|
|
152
|
+
true
|
|
153
|
+
);
|
|
110
154
|
expect(result).toBeInstanceOf(Error);
|
|
111
155
|
expect(result?.message).toBe('Insufficient order position data');
|
|
112
156
|
});
|
|
@@ -114,30 +158,75 @@ describe('validateData', () => {
|
|
|
114
158
|
it('should return error when hasValidCandles is false', () => {
|
|
115
159
|
const priceCandlesData = createMockPriceCandlesData();
|
|
116
160
|
const orderPositionData = createMockOrderPositionData();
|
|
117
|
-
const result = validateData(
|
|
161
|
+
const result = validateData(
|
|
162
|
+
priceCandlesData,
|
|
163
|
+
orderPositionData,
|
|
164
|
+
false,
|
|
165
|
+
true,
|
|
166
|
+
true
|
|
167
|
+
);
|
|
118
168
|
expect(result).toBeInstanceOf(Error);
|
|
119
169
|
expect(result?.message).toBe('Invalid candle data');
|
|
120
170
|
});
|
|
121
171
|
|
|
172
|
+
it('should return error when hasValidBooks is false', () => {
|
|
173
|
+
const priceCandlesData = createMockPriceCandlesData();
|
|
174
|
+
const orderPositionData = createMockOrderPositionData();
|
|
175
|
+
const result = validateData(
|
|
176
|
+
priceCandlesData,
|
|
177
|
+
orderPositionData,
|
|
178
|
+
true,
|
|
179
|
+
false,
|
|
180
|
+
true
|
|
181
|
+
);
|
|
182
|
+
expect(result).toBeInstanceOf(Error);
|
|
183
|
+
expect(result?.message).toBe('Invalid book data');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should return error when hasValidSentiments is false', () => {
|
|
187
|
+
const priceCandlesData = createMockPriceCandlesData();
|
|
188
|
+
const orderPositionData = createMockOrderPositionData();
|
|
189
|
+
const result = validateData(
|
|
190
|
+
priceCandlesData,
|
|
191
|
+
orderPositionData,
|
|
192
|
+
true,
|
|
193
|
+
true,
|
|
194
|
+
false
|
|
195
|
+
);
|
|
196
|
+
expect(result).toBeInstanceOf(Error);
|
|
197
|
+
expect(result?.message).toBe('Invalid sentiment data');
|
|
198
|
+
});
|
|
199
|
+
|
|
122
200
|
it('should prioritize price candle error over order position error', () => {
|
|
123
201
|
const orderPositionData: GetOrderPositionBooksQuery = {
|
|
124
|
-
orderPositionBooks:
|
|
202
|
+
orderPositionBooks: {
|
|
203
|
+
books: [],
|
|
204
|
+
bucketWidth: 0.0005,
|
|
205
|
+
sentimentThresholdMin: 0.15,
|
|
206
|
+
sentimentThresholdMax: 0.55,
|
|
207
|
+
},
|
|
125
208
|
};
|
|
126
|
-
const result = validateData(undefined, orderPositionData, true);
|
|
209
|
+
const result = validateData(undefined, orderPositionData, true, true, true);
|
|
127
210
|
expect(result).toBeInstanceOf(Error);
|
|
128
211
|
expect(result?.message).toBe('Insufficient price candle data');
|
|
129
212
|
});
|
|
130
213
|
|
|
131
214
|
it('should prioritize price candle error over hasValidCandles error', () => {
|
|
132
215
|
const orderPositionData = createMockOrderPositionData();
|
|
133
|
-
const result = validateData(
|
|
216
|
+
const result = validateData(
|
|
217
|
+
undefined,
|
|
218
|
+
orderPositionData,
|
|
219
|
+
false,
|
|
220
|
+
true,
|
|
221
|
+
true
|
|
222
|
+
);
|
|
134
223
|
expect(result).toBeInstanceOf(Error);
|
|
135
224
|
expect(result?.message).toBe('Insufficient price candle data');
|
|
136
225
|
});
|
|
137
226
|
|
|
138
227
|
it('should prioritize order position error over hasValidCandles error', () => {
|
|
139
228
|
const priceCandlesData = createMockPriceCandlesData();
|
|
140
|
-
const result = validateData(priceCandlesData, undefined, false);
|
|
229
|
+
const result = validateData(priceCandlesData, undefined, false, true, true);
|
|
141
230
|
expect(result).toBeInstanceOf(Error);
|
|
142
231
|
expect(result?.message).toBe('Insufficient order position data');
|
|
143
232
|
});
|
|
@@ -154,13 +243,18 @@ describe('validateData', () => {
|
|
|
154
243
|
]);
|
|
155
244
|
const orderPositionData = createMockOrderPositionData([
|
|
156
245
|
{
|
|
157
|
-
|
|
246
|
+
time: '2025-01-01T00:00:00Z',
|
|
158
247
|
price: 1.0,
|
|
159
|
-
time: '2025-01-01',
|
|
160
248
|
buckets: [{ price: 1.0, sentiment: 0.2 }],
|
|
161
249
|
},
|
|
162
250
|
]);
|
|
163
|
-
const result = validateData(
|
|
251
|
+
const result = validateData(
|
|
252
|
+
priceCandlesData,
|
|
253
|
+
orderPositionData,
|
|
254
|
+
true,
|
|
255
|
+
true,
|
|
256
|
+
true
|
|
257
|
+
);
|
|
164
258
|
expect(result).toBeNull();
|
|
165
259
|
});
|
|
166
260
|
|
|
@@ -183,19 +277,23 @@ describe('validateData', () => {
|
|
|
183
277
|
]);
|
|
184
278
|
const orderPositionData = createMockOrderPositionData([
|
|
185
279
|
{
|
|
186
|
-
|
|
280
|
+
time: '2025-01-01T00:00:00Z',
|
|
187
281
|
price: 1.0,
|
|
188
|
-
time: '2025-01-01',
|
|
189
282
|
buckets: [{ price: 1.0, sentiment: 0.2 }],
|
|
190
283
|
},
|
|
191
284
|
{
|
|
192
|
-
|
|
285
|
+
time: '2025-01-01T01:00:00Z',
|
|
193
286
|
price: 1.1,
|
|
194
|
-
time: '2025-01-02',
|
|
195
287
|
buckets: [{ price: 1.1, sentiment: 0.3 }],
|
|
196
288
|
},
|
|
197
289
|
]);
|
|
198
|
-
const result = validateData(
|
|
290
|
+
const result = validateData(
|
|
291
|
+
priceCandlesData,
|
|
292
|
+
orderPositionData,
|
|
293
|
+
true,
|
|
294
|
+
true,
|
|
295
|
+
true
|
|
296
|
+
);
|
|
199
297
|
expect(result).toBeNull();
|
|
200
298
|
});
|
|
201
299
|
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.aggregateBuckets = void 0;
|
|
7
|
-
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const aggregateBuckets = (buckets, newBucketWidth) => {
|
|
10
|
-
if (!buckets.length) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
const bucketWidthDecimal = new _decimal.default(newBucketWidth);
|
|
14
|
-
const aggregatedMap = new Map();
|
|
15
|
-
for (const bucket of buckets) {
|
|
16
|
-
var _aggregatedMap$get;
|
|
17
|
-
const priceDecimal = new _decimal.default(bucket.price);
|
|
18
|
-
const sentimentDecimal = new _decimal.default(bucket.sentiment);
|
|
19
|
-
const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();
|
|
20
|
-
const groupingKey = bucketIndex.mul(bucketWidthDecimal);
|
|
21
|
-
const groupingKeyStr = groupingKey.toString();
|
|
22
|
-
const currentSentiment = (_aggregatedMap$get = aggregatedMap.get(groupingKeyStr)) !== null && _aggregatedMap$get !== void 0 ? _aggregatedMap$get : new _decimal.default(0);
|
|
23
|
-
aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));
|
|
24
|
-
}
|
|
25
|
-
const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(_ref => {
|
|
26
|
-
let [priceStr, sentimentDecimal] = _ref;
|
|
27
|
-
const price = new _decimal.default(priceStr).toNumber();
|
|
28
|
-
const sentiment = sentimentDecimal.toNumber();
|
|
29
|
-
return {
|
|
30
|
-
price,
|
|
31
|
-
sentiment
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
return aggregatedBuckets;
|
|
35
|
-
};
|
|
36
|
-
exports.aggregateBuckets = aggregateBuckets;
|
|
37
|
-
//# sourceMappingURL=aggregateBuckets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aggregateBuckets.js","names":["_decimal","_interopRequireDefault","require","e","__esModule","default","aggregateBuckets","buckets","newBucketWidth","length","bucketWidthDecimal","Decimal","aggregatedMap","Map","bucket","_aggregatedMap$get","priceDecimal","price","sentimentDecimal","sentiment","bucketIndex","div","floor","groupingKey","mul","groupingKeyStr","toString","currentSentiment","get","set","add","aggregatedBuckets","Array","from","entries","map","_ref","priceStr","toNumber","exports"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts"],"sourcesContent":["import Decimal from 'decimal.js';\n\nimport type { Bucket } from '../types';\n\nexport const aggregateBuckets = (\n buckets: Bucket[],\n newBucketWidth: number\n): Bucket[] => {\n if (!buckets.length) {\n return [];\n }\n\n const bucketWidthDecimal = new Decimal(newBucketWidth);\n\n const aggregatedMap = new Map<string, Decimal>();\n\n for (const bucket of buckets) {\n const priceDecimal = new Decimal(bucket.price);\n const sentimentDecimal = new Decimal(bucket.sentiment);\n\n const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();\n const groupingKey = bucketIndex.mul(bucketWidthDecimal);\n\n const groupingKeyStr = groupingKey.toString();\n\n const currentSentiment =\n aggregatedMap.get(groupingKeyStr) ?? new Decimal(0);\n aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));\n }\n\n const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(\n ([priceStr, sentimentDecimal]) => {\n const price = new Decimal(priceStr).toNumber();\n const sentiment = sentimentDecimal.toNumber();\n\n return {\n price,\n sentiment,\n };\n }\n );\n\n return aggregatedBuckets;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI1B,MAAMG,gBAAgB,GAAGA,CAC9BC,OAAiB,EACjBC,cAAsB,KACT;EACb,IAAI,CAACD,OAAO,CAACE,MAAM,EAAE;IACnB,OAAO,EAAE;EACX;EAEA,MAAMC,kBAAkB,GAAG,IAAIC,gBAAO,CAACH,cAAc,CAAC;EAEtD,MAAMI,aAAa,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAEhD,KAAK,MAAMC,MAAM,IAAIP,OAAO,EAAE;IAAA,IAAAQ,kBAAA;IAC5B,MAAMC,YAAY,GAAG,IAAIL,gBAAO,CAACG,MAAM,CAACG,KAAK,CAAC;IAC9C,MAAMC,gBAAgB,GAAG,IAAIP,gBAAO,CAACG,MAAM,CAACK,SAAS,CAAC;IAEtD,MAAMC,WAAW,GAAGJ,YAAY,CAACK,GAAG,CAACX,kBAAkB,CAAC,CAACY,KAAK,CAAC,CAAC;IAChE,MAAMC,WAAW,GAAGH,WAAW,CAACI,GAAG,CAACd,kBAAkB,CAAC;IAEvD,MAAMe,cAAc,GAAGF,WAAW,CAACG,QAAQ,CAAC,CAAC;IAE7C,MAAMC,gBAAgB,IAAAZ,kBAAA,GACpBH,aAAa,CAACgB,GAAG,CAACH,cAAc,CAAC,cAAAV,kBAAA,cAAAA,kBAAA,GAAI,IAAIJ,gBAAO,CAAC,CAAC,CAAC;IACrDC,aAAa,CAACiB,GAAG,CAACJ,cAAc,EAAEE,gBAAgB,CAACG,GAAG,CAACZ,gBAAgB,CAAC,CAAC;EAC3E;EAEA,MAAMa,iBAAiB,GAAGC,KAAK,CAACC,IAAI,CAACrB,aAAa,CAACsB,OAAO,CAAC,CAAC,CAAC,CAACC,GAAG,CAC/DC,IAAA,IAAkC;IAAA,IAAjC,CAACC,QAAQ,EAAEnB,gBAAgB,CAAC,GAAAkB,IAAA;IAC3B,MAAMnB,KAAK,GAAG,IAAIN,gBAAO,CAAC0B,QAAQ,CAAC,CAACC,QAAQ,CAAC,CAAC;IAC9C,MAAMnB,SAAS,GAAGD,gBAAgB,CAACoB,QAAQ,CAAC,CAAC;IAE7C,OAAO;MACLrB,KAAK;MACLE;IACF,CAAC;EACH,CACF,CAAC;EAED,OAAOY,iBAAiB;AAC1B,CAAC;AAACQ,OAAA,CAAAjC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTargetBucketWidth = void 0;
|
|
7
|
-
var _graphql = require("../../../../gql/types/graphql");
|
|
8
|
-
var _constants = require("../../../constants");
|
|
9
|
-
const getTargetBucketWidth = (granularity, instrument) => {
|
|
10
|
-
const bucketWidth = _constants.INSTRUMENTS_CONFIG[instrument].defaultBucketWidth;
|
|
11
|
-
return granularity === _graphql.Granularity.H1 || granularity === _graphql.Granularity.H4 ? bucketWidth * _constants.BUCKET_CONFIG.MULTIPLIER : bucketWidth;
|
|
12
|
-
};
|
|
13
|
-
exports.getTargetBucketWidth = getTargetBucketWidth;
|
|
14
|
-
//# sourceMappingURL=getTargetBucketWidth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTargetBucketWidth.js","names":["_graphql","require","_constants","getTargetBucketWidth","granularity","instrument","bucketWidth","INSTRUMENTS_CONFIG","defaultBucketWidth","Granularity","H1","H4","BUCKET_CONFIG","MULTIPLIER","exports"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts"],"sourcesContent":["import { Granularity } from '../../../../gql/types/graphql';\nimport { BUCKET_CONFIG, INSTRUMENTS_CONFIG } from '../../../constants';\nimport type { InstrumentId } from '../../../types';\n\nexport const getTargetBucketWidth = (\n granularity: Granularity,\n instrument: InstrumentId\n): number => {\n const bucketWidth = INSTRUMENTS_CONFIG[instrument].defaultBucketWidth;\n return granularity === Granularity.H1 || granularity === Granularity.H4\n ? bucketWidth * BUCKET_CONFIG.MULTIPLIER\n : bucketWidth;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,oBAAoB,GAAGA,CAClCC,WAAwB,EACxBC,UAAwB,KACb;EACX,MAAMC,WAAW,GAAGC,6BAAkB,CAACF,UAAU,CAAC,CAACG,kBAAkB;EACrE,OAAOJ,WAAW,KAAKK,oBAAW,CAACC,EAAE,IAAIN,WAAW,KAAKK,oBAAW,CAACE,EAAE,GACnEL,WAAW,GAAGM,wBAAa,CAACC,UAAU,GACtCP,WAAW;AACjB,CAAC;AAACQ,OAAA,CAAAX,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.processBuckets = void 0;
|
|
7
|
-
var _constants = require("../../../constants");
|
|
8
|
-
var _aggregateBuckets = require("./aggregateBuckets");
|
|
9
|
-
const processBuckets = (orderPositionData, targetBucketWidth) => {
|
|
10
|
-
var _orderPositionData$or;
|
|
11
|
-
if (!(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or !== void 0 && _orderPositionData$or.length)) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
return orderPositionData.orderPositionBooks.filter(book => {
|
|
15
|
-
var _book$buckets;
|
|
16
|
-
return book !== null && ((_book$buckets = book.buckets) === null || _book$buckets === void 0 ? void 0 : _book$buckets.length) > 0;
|
|
17
|
-
}).map(book => {
|
|
18
|
-
var _book$bucketWidth;
|
|
19
|
-
const validBuckets = book.buckets.filter(bucket => bucket !== null && bucket.price !== undefined && bucket.sentiment !== undefined && bucket.sentiment !== null).map(bucket => ({
|
|
20
|
-
price: bucket.price,
|
|
21
|
-
sentiment: bucket.sentiment
|
|
22
|
-
}));
|
|
23
|
-
const bucketsToFilter = targetBucketWidth > ((_book$bucketWidth = book.bucketWidth) !== null && _book$bucketWidth !== void 0 ? _book$bucketWidth : 0) ? (0, _aggregateBuckets.aggregateBuckets)(validBuckets, targetBucketWidth) : validBuckets;
|
|
24
|
-
const filteredBuckets = bucketsToFilter.filter(bucket => Math.abs(bucket.sentiment) >= _constants.BOOKS_THRESHOLDS.MIN);
|
|
25
|
-
return filteredBuckets;
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
exports.processBuckets = processBuckets;
|
|
29
|
-
//# sourceMappingURL=processBuckets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processBuckets.js","names":["_constants","require","_aggregateBuckets","processBuckets","orderPositionData","targetBucketWidth","_orderPositionData$or","orderPositionBooks","length","filter","book","_book$buckets","buckets","map","_book$bucketWidth","validBuckets","bucket","price","undefined","sentiment","bucketsToFilter","bucketWidth","aggregateBuckets","filteredBuckets","Math","abs","BOOKS_THRESHOLDS","MIN","exports"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/processBuckets.ts"],"sourcesContent":["import type { GetOrderPositionBooksQuery } from '../../../../gql/types/graphql';\nimport { BOOKS_THRESHOLDS } from '../../../constants';\nimport type { Bucket } from '../types';\nimport { aggregateBuckets } from './aggregateBuckets';\n\nexport const processBuckets = (\n orderPositionData: GetOrderPositionBooksQuery | undefined,\n targetBucketWidth: number\n): Bucket[][] => {\n if (!orderPositionData?.orderPositionBooks?.length) {\n return [];\n }\n\n return orderPositionData.orderPositionBooks\n .filter((book): book is NonNullable<typeof book> => {\n return book !== null && book.buckets?.length > 0;\n })\n .map((book) => {\n const validBuckets = book.buckets\n .filter(\n (bucket): bucket is NonNullable<typeof bucket> =>\n bucket !== null &&\n bucket.price !== undefined &&\n bucket.sentiment !== undefined &&\n bucket.sentiment !== null\n )\n .map((bucket) => ({\n price: bucket.price!,\n sentiment: bucket.sentiment!,\n }));\n\n const bucketsToFilter =\n targetBucketWidth > (book.bucketWidth ?? 0)\n ? aggregateBuckets(validBuckets, targetBucketWidth)\n : validBuckets;\n\n const filteredBuckets = bucketsToFilter.filter(\n (bucket: Bucket) => Math.abs(bucket.sentiment) >= BOOKS_THRESHOLDS.MIN\n );\n\n return filteredBuckets;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,GAAGA,CAC5BC,iBAAyD,EACzDC,iBAAyB,KACV;EAAA,IAAAC,qBAAA;EACf,IAAI,EAACF,iBAAiB,aAAjBA,iBAAiB,gBAAAE,qBAAA,GAAjBF,iBAAiB,CAAEG,kBAAkB,cAAAD,qBAAA,eAArCA,qBAAA,CAAuCE,MAAM,GAAE;IAClD,OAAO,EAAE;EACX;EAEA,OAAOJ,iBAAiB,CAACG,kBAAkB,CACxCE,MAAM,CAAEC,IAAI,IAAuC;IAAA,IAAAC,aAAA;IAClD,OAAOD,IAAI,KAAK,IAAI,IAAI,EAAAC,aAAA,GAAAD,IAAI,CAACE,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcH,MAAM,IAAG,CAAC;EAClD,CAAC,CAAC,CACDK,GAAG,CAAEH,IAAI,IAAK;IAAA,IAAAI,iBAAA;IACb,MAAMC,YAAY,GAAGL,IAAI,CAACE,OAAO,CAC9BH,MAAM,CACJO,MAAM,IACLA,MAAM,KAAK,IAAI,IACfA,MAAM,CAACC,KAAK,KAAKC,SAAS,IAC1BF,MAAM,CAACG,SAAS,KAAKD,SAAS,IAC9BF,MAAM,CAACG,SAAS,KAAK,IACzB,CAAC,CACAN,GAAG,CAAEG,MAAM,KAAM;MAChBC,KAAK,EAAED,MAAM,CAACC,KAAM;MACpBE,SAAS,EAAEH,MAAM,CAACG;IACpB,CAAC,CAAC,CAAC;IAEL,MAAMC,eAAe,GACnBf,iBAAiB,KAAAS,iBAAA,GAAIJ,IAAI,CAACW,WAAW,cAAAP,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC,GACvC,IAAAQ,kCAAgB,EAACP,YAAY,EAAEV,iBAAiB,CAAC,GACjDU,YAAY;IAElB,MAAMQ,eAAe,GAAGH,eAAe,CAACX,MAAM,CAC3CO,MAAc,IAAKQ,IAAI,CAACC,GAAG,CAACT,MAAM,CAACG,SAAS,CAAC,IAAIO,2BAAgB,CAACC,GACrE,CAAC;IAED,OAAOJ,eAAe;EACxB,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAzB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js';
|
|
2
|
-
export const aggregateBuckets = (buckets, newBucketWidth) => {
|
|
3
|
-
if (!buckets.length) {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
const bucketWidthDecimal = new Decimal(newBucketWidth);
|
|
7
|
-
const aggregatedMap = new Map();
|
|
8
|
-
for (const bucket of buckets) {
|
|
9
|
-
var _aggregatedMap$get;
|
|
10
|
-
const priceDecimal = new Decimal(bucket.price);
|
|
11
|
-
const sentimentDecimal = new Decimal(bucket.sentiment);
|
|
12
|
-
const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();
|
|
13
|
-
const groupingKey = bucketIndex.mul(bucketWidthDecimal);
|
|
14
|
-
const groupingKeyStr = groupingKey.toString();
|
|
15
|
-
const currentSentiment = (_aggregatedMap$get = aggregatedMap.get(groupingKeyStr)) !== null && _aggregatedMap$get !== void 0 ? _aggregatedMap$get : new Decimal(0);
|
|
16
|
-
aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));
|
|
17
|
-
}
|
|
18
|
-
const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(_ref => {
|
|
19
|
-
let [priceStr, sentimentDecimal] = _ref;
|
|
20
|
-
const price = new Decimal(priceStr).toNumber();
|
|
21
|
-
const sentiment = sentimentDecimal.toNumber();
|
|
22
|
-
return {
|
|
23
|
-
price,
|
|
24
|
-
sentiment
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
return aggregatedBuckets;
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=aggregateBuckets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aggregateBuckets.js","names":["Decimal","aggregateBuckets","buckets","newBucketWidth","length","bucketWidthDecimal","aggregatedMap","Map","bucket","_aggregatedMap$get","priceDecimal","price","sentimentDecimal","sentiment","bucketIndex","div","floor","groupingKey","mul","groupingKeyStr","toString","currentSentiment","get","set","add","aggregatedBuckets","Array","from","entries","map","_ref","priceStr","toNumber"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts"],"sourcesContent":["import Decimal from 'decimal.js';\n\nimport type { Bucket } from '../types';\n\nexport const aggregateBuckets = (\n buckets: Bucket[],\n newBucketWidth: number\n): Bucket[] => {\n if (!buckets.length) {\n return [];\n }\n\n const bucketWidthDecimal = new Decimal(newBucketWidth);\n\n const aggregatedMap = new Map<string, Decimal>();\n\n for (const bucket of buckets) {\n const priceDecimal = new Decimal(bucket.price);\n const sentimentDecimal = new Decimal(bucket.sentiment);\n\n const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();\n const groupingKey = bucketIndex.mul(bucketWidthDecimal);\n\n const groupingKeyStr = groupingKey.toString();\n\n const currentSentiment =\n aggregatedMap.get(groupingKeyStr) ?? new Decimal(0);\n aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));\n }\n\n const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(\n ([priceStr, sentimentDecimal]) => {\n const price = new Decimal(priceStr).toNumber();\n const sentiment = sentimentDecimal.toNumber();\n\n return {\n price,\n sentiment,\n };\n }\n );\n\n return aggregatedBuckets;\n};\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,YAAY;AAIhC,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,OAAiB,EACjBC,cAAsB,KACT;EACb,IAAI,CAACD,OAAO,CAACE,MAAM,EAAE;IACnB,OAAO,EAAE;EACX;EAEA,MAAMC,kBAAkB,GAAG,IAAIL,OAAO,CAACG,cAAc,CAAC;EAEtD,MAAMG,aAAa,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAEhD,KAAK,MAAMC,MAAM,IAAIN,OAAO,EAAE;IAAA,IAAAO,kBAAA;IAC5B,MAAMC,YAAY,GAAG,IAAIV,OAAO,CAACQ,MAAM,CAACG,KAAK,CAAC;IAC9C,MAAMC,gBAAgB,GAAG,IAAIZ,OAAO,CAACQ,MAAM,CAACK,SAAS,CAAC;IAEtD,MAAMC,WAAW,GAAGJ,YAAY,CAACK,GAAG,CAACV,kBAAkB,CAAC,CAACW,KAAK,CAAC,CAAC;IAChE,MAAMC,WAAW,GAAGH,WAAW,CAACI,GAAG,CAACb,kBAAkB,CAAC;IAEvD,MAAMc,cAAc,GAAGF,WAAW,CAACG,QAAQ,CAAC,CAAC;IAE7C,MAAMC,gBAAgB,IAAAZ,kBAAA,GACpBH,aAAa,CAACgB,GAAG,CAACH,cAAc,CAAC,cAAAV,kBAAA,cAAAA,kBAAA,GAAI,IAAIT,OAAO,CAAC,CAAC,CAAC;IACrDM,aAAa,CAACiB,GAAG,CAACJ,cAAc,EAAEE,gBAAgB,CAACG,GAAG,CAACZ,gBAAgB,CAAC,CAAC;EAC3E;EAEA,MAAMa,iBAAiB,GAAGC,KAAK,CAACC,IAAI,CAACrB,aAAa,CAACsB,OAAO,CAAC,CAAC,CAAC,CAACC,GAAG,CAC/DC,IAAA,IAAkC;IAAA,IAAjC,CAACC,QAAQ,EAAEnB,gBAAgB,CAAC,GAAAkB,IAAA;IAC3B,MAAMnB,KAAK,GAAG,IAAIX,OAAO,CAAC+B,QAAQ,CAAC,CAACC,QAAQ,CAAC,CAAC;IAC9C,MAAMnB,SAAS,GAAGD,gBAAgB,CAACoB,QAAQ,CAAC,CAAC;IAE7C,OAAO;MACLrB,KAAK;MACLE;IACF,CAAC;EACH,CACF,CAAC;EAED,OAAOY,iBAAiB;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Granularity } from '../../../../gql/types/graphql';
|
|
2
|
-
import { BUCKET_CONFIG, INSTRUMENTS_CONFIG } from '../../../constants';
|
|
3
|
-
export const getTargetBucketWidth = (granularity, instrument) => {
|
|
4
|
-
const bucketWidth = INSTRUMENTS_CONFIG[instrument].defaultBucketWidth;
|
|
5
|
-
return granularity === Granularity.H1 || granularity === Granularity.H4 ? bucketWidth * BUCKET_CONFIG.MULTIPLIER : bucketWidth;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=getTargetBucketWidth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTargetBucketWidth.js","names":["Granularity","BUCKET_CONFIG","INSTRUMENTS_CONFIG","getTargetBucketWidth","granularity","instrument","bucketWidth","defaultBucketWidth","H1","H4","MULTIPLIER"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts"],"sourcesContent":["import { Granularity } from '../../../../gql/types/graphql';\nimport { BUCKET_CONFIG, INSTRUMENTS_CONFIG } from '../../../constants';\nimport type { InstrumentId } from '../../../types';\n\nexport const getTargetBucketWidth = (\n granularity: Granularity,\n instrument: InstrumentId\n): number => {\n const bucketWidth = INSTRUMENTS_CONFIG[instrument].defaultBucketWidth;\n return granularity === Granularity.H1 || granularity === Granularity.H4\n ? bucketWidth * BUCKET_CONFIG.MULTIPLIER\n : bucketWidth;\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,oBAAoB;AAGtE,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,WAAwB,EACxBC,UAAwB,KACb;EACX,MAAMC,WAAW,GAAGJ,kBAAkB,CAACG,UAAU,CAAC,CAACE,kBAAkB;EACrE,OAAOH,WAAW,KAAKJ,WAAW,CAACQ,EAAE,IAAIJ,WAAW,KAAKJ,WAAW,CAACS,EAAE,GACnEH,WAAW,GAAGL,aAAa,CAACS,UAAU,GACtCJ,WAAW;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BOOKS_THRESHOLDS } from '../../../constants';
|
|
2
|
-
import { aggregateBuckets } from './aggregateBuckets';
|
|
3
|
-
export const processBuckets = (orderPositionData, targetBucketWidth) => {
|
|
4
|
-
var _orderPositionData$or;
|
|
5
|
-
if (!(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or !== void 0 && _orderPositionData$or.length)) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
return orderPositionData.orderPositionBooks.filter(book => {
|
|
9
|
-
var _book$buckets;
|
|
10
|
-
return book !== null && ((_book$buckets = book.buckets) === null || _book$buckets === void 0 ? void 0 : _book$buckets.length) > 0;
|
|
11
|
-
}).map(book => {
|
|
12
|
-
var _book$bucketWidth;
|
|
13
|
-
const validBuckets = book.buckets.filter(bucket => bucket !== null && bucket.price !== undefined && bucket.sentiment !== undefined && bucket.sentiment !== null).map(bucket => ({
|
|
14
|
-
price: bucket.price,
|
|
15
|
-
sentiment: bucket.sentiment
|
|
16
|
-
}));
|
|
17
|
-
const bucketsToFilter = targetBucketWidth > ((_book$bucketWidth = book.bucketWidth) !== null && _book$bucketWidth !== void 0 ? _book$bucketWidth : 0) ? aggregateBuckets(validBuckets, targetBucketWidth) : validBuckets;
|
|
18
|
-
const filteredBuckets = bucketsToFilter.filter(bucket => Math.abs(bucket.sentiment) >= BOOKS_THRESHOLDS.MIN);
|
|
19
|
-
return filteredBuckets;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=processBuckets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processBuckets.js","names":["BOOKS_THRESHOLDS","aggregateBuckets","processBuckets","orderPositionData","targetBucketWidth","_orderPositionData$or","orderPositionBooks","length","filter","book","_book$buckets","buckets","map","_book$bucketWidth","validBuckets","bucket","price","undefined","sentiment","bucketsToFilter","bucketWidth","filteredBuckets","Math","abs","MIN"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/utils/processBuckets.ts"],"sourcesContent":["import type { GetOrderPositionBooksQuery } from '../../../../gql/types/graphql';\nimport { BOOKS_THRESHOLDS } from '../../../constants';\nimport type { Bucket } from '../types';\nimport { aggregateBuckets } from './aggregateBuckets';\n\nexport const processBuckets = (\n orderPositionData: GetOrderPositionBooksQuery | undefined,\n targetBucketWidth: number\n): Bucket[][] => {\n if (!orderPositionData?.orderPositionBooks?.length) {\n return [];\n }\n\n return orderPositionData.orderPositionBooks\n .filter((book): book is NonNullable<typeof book> => {\n return book !== null && book.buckets?.length > 0;\n })\n .map((book) => {\n const validBuckets = book.buckets\n .filter(\n (bucket): bucket is NonNullable<typeof bucket> =>\n bucket !== null &&\n bucket.price !== undefined &&\n bucket.sentiment !== undefined &&\n bucket.sentiment !== null\n )\n .map((bucket) => ({\n price: bucket.price!,\n sentiment: bucket.sentiment!,\n }));\n\n const bucketsToFilter =\n targetBucketWidth > (book.bucketWidth ?? 0)\n ? aggregateBuckets(validBuckets, targetBucketWidth)\n : validBuckets;\n\n const filteredBuckets = bucketsToFilter.filter(\n (bucket: Bucket) => Math.abs(bucket.sentiment) >= BOOKS_THRESHOLDS.MIN\n );\n\n return filteredBuckets;\n });\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,OAAO,MAAMC,cAAc,GAAGA,CAC5BC,iBAAyD,EACzDC,iBAAyB,KACV;EAAA,IAAAC,qBAAA;EACf,IAAI,EAACF,iBAAiB,aAAjBA,iBAAiB,gBAAAE,qBAAA,GAAjBF,iBAAiB,CAAEG,kBAAkB,cAAAD,qBAAA,eAArCA,qBAAA,CAAuCE,MAAM,GAAE;IAClD,OAAO,EAAE;EACX;EAEA,OAAOJ,iBAAiB,CAACG,kBAAkB,CACxCE,MAAM,CAAEC,IAAI,IAAuC;IAAA,IAAAC,aAAA;IAClD,OAAOD,IAAI,KAAK,IAAI,IAAI,EAAAC,aAAA,GAAAD,IAAI,CAACE,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcH,MAAM,IAAG,CAAC;EAClD,CAAC,CAAC,CACDK,GAAG,CAAEH,IAAI,IAAK;IAAA,IAAAI,iBAAA;IACb,MAAMC,YAAY,GAAGL,IAAI,CAACE,OAAO,CAC9BH,MAAM,CACJO,MAAM,IACLA,MAAM,KAAK,IAAI,IACfA,MAAM,CAACC,KAAK,KAAKC,SAAS,IAC1BF,MAAM,CAACG,SAAS,KAAKD,SAAS,IAC9BF,MAAM,CAACG,SAAS,KAAK,IACzB,CAAC,CACAN,GAAG,CAAEG,MAAM,KAAM;MAChBC,KAAK,EAAED,MAAM,CAACC,KAAM;MACpBE,SAAS,EAAEH,MAAM,CAACG;IACpB,CAAC,CAAC,CAAC;IAEL,MAAMC,eAAe,GACnBf,iBAAiB,KAAAS,iBAAA,GAAIJ,IAAI,CAACW,WAAW,cAAAP,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC,GACvCZ,gBAAgB,CAACa,YAAY,EAAEV,iBAAiB,CAAC,GACjDU,YAAY;IAElB,MAAMO,eAAe,GAAGF,eAAe,CAACX,MAAM,CAC3CO,MAAc,IAAKO,IAAI,CAACC,GAAG,CAACR,MAAM,CAACG,SAAS,CAAC,IAAIlB,gBAAgB,CAACwB,GACrE,CAAC;IAED,OAAOH,eAAe;EACxB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js';
|
|
2
|
-
|
|
3
|
-
import type { Bucket } from '../types';
|
|
4
|
-
|
|
5
|
-
export const aggregateBuckets = (
|
|
6
|
-
buckets: Bucket[],
|
|
7
|
-
newBucketWidth: number
|
|
8
|
-
): Bucket[] => {
|
|
9
|
-
if (!buckets.length) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const bucketWidthDecimal = new Decimal(newBucketWidth);
|
|
14
|
-
|
|
15
|
-
const aggregatedMap = new Map<string, Decimal>();
|
|
16
|
-
|
|
17
|
-
for (const bucket of buckets) {
|
|
18
|
-
const priceDecimal = new Decimal(bucket.price);
|
|
19
|
-
const sentimentDecimal = new Decimal(bucket.sentiment);
|
|
20
|
-
|
|
21
|
-
const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();
|
|
22
|
-
const groupingKey = bucketIndex.mul(bucketWidthDecimal);
|
|
23
|
-
|
|
24
|
-
const groupingKeyStr = groupingKey.toString();
|
|
25
|
-
|
|
26
|
-
const currentSentiment =
|
|
27
|
-
aggregatedMap.get(groupingKeyStr) ?? new Decimal(0);
|
|
28
|
-
aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(
|
|
32
|
-
([priceStr, sentimentDecimal]) => {
|
|
33
|
-
const price = new Decimal(priceStr).toNumber();
|
|
34
|
-
const sentiment = sentimentDecimal.toNumber();
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
price,
|
|
38
|
-
sentiment,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return aggregatedBuckets;
|
|
44
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Granularity } from '../../../../gql/types/graphql';
|
|
2
|
-
import { BUCKET_CONFIG, INSTRUMENTS_CONFIG } from '../../../constants';
|
|
3
|
-
import type { InstrumentId } from '../../../types';
|
|
4
|
-
|
|
5
|
-
export const getTargetBucketWidth = (
|
|
6
|
-
granularity: Granularity,
|
|
7
|
-
instrument: InstrumentId
|
|
8
|
-
): number => {
|
|
9
|
-
const bucketWidth = INSTRUMENTS_CONFIG[instrument].defaultBucketWidth;
|
|
10
|
-
return granularity === Granularity.H1 || granularity === Granularity.H4
|
|
11
|
-
? bucketWidth * BUCKET_CONFIG.MULTIPLIER
|
|
12
|
-
: bucketWidth;
|
|
13
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { GetOrderPositionBooksQuery } from '../../../../gql/types/graphql';
|
|
2
|
-
import { BOOKS_THRESHOLDS } from '../../../constants';
|
|
3
|
-
import type { Bucket } from '../types';
|
|
4
|
-
import { aggregateBuckets } from './aggregateBuckets';
|
|
5
|
-
|
|
6
|
-
export const processBuckets = (
|
|
7
|
-
orderPositionData: GetOrderPositionBooksQuery | undefined,
|
|
8
|
-
targetBucketWidth: number
|
|
9
|
-
): Bucket[][] => {
|
|
10
|
-
if (!orderPositionData?.orderPositionBooks?.length) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return orderPositionData.orderPositionBooks
|
|
15
|
-
.filter((book): book is NonNullable<typeof book> => {
|
|
16
|
-
return book !== null && book.buckets?.length > 0;
|
|
17
|
-
})
|
|
18
|
-
.map((book) => {
|
|
19
|
-
const validBuckets = book.buckets
|
|
20
|
-
.filter(
|
|
21
|
-
(bucket): bucket is NonNullable<typeof bucket> =>
|
|
22
|
-
bucket !== null &&
|
|
23
|
-
bucket.price !== undefined &&
|
|
24
|
-
bucket.sentiment !== undefined &&
|
|
25
|
-
bucket.sentiment !== null
|
|
26
|
-
)
|
|
27
|
-
.map((bucket) => ({
|
|
28
|
-
price: bucket.price!,
|
|
29
|
-
sentiment: bucket.sentiment!,
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
const bucketsToFilter =
|
|
33
|
-
targetBucketWidth > (book.bucketWidth ?? 0)
|
|
34
|
-
? aggregateBuckets(validBuckets, targetBucketWidth)
|
|
35
|
-
: validBuckets;
|
|
36
|
-
|
|
37
|
-
const filteredBuckets = bucketsToFilter.filter(
|
|
38
|
-
(bucket: Bucket) => Math.abs(bucket.sentiment) >= BOOKS_THRESHOLDS.MIN
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return filteredBuckets;
|
|
42
|
-
});
|
|
43
|
-
};
|