@oanda/labs-crowd-view-widget 1.0.52 → 1.0.54
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 +436 -0
- package/dist/main/CrowdViewWidget/Main.js +4 -6
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +18 -31
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +30 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +54 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +60 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +31 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +75 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +116 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +108 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +83 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +15 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/main/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +8 -41
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +43 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +103 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/index.js +11 -11
- package/dist/main/CrowdViewWidget/components/Chart/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +53 -30
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +15 -13
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +12 -18
- 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/main/translations/sources/en.json +2 -1
- package/dist/module/CrowdViewWidget/Main.js +3 -5
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +20 -33
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +23 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +53 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +24 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +68 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +6 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +7 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +101 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/module/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +7 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +36 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +96 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/index.js +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/index.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/Legend/Legend.js +15 -13
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +10 -17
- 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/module/translations/sources/en.json +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +16 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.d.ts +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +17 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.d.ts +1 -0
- package/dist/types/CrowdViewWidget/{utils/instrumentUtils.d.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.d.ts} +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/index.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.d.ts +12 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processSentiments.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +28 -11
- package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +1 -4
- package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +1 -3
- package/dist/types/CrowdViewWidget/constants.d.ts +4 -12
- 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 +3 -4
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +25 -40
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +8 -4
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +84 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +52 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +82 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +43 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +77 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +10 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.ts +9 -6
- package/src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +42 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +183 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +7 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts +13 -0
- package/src/CrowdViewWidget/{utils/instrumentUtils.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.ts} +2 -2
- package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/index.ts +6 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.ts +92 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +67 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processSentiments.ts +55 -0
- package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.ts +10 -2
- package/src/CrowdViewWidget/components/Chart/getOption.ts +114 -0
- package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/types.ts +30 -19
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +84 -67
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -23
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +13 -26
- package/src/CrowdViewWidget/constants.ts +21 -23
- 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/src/translations/sources/en.json +2 -1
- package/test/components/Chart/utils/chartUtils.test.ts +39 -21
- package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
- package/test/components/Chart/utils/processSentiments.test.ts +138 -30
- package/test/components/Legend.test.tsx +13 -21
- package/test/components/LegendBar.test.tsx +31 -51
- package/test/utils/instrumentUtils.test.ts +1 -1
- 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/chartOptions.js +0 -359
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
- 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/chartUtils.js +0 -127
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/getGridLines.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/index.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/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -23
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -43
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -28
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
- package/dist/main/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +0 -351
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.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/chartUtils.js +0 -114
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/getGridLines.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/index.js +0 -10
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.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/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -16
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -36
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -21
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
- package/dist/module/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
- package/dist/types/CrowdViewWidget/components/Chart/utils/aggregateBuckets.d.ts +0 -2
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +0 -31
- package/dist/types/CrowdViewWidget/components/Chart/utils/getGridLines.d.ts +0 -97
- package/dist/types/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/index.d.ts +0 -9
- package/dist/types/CrowdViewWidget/components/Chart/utils/processBuckets.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.d.ts +0 -8
- package/dist/types/CrowdViewWidget/components/Chart/utils/processPriceCandles.d.ts +0 -27
- package/dist/types/CrowdViewWidget/components/Chart/utils/processSentiments.d.ts +0 -3
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +0 -401
- package/src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts +0 -44
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +0 -216
- package/src/CrowdViewWidget/components/Chart/utils/getGridLines.ts +0 -148
- package/src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts +0 -13
- package/src/CrowdViewWidget/components/Chart/utils/index.ts +0 -9
- package/src/CrowdViewWidget/components/Chart/utils/processBuckets.ts +0 -43
- package/src/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.ts +0 -30
- package/src/CrowdViewWidget/components/Chart/utils/processPriceCandles.ts +0 -53
- package/src/CrowdViewWidget/components/Chart/utils/processSentiments.ts +0 -42
- package/test/utils/aggregateBuckets.test.ts +0 -82
- package/test/utils/getTargetBucketWidth.test.ts +0 -37
- package/test/utils/processBuckets.test.ts +0 -153
- /package/dist/types/CrowdViewWidget/components/Chart/{chartOptions.d.ts → getOption.d.ts} +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
5
6
|
import { render } from '@testing-library/react';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
@@ -13,27 +14,21 @@ describe('Crowd View Widget', () => {
|
|
|
13
14
|
describe('components', () => {
|
|
14
15
|
describe('<Legend />', () => {
|
|
15
16
|
it('renders two LegendBar components', () => {
|
|
16
|
-
const {
|
|
17
|
-
<
|
|
18
|
-
bookType={BookType.Position}
|
|
19
|
-
|
|
20
|
-
longValues={[0.15, 0.55]}
|
|
21
|
-
shortValues={[0.15, 0.55]}
|
|
22
|
-
/>
|
|
17
|
+
const { getAllByTestId } = render(
|
|
18
|
+
<MockLayoutProvider isDark={false}>
|
|
19
|
+
<Legend bookType={BookType.Position} />
|
|
20
|
+
</MockLayoutProvider>
|
|
23
21
|
);
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
expect(
|
|
23
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
24
|
+
expect(segments.length).toBe(2);
|
|
27
25
|
});
|
|
28
26
|
|
|
29
27
|
it('passes isDark prop to LegendBar components in light mode', () => {
|
|
30
28
|
const { getAllByTestId } = render(
|
|
31
|
-
<
|
|
32
|
-
bookType={BookType.Position}
|
|
33
|
-
|
|
34
|
-
longValues={[0.15, 0.55]}
|
|
35
|
-
shortValues={[0.15, 0.55]}
|
|
36
|
-
/>
|
|
29
|
+
<MockLayoutProvider isDark={false}>
|
|
30
|
+
<Legend bookType={BookType.Position} />
|
|
31
|
+
</MockLayoutProvider>
|
|
37
32
|
);
|
|
38
33
|
const segments = getAllByTestId('legend-bar-segment');
|
|
39
34
|
expect(segments.length).toBe(2);
|
|
@@ -49,12 +44,9 @@ describe('Crowd View Widget', () => {
|
|
|
49
44
|
|
|
50
45
|
it('passes isDark prop to LegendBar components in dark mode', () => {
|
|
51
46
|
const { getAllByTestId } = render(
|
|
52
|
-
<
|
|
53
|
-
bookType={BookType.Position}
|
|
54
|
-
|
|
55
|
-
longValues={[0.15, 0.55]}
|
|
56
|
-
shortValues={[0.15, 0.55]}
|
|
57
|
-
/>
|
|
47
|
+
<MockLayoutProvider isDark={true}>
|
|
48
|
+
<Legend bookType={BookType.Position} />
|
|
49
|
+
</MockLayoutProvider>
|
|
58
50
|
);
|
|
59
51
|
const segments = getAllByTestId('legend-bar-segment');
|
|
60
52
|
expect(segments.length).toBe(2);
|
|
@@ -11,44 +11,17 @@ import { COLOR_MAP } from '../../src/CrowdViewWidget/constants';
|
|
|
11
11
|
describe('Crowd View Widget', () => {
|
|
12
12
|
describe('components', () => {
|
|
13
13
|
describe('<LegendBar />', () => {
|
|
14
|
-
const mockValues = [0.15, 0.55];
|
|
15
|
-
|
|
16
|
-
it('renders LegendBar with min and max values', () => {
|
|
17
|
-
const { getByText } = render(
|
|
18
|
-
<LegendBar
|
|
19
|
-
isDark={false}
|
|
20
|
-
label="long"
|
|
21
|
-
type="long"
|
|
22
|
-
values={mockValues}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
expect(getByText('long')).toBeInTheDocument();
|
|
27
|
-
expect(getByText('0.15%')).toBeInTheDocument();
|
|
28
|
-
expect(getByText('≤ 0.55%')).toBeInTheDocument();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
14
|
it('renders exactly 1 segment', () => {
|
|
32
15
|
const { getAllByTestId } = render(
|
|
33
|
-
<LegendBar
|
|
34
|
-
isDark={false}
|
|
35
|
-
label="short"
|
|
36
|
-
type="short"
|
|
37
|
-
values={mockValues}
|
|
38
|
-
/>
|
|
16
|
+
<LegendBar isDark={false} type="short" />
|
|
39
17
|
);
|
|
40
18
|
const segments = getAllByTestId('legend-bar-segment');
|
|
41
19
|
expect(segments.length).toBe(1);
|
|
42
20
|
});
|
|
43
21
|
|
|
44
|
-
it('uses light mode colors when isDark is false', () => {
|
|
22
|
+
it('uses light mode colors when isDark is false for long type', () => {
|
|
45
23
|
const { getByTestId } = render(
|
|
46
|
-
<LegendBar
|
|
47
|
-
isDark={false}
|
|
48
|
-
label="long"
|
|
49
|
-
type="long"
|
|
50
|
-
values={mockValues}
|
|
51
|
-
/>
|
|
24
|
+
<LegendBar isDark={false} type="long" />
|
|
52
25
|
);
|
|
53
26
|
const segment = getByTestId('legend-bar-segment');
|
|
54
27
|
const style = segment.getAttribute('style');
|
|
@@ -56,15 +29,8 @@ describe('Crowd View Widget', () => {
|
|
|
56
29
|
expect(style).toContain(COLOR_MAP.light.long[1]);
|
|
57
30
|
});
|
|
58
31
|
|
|
59
|
-
it('uses dark mode colors when isDark is true', () => {
|
|
60
|
-
const { getByTestId } = render(
|
|
61
|
-
<LegendBar
|
|
62
|
-
isDark={true}
|
|
63
|
-
label="long"
|
|
64
|
-
type="long"
|
|
65
|
-
values={mockValues}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
32
|
+
it('uses dark mode colors when isDark is true for long type', () => {
|
|
33
|
+
const { getByTestId } = render(<LegendBar isDark={true} type="long" />);
|
|
68
34
|
const segment = getByTestId('legend-bar-segment');
|
|
69
35
|
const style = segment.getAttribute('style');
|
|
70
36
|
expect(style).toContain(COLOR_MAP.dark.long[0]);
|
|
@@ -73,12 +39,7 @@ describe('Crowd View Widget', () => {
|
|
|
73
39
|
|
|
74
40
|
it('uses light mode short colors when isDark is false', () => {
|
|
75
41
|
const { getByTestId } = render(
|
|
76
|
-
<LegendBar
|
|
77
|
-
isDark={false}
|
|
78
|
-
label="short"
|
|
79
|
-
type="short"
|
|
80
|
-
values={mockValues}
|
|
81
|
-
/>
|
|
42
|
+
<LegendBar isDark={false} type="short" />
|
|
82
43
|
);
|
|
83
44
|
const segment = getByTestId('legend-bar-segment');
|
|
84
45
|
const style = segment.getAttribute('style');
|
|
@@ -88,18 +49,37 @@ describe('Crowd View Widget', () => {
|
|
|
88
49
|
|
|
89
50
|
it('uses dark mode short colors when isDark is true', () => {
|
|
90
51
|
const { getByTestId } = render(
|
|
91
|
-
<LegendBar
|
|
92
|
-
isDark={true}
|
|
93
|
-
label="short"
|
|
94
|
-
type="short"
|
|
95
|
-
values={mockValues}
|
|
96
|
-
/>
|
|
52
|
+
<LegendBar isDark={true} type="short" />
|
|
97
53
|
);
|
|
98
54
|
const segment = getByTestId('legend-bar-segment');
|
|
99
55
|
const style = segment.getAttribute('style');
|
|
100
56
|
expect(style).toContain(COLOR_MAP.dark.short[0]);
|
|
101
57
|
expect(style).toContain(COLOR_MAP.dark.short[1]);
|
|
102
58
|
});
|
|
59
|
+
|
|
60
|
+
it('renders gradient with correct direction for long type', () => {
|
|
61
|
+
const { getByTestId } = render(
|
|
62
|
+
<LegendBar isDark={false} type="long" />
|
|
63
|
+
);
|
|
64
|
+
const segment = getByTestId('legend-bar-segment');
|
|
65
|
+
const style = segment.getAttribute('style');
|
|
66
|
+
// Long type should use long[1] as start and long[0] as end
|
|
67
|
+
expect(style).toMatch(/linear-gradient\(90deg/);
|
|
68
|
+
expect(style).toContain(COLOR_MAP.light.long[1]);
|
|
69
|
+
expect(style).toContain(COLOR_MAP.light.long[0]);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('renders gradient with correct direction for short type', () => {
|
|
73
|
+
const { getByTestId } = render(
|
|
74
|
+
<LegendBar isDark={false} type="short" />
|
|
75
|
+
);
|
|
76
|
+
const segment = getByTestId('legend-bar-segment');
|
|
77
|
+
const style = segment.getAttribute('style');
|
|
78
|
+
// Short type should use short[0] as start and short[1] as end
|
|
79
|
+
expect(style).toMatch(/linear-gradient\(90deg/);
|
|
80
|
+
expect(style).toContain(COLOR_MAP.light.short[0]);
|
|
81
|
+
expect(style).toContain(COLOR_MAP.light.short[1]);
|
|
82
|
+
});
|
|
103
83
|
});
|
|
104
84
|
});
|
|
105
85
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { getInstrumentConfigForDivision } from '../../src/CrowdViewWidget/
|
|
5
|
+
import { getInstrumentConfigForDivision } from '../../src/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision';
|
|
6
6
|
import { Division } from '../../src/gql/types/graphql';
|
|
7
7
|
|
|
8
8
|
describe('instrumentUtils', () => {
|
|
@@ -3,125 +3,242 @@ import type { GetOrderPositionBooksQuery } from '../../src/gql/types/graphql';
|
|
|
3
3
|
|
|
4
4
|
describe('processOrderPositionBooks', () => {
|
|
5
5
|
const createMockOrderPositionBook = (time: string) => ({
|
|
6
|
-
bucketWidth: 0.0005,
|
|
7
|
-
price: 1.0,
|
|
8
6
|
time,
|
|
9
|
-
|
|
7
|
+
price: 1.0,
|
|
8
|
+
buckets: [
|
|
9
|
+
{ price: 1.0, sentiment: 0.2 },
|
|
10
|
+
{ price: 1.0005, sentiment: -0.3 },
|
|
11
|
+
],
|
|
10
12
|
});
|
|
11
13
|
|
|
12
|
-
it('should return empty
|
|
13
|
-
const
|
|
14
|
-
expect(
|
|
14
|
+
it('should return empty arrays when orderPositionData is undefined', () => {
|
|
15
|
+
const result = processOrderPositionBooks(undefined, []);
|
|
16
|
+
expect(result).toEqual({
|
|
17
|
+
bookPrices: [],
|
|
18
|
+
bookIndexes: [],
|
|
19
|
+
buckets: [],
|
|
20
|
+
bucketWidth: 0,
|
|
21
|
+
sentimentThresholdMin: 0,
|
|
22
|
+
sentimentThresholdMax: 0,
|
|
23
|
+
hasValidBooks: false,
|
|
24
|
+
});
|
|
15
25
|
});
|
|
16
26
|
|
|
17
|
-
it('should return empty
|
|
27
|
+
it('should return empty arrays when orderPositionBooks is undefined', () => {
|
|
18
28
|
const mockData: GetOrderPositionBooksQuery = {
|
|
19
|
-
orderPositionBooks:
|
|
29
|
+
orderPositionBooks: {} as any,
|
|
20
30
|
};
|
|
21
|
-
const
|
|
22
|
-
expect(
|
|
31
|
+
const result = processOrderPositionBooks(mockData, []);
|
|
32
|
+
expect(result).toEqual({
|
|
33
|
+
bookPrices: [],
|
|
34
|
+
bookIndexes: [],
|
|
35
|
+
buckets: [],
|
|
36
|
+
bucketWidth: 0,
|
|
37
|
+
sentimentThresholdMin: 0,
|
|
38
|
+
sentimentThresholdMax: 0,
|
|
39
|
+
hasValidBooks: false,
|
|
40
|
+
});
|
|
23
41
|
});
|
|
24
42
|
|
|
25
|
-
it('should
|
|
43
|
+
it('should return empty arrays when books array is empty', () => {
|
|
26
44
|
const mockData: GetOrderPositionBooksQuery = {
|
|
27
|
-
orderPositionBooks:
|
|
45
|
+
orderPositionBooks: {
|
|
46
|
+
books: [],
|
|
47
|
+
bucketWidth: 0.0005,
|
|
48
|
+
sentimentThresholdMin: 0.15,
|
|
49
|
+
sentimentThresholdMax: 0.55,
|
|
50
|
+
},
|
|
28
51
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
const result = processOrderPositionBooks(mockData, []);
|
|
53
|
+
expect(result).toEqual({
|
|
54
|
+
bookPrices: [],
|
|
55
|
+
bookIndexes: [],
|
|
56
|
+
buckets: [],
|
|
57
|
+
bucketWidth: 0,
|
|
58
|
+
sentimentThresholdMin: 0,
|
|
59
|
+
sentimentThresholdMax: 0,
|
|
60
|
+
hasValidBooks: false,
|
|
61
|
+
});
|
|
33
62
|
});
|
|
34
63
|
|
|
35
|
-
it('should
|
|
64
|
+
it('should return empty arrays when sentimentThresholdMin is missing', () => {
|
|
36
65
|
const mockData: GetOrderPositionBooksQuery = {
|
|
37
|
-
orderPositionBooks:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
createMockOrderPositionBook('2025-01-02'),
|
|
45
|
-
],
|
|
66
|
+
orderPositionBooks: {
|
|
67
|
+
books: [createMockOrderPositionBook('2025-01-01T00:00:00Z')],
|
|
68
|
+
bucketWidth: 0.0005,
|
|
69
|
+
sentimentThresholdMin: null as any,
|
|
70
|
+
sentimentThresholdMax: 0.55,
|
|
71
|
+
},
|
|
46
72
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(result
|
|
73
|
+
const result = processOrderPositionBooks(mockData, [
|
|
74
|
+
'2025-01-01T00:00:00Z',
|
|
75
|
+
]);
|
|
76
|
+
expect(result.hasValidBooks).toBe(false);
|
|
51
77
|
});
|
|
52
78
|
|
|
53
|
-
it('should
|
|
79
|
+
it('should process valid order position books and match with dates', () => {
|
|
80
|
+
const dates = [
|
|
81
|
+
'2025-01-01T00:00:00Z',
|
|
82
|
+
'2025-01-01T01:00:00Z',
|
|
83
|
+
'2025-01-01T02:00:00Z',
|
|
84
|
+
];
|
|
54
85
|
const mockData: GetOrderPositionBooksQuery = {
|
|
55
|
-
orderPositionBooks:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
orderPositionBooks: {
|
|
87
|
+
books: [
|
|
88
|
+
createMockOrderPositionBook('2025-01-01T00:00:00Z'),
|
|
89
|
+
createMockOrderPositionBook('2025-01-01T01:00:00Z'),
|
|
90
|
+
],
|
|
91
|
+
bucketWidth: 0.0005,
|
|
92
|
+
sentimentThresholdMin: 0.15,
|
|
93
|
+
sentimentThresholdMax: 0.55,
|
|
94
|
+
},
|
|
59
95
|
};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
expect(result).toHaveLength(
|
|
66
|
-
expect(result
|
|
67
|
-
expect(result
|
|
96
|
+
const result = processOrderPositionBooks(mockData, dates);
|
|
97
|
+
expect(result.hasValidBooks).toBe(true);
|
|
98
|
+
expect(result.bucketWidth).toBe(0.0005);
|
|
99
|
+
expect(result.sentimentThresholdMin).toBe(0.15);
|
|
100
|
+
expect(result.sentimentThresholdMax).toBe(0.55);
|
|
101
|
+
expect(result.bookPrices).toHaveLength(3);
|
|
102
|
+
expect(result.bookIndexes).toHaveLength(3);
|
|
103
|
+
expect(result.buckets).toHaveLength(3);
|
|
104
|
+
expect(result.bookPrices[0]).toBe(1.0);
|
|
105
|
+
expect(result.bookPrices[1]).toBe(1.0);
|
|
106
|
+
expect(result.bookPrices[2]).toBeNull();
|
|
107
|
+
expect(result.bookIndexes).toEqual([0, 1, 2]);
|
|
108
|
+
expect(result.buckets[0]).toHaveLength(2);
|
|
109
|
+
expect(result.buckets[1]).toHaveLength(2);
|
|
110
|
+
expect(result.buckets[2]).toEqual([]);
|
|
68
111
|
});
|
|
69
112
|
|
|
70
|
-
it('should
|
|
113
|
+
it('should handle dates that do not match any book', () => {
|
|
114
|
+
const dates = [
|
|
115
|
+
'2025-01-01T00:00:00Z',
|
|
116
|
+
'2025-01-01T01:00:00Z',
|
|
117
|
+
'2025-01-01T02:00:00Z',
|
|
118
|
+
];
|
|
71
119
|
const mockData: GetOrderPositionBooksQuery = {
|
|
72
|
-
orderPositionBooks:
|
|
120
|
+
orderPositionBooks: {
|
|
121
|
+
books: [createMockOrderPositionBook('2025-01-01T00:00:00Z')],
|
|
122
|
+
bucketWidth: 0.0005,
|
|
123
|
+
sentimentThresholdMin: 0.15,
|
|
124
|
+
sentimentThresholdMax: 0.55,
|
|
125
|
+
},
|
|
73
126
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
expect(result).toHaveLength(
|
|
77
|
-
expect(result[
|
|
127
|
+
const result = processOrderPositionBooks(mockData, dates);
|
|
128
|
+
expect(result.bookPrices).toEqual([1.0, null, null]);
|
|
129
|
+
expect(result.buckets[0]).toHaveLength(2);
|
|
130
|
+
expect(result.buckets[1]).toEqual([]);
|
|
131
|
+
expect(result.buckets[2]).toEqual([]);
|
|
78
132
|
});
|
|
79
133
|
|
|
80
|
-
it('should
|
|
134
|
+
it('should handle books with null price', () => {
|
|
135
|
+
const dates = ['2025-01-01T00:00:00Z'];
|
|
81
136
|
const mockData: GetOrderPositionBooksQuery = {
|
|
82
|
-
orderPositionBooks:
|
|
137
|
+
orderPositionBooks: {
|
|
138
|
+
books: [
|
|
139
|
+
{
|
|
140
|
+
time: '2025-01-01T00:00:00Z',
|
|
141
|
+
price: null,
|
|
142
|
+
buckets: [{ price: 1.0, sentiment: 0.2 }],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
bucketWidth: 0.0005,
|
|
146
|
+
sentimentThresholdMin: 0.15,
|
|
147
|
+
sentimentThresholdMax: 0.55,
|
|
148
|
+
},
|
|
83
149
|
};
|
|
84
|
-
const
|
|
85
|
-
|
|
150
|
+
const result = processOrderPositionBooks(mockData, dates);
|
|
151
|
+
expect(result.bookPrices[0]).toBeNull();
|
|
152
|
+
expect(result.buckets[0]).toHaveLength(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should correctly map buckets structure', () => {
|
|
156
|
+
const dates = ['2025-01-01T00:00:00Z'];
|
|
157
|
+
const mockData: GetOrderPositionBooksQuery = {
|
|
158
|
+
orderPositionBooks: {
|
|
159
|
+
books: [
|
|
160
|
+
{
|
|
161
|
+
time: '2025-01-01T00:00:00Z',
|
|
162
|
+
price: 1.0,
|
|
163
|
+
buckets: [
|
|
164
|
+
{ price: 1.0, sentiment: 0.2 },
|
|
165
|
+
{ price: 1.0005, sentiment: -0.3 },
|
|
166
|
+
{ price: 1.001, sentiment: 0.5 },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
bucketWidth: 0.0005,
|
|
171
|
+
sentimentThresholdMin: 0.15,
|
|
172
|
+
sentimentThresholdMax: 0.55,
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const result = processOrderPositionBooks(mockData, dates);
|
|
176
|
+
expect(result.buckets[0]).toEqual([
|
|
177
|
+
{ price: 1.0, sentiment: 0.2 },
|
|
178
|
+
{ price: 1.0005, sentiment: -0.3 },
|
|
179
|
+
{ price: 1.001, sentiment: 0.5 },
|
|
86
180
|
]);
|
|
87
|
-
const result = processOrderPositionBooks(mockData, candleMap);
|
|
88
|
-
expect(result).toHaveLength(1);
|
|
89
|
-
expect(result[0]).toEqual(['2025-01-01', null, 0]);
|
|
90
181
|
});
|
|
91
182
|
|
|
92
|
-
it('should
|
|
183
|
+
it('should handle duplicate time values in books array (last one wins)', () => {
|
|
184
|
+
const dates = ['2025-01-01T00:00:00Z'];
|
|
93
185
|
const mockData: GetOrderPositionBooksQuery = {
|
|
94
|
-
orderPositionBooks:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
186
|
+
orderPositionBooks: {
|
|
187
|
+
books: [
|
|
188
|
+
{
|
|
189
|
+
time: '2025-01-01T00:00:00Z',
|
|
190
|
+
price: 1.0,
|
|
191
|
+
buckets: [{ price: 1.0, sentiment: 0.2 }],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
time: '2025-01-01T00:00:00Z',
|
|
195
|
+
price: 1.5,
|
|
196
|
+
buckets: [{ price: 1.5, sentiment: 0.8 }],
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
bucketWidth: 0.0005,
|
|
200
|
+
sentimentThresholdMin: 0.15,
|
|
201
|
+
sentimentThresholdMax: 0.55,
|
|
202
|
+
},
|
|
99
203
|
};
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
expect(result).
|
|
103
|
-
expect(result[0]
|
|
104
|
-
expect(result[1][2]).toBe(1);
|
|
105
|
-
expect(result[2][2]).toBe(2);
|
|
204
|
+
const result = processOrderPositionBooks(mockData, dates);
|
|
205
|
+
// Last entry should win
|
|
206
|
+
expect(result.bookPrices[0]).toBe(1.5);
|
|
207
|
+
expect(result.buckets[0]).toEqual([{ price: 1.5, sentiment: 0.8 }]);
|
|
106
208
|
});
|
|
107
209
|
|
|
108
|
-
it('should
|
|
210
|
+
it('should return empty arrays when dates array is empty', () => {
|
|
109
211
|
const mockData: GetOrderPositionBooksQuery = {
|
|
110
|
-
orderPositionBooks:
|
|
111
|
-
createMockOrderPositionBook('2025-01-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
212
|
+
orderPositionBooks: {
|
|
213
|
+
books: [createMockOrderPositionBook('2025-01-01T00:00:00Z')],
|
|
214
|
+
bucketWidth: 0.0005,
|
|
215
|
+
sentimentThresholdMin: 0.15,
|
|
216
|
+
sentimentThresholdMax: 0.55,
|
|
217
|
+
},
|
|
115
218
|
};
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
219
|
+
const result = processOrderPositionBooks(mockData, []);
|
|
220
|
+
expect(result).toEqual({
|
|
221
|
+
bookPrices: [],
|
|
222
|
+
bookIndexes: [],
|
|
223
|
+
buckets: [],
|
|
224
|
+
bucketWidth: 0,
|
|
225
|
+
sentimentThresholdMin: 0,
|
|
226
|
+
sentimentThresholdMax: 0,
|
|
227
|
+
hasValidBooks: false,
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should return empty arrays when dates is not an array', () => {
|
|
232
|
+
const mockData: GetOrderPositionBooksQuery = {
|
|
233
|
+
orderPositionBooks: {
|
|
234
|
+
books: [createMockOrderPositionBook('2025-01-01T00:00:00Z')],
|
|
235
|
+
bucketWidth: 0.0005,
|
|
236
|
+
sentimentThresholdMin: 0.15,
|
|
237
|
+
sentimentThresholdMax: 0.55,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
// @ts-expect-error - Testing invalid input
|
|
241
|
+
const result = processOrderPositionBooks(mockData, null);
|
|
242
|
+
expect(result.hasValidBooks).toBe(false);
|
|
126
243
|
});
|
|
127
244
|
});
|