@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { BookType } from '../../../../gql/types/graphql';
|
|
2
|
+
import type { Bucket, TooltipParam } from '../types';
|
|
3
|
+
|
|
4
|
+
const DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
|
|
5
|
+
hour: '2-digit',
|
|
6
|
+
minute: '2-digit',
|
|
7
|
+
year: 'numeric',
|
|
8
|
+
day: 'numeric',
|
|
9
|
+
month: 'numeric',
|
|
10
|
+
timeZoneName: 'short',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const SENTIMENT_DISPLAY_PRECISION = 2;
|
|
14
|
+
|
|
15
|
+
const calculateBucketDisplayPrecision = (bucketWidth: number): number => {
|
|
16
|
+
return bucketWidth.toString().split('.')[1]?.length || 0;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const findSeriesParam = <T extends TooltipParam['seriesId']>(
|
|
20
|
+
params: TooltipParam[],
|
|
21
|
+
seriesId: T
|
|
22
|
+
): Extract<TooltipParam, { seriesId: T }> | undefined => {
|
|
23
|
+
return params.find(
|
|
24
|
+
(series): series is Extract<TooltipParam, { seriesId: T }> =>
|
|
25
|
+
series.seriesId === seriesId
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getSentimentOverbalanceLabel = (
|
|
30
|
+
sentiment: number,
|
|
31
|
+
bookType: BookType
|
|
32
|
+
): string => {
|
|
33
|
+
if (sentiment < 0) {
|
|
34
|
+
return bookType === BookType.Order
|
|
35
|
+
? 'sell_overbalance'
|
|
36
|
+
: 'short_overbalance';
|
|
37
|
+
}
|
|
38
|
+
return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const formatCandleData = (
|
|
42
|
+
candleData: [number, number, number, number, number],
|
|
43
|
+
labelCallback: (key: string) => string
|
|
44
|
+
): string => {
|
|
45
|
+
const [, open, close, low, high] = candleData;
|
|
46
|
+
return `<p><b>${labelCallback('candle')}:</b></p>
|
|
47
|
+
<p>${labelCallback('open_price')}: ${open} </p>
|
|
48
|
+
<p>${labelCallback('close_price')}: ${close} </p>
|
|
49
|
+
<p>${labelCallback('low')}: ${low} </p>
|
|
50
|
+
<p>${labelCallback('high')}: ${high} </p>
|
|
51
|
+
`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const formatBookData = ({
|
|
55
|
+
matchedBucket,
|
|
56
|
+
bucketWidth,
|
|
57
|
+
bucketDisplayPrecision,
|
|
58
|
+
bookType,
|
|
59
|
+
labelCallback,
|
|
60
|
+
}: {
|
|
61
|
+
matchedBucket: Bucket;
|
|
62
|
+
bucketWidth: number;
|
|
63
|
+
bucketDisplayPrecision: number;
|
|
64
|
+
bookType: BookType;
|
|
65
|
+
labelCallback: (key: string) => string;
|
|
66
|
+
}): string => {
|
|
67
|
+
const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';
|
|
68
|
+
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
69
|
+
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(
|
|
70
|
+
bucketDisplayPrecision
|
|
71
|
+
);
|
|
72
|
+
const sentimentLabel = getSentimentOverbalanceLabel(
|
|
73
|
+
matchedBucket.sentiment,
|
|
74
|
+
bookType
|
|
75
|
+
);
|
|
76
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(
|
|
77
|
+
bucketDisplayPrecision
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return `<br /><p><b>${labelCallback(bookLabelKey)}:</b></p>
|
|
81
|
+
<p>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </p>
|
|
82
|
+
<p>${labelCallback(sentimentLabel)}: ${sentimentValue}% </p>`;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const formatSentimentData = (
|
|
86
|
+
sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }>,
|
|
87
|
+
labelCallback: (key: string) => string
|
|
88
|
+
): string => {
|
|
89
|
+
const [, shortPercent, longPercent] = sentimentParam.value;
|
|
90
|
+
return `<br /><p><b>${labelCallback('sentiment')}:</b></p>
|
|
91
|
+
<p>${labelCallback('long')}: ${longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>
|
|
92
|
+
<p>${labelCallback('short')}: ${shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>`;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const hasValidCandleData = (
|
|
96
|
+
candleData: [number, number, number, number, number]
|
|
97
|
+
): boolean =>
|
|
98
|
+
!!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[3];
|
|
99
|
+
const hasValidSentimentData = (
|
|
100
|
+
sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }> | undefined
|
|
101
|
+
): boolean => !!sentimentParam?.value[1] && !!sentimentParam?.value[2];
|
|
102
|
+
const findMatchingBucket = (
|
|
103
|
+
buckets: Bucket[][],
|
|
104
|
+
bucketsIndex: number | undefined,
|
|
105
|
+
selectedPrice: number,
|
|
106
|
+
bucketWidth: number
|
|
107
|
+
): Bucket | undefined => {
|
|
108
|
+
if (bucketsIndex === undefined) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const selectedBuckets = buckets[bucketsIndex];
|
|
112
|
+
return selectedBuckets?.find(
|
|
113
|
+
({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const getTooltipFormatter = ({
|
|
118
|
+
params,
|
|
119
|
+
buckets,
|
|
120
|
+
bucketWidth,
|
|
121
|
+
selectedPrice,
|
|
122
|
+
bookType,
|
|
123
|
+
labelCallback,
|
|
124
|
+
}: {
|
|
125
|
+
params: TooltipParam[];
|
|
126
|
+
buckets: Bucket[][];
|
|
127
|
+
bucketWidth: number;
|
|
128
|
+
selectedPrice: number;
|
|
129
|
+
bookType: BookType;
|
|
130
|
+
labelCallback: (key: string) => string;
|
|
131
|
+
}) => {
|
|
132
|
+
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const candleParam = findSeriesParam(params, 'candlestick');
|
|
137
|
+
const booksParam = findSeriesParam(params, 'heatmap');
|
|
138
|
+
const sentimentParam = findSeriesParam(params, 'sentiment');
|
|
139
|
+
|
|
140
|
+
if (!candleParam) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);
|
|
145
|
+
const time = new Date(candleParam.axisValue as string);
|
|
146
|
+
const candleData = candleParam.value;
|
|
147
|
+
const bucketsIndex = booksParam?.value[2];
|
|
148
|
+
const matchedBucket = findMatchingBucket(
|
|
149
|
+
buckets,
|
|
150
|
+
bucketsIndex,
|
|
151
|
+
selectedPrice,
|
|
152
|
+
bucketWidth
|
|
153
|
+
);
|
|
154
|
+
const showCandles = hasValidCandleData(candleData);
|
|
155
|
+
const showSentiment = hasValidSentimentData(sentimentParam);
|
|
156
|
+
|
|
157
|
+
if (!showCandles && !matchedBucket) {
|
|
158
|
+
return '';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);
|
|
162
|
+
const candleSection = showCandles
|
|
163
|
+
? formatCandleData(candleData, labelCallback)
|
|
164
|
+
: '';
|
|
165
|
+
const bookSection = matchedBucket
|
|
166
|
+
? formatBookData({
|
|
167
|
+
matchedBucket,
|
|
168
|
+
bucketWidth,
|
|
169
|
+
bucketDisplayPrecision,
|
|
170
|
+
bookType,
|
|
171
|
+
labelCallback,
|
|
172
|
+
})
|
|
173
|
+
: '';
|
|
174
|
+
const sentimentSection =
|
|
175
|
+
showSentiment && sentimentParam
|
|
176
|
+
? formatSentimentData(sentimentParam, labelCallback)
|
|
177
|
+
: '';
|
|
178
|
+
|
|
179
|
+
return `<p>${timeFormatted}</p><br />
|
|
180
|
+
${candleSection}
|
|
181
|
+
${bookSection}
|
|
182
|
+
${sentimentSection}`;
|
|
183
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './formatXAxisLabel';
|
|
2
|
+
export * from './getChartStyles';
|
|
3
|
+
export * from './getGradientColor';
|
|
4
|
+
export * from './getLabelData';
|
|
5
|
+
export * from './getRectColor';
|
|
6
|
+
export * from './getTooltipFormatter';
|
|
7
|
+
export * from './isDifferenceGreaterThanTwoWeeks';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TIME_THRESHOLDS } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
export const isDifferenceGreaterThanTwoWeeks = (
|
|
4
|
+
startDate: string,
|
|
5
|
+
endDate: string
|
|
6
|
+
) => {
|
|
7
|
+
const date1 = new Date(startDate);
|
|
8
|
+
const date2 = new Date(endDate);
|
|
9
|
+
|
|
10
|
+
const differenceInMs = Math.abs(date2.getTime() - date1.getTime());
|
|
11
|
+
|
|
12
|
+
return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;
|
|
13
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Division } from '
|
|
1
|
+
import { Division } from '../../../../gql/types/graphql';
|
|
2
2
|
import {
|
|
3
3
|
instrumentSelectConfig,
|
|
4
4
|
instrumentSelectConfigOC,
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../../selectConfig';
|
|
6
6
|
|
|
7
7
|
export const getInstrumentConfigForDivision = (division: Division) => {
|
|
8
8
|
return division === Division.Oc
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Granularity, TimeSpan } from '../../../../gql/types/graphql';
|
|
2
|
+
|
|
3
|
+
export const getTimeSpanForGranularity = (
|
|
4
|
+
granularity: Granularity
|
|
5
|
+
): TimeSpan => {
|
|
6
|
+
const granularityTimeSpanMap: Record<Granularity, TimeSpan> = {
|
|
7
|
+
[Granularity.M5]: TimeSpan.TwoDays,
|
|
8
|
+
[Granularity.M15]: TimeSpan.FiveDays,
|
|
9
|
+
[Granularity.H1]: TimeSpan.TwentyDays,
|
|
10
|
+
[Granularity.H4]: TimeSpan.NinetyDays,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;
|
|
14
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { GetOrderPositionBooksQuery } from '../../../../gql/types/graphql';
|
|
2
|
+
import type { Bucket } from '../types';
|
|
3
|
+
|
|
4
|
+
export const processOrderPositionBooks = (
|
|
5
|
+
orderPositionData: GetOrderPositionBooksQuery | undefined,
|
|
6
|
+
dates: string[]
|
|
7
|
+
) => {
|
|
8
|
+
// Input validation
|
|
9
|
+
if (!Array.isArray(dates) || dates.length === 0) {
|
|
10
|
+
return {
|
|
11
|
+
bookPrices: [],
|
|
12
|
+
bookIndexes: [],
|
|
13
|
+
buckets: [],
|
|
14
|
+
bucketWidth: 0,
|
|
15
|
+
sentimentThresholdMin: 0,
|
|
16
|
+
sentimentThresholdMax: 0,
|
|
17
|
+
hasValidBooks: false,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
!orderPositionData?.orderPositionBooks?.books?.length ||
|
|
23
|
+
!orderPositionData?.orderPositionBooks?.sentimentThresholdMin ||
|
|
24
|
+
!orderPositionData?.orderPositionBooks?.sentimentThresholdMax ||
|
|
25
|
+
!orderPositionData?.orderPositionBooks?.bucketWidth
|
|
26
|
+
) {
|
|
27
|
+
return {
|
|
28
|
+
bookPrices: [],
|
|
29
|
+
bookIndexes: [],
|
|
30
|
+
buckets: [],
|
|
31
|
+
bucketWidth: 0,
|
|
32
|
+
sentimentThresholdMin: 0,
|
|
33
|
+
sentimentThresholdMax: 0,
|
|
34
|
+
hasValidBooks: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { bucketWidth, sentimentThresholdMin, sentimentThresholdMax } =
|
|
39
|
+
orderPositionData.orderPositionBooks;
|
|
40
|
+
|
|
41
|
+
const booksDataMap = new Map(
|
|
42
|
+
orderPositionData.orderPositionBooks.books.map((item) => [
|
|
43
|
+
item.time,
|
|
44
|
+
{
|
|
45
|
+
price: item.price,
|
|
46
|
+
buckets: item.buckets,
|
|
47
|
+
},
|
|
48
|
+
])
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Use forEach + push for O(n) performance instead of reduce with spreads (O(n²))
|
|
52
|
+
const bookPrices: (number | null)[] = [];
|
|
53
|
+
const bookIndexes: number[] = [];
|
|
54
|
+
const buckets: Bucket[][] = [];
|
|
55
|
+
|
|
56
|
+
dates.forEach((date, index) => {
|
|
57
|
+
const book = booksDataMap.get(date);
|
|
58
|
+
|
|
59
|
+
const currentBuckets =
|
|
60
|
+
book?.buckets
|
|
61
|
+
.filter(
|
|
62
|
+
(
|
|
63
|
+
bucket
|
|
64
|
+
): bucket is {
|
|
65
|
+
price: number;
|
|
66
|
+
sentiment: number;
|
|
67
|
+
} =>
|
|
68
|
+
bucket !== null &&
|
|
69
|
+
typeof bucket.price === 'number' &&
|
|
70
|
+
typeof bucket.sentiment === 'number' &&
|
|
71
|
+
Math.abs(bucket.sentiment) >= sentimentThresholdMin
|
|
72
|
+
)
|
|
73
|
+
.map((bucket) => ({
|
|
74
|
+
price: bucket.price,
|
|
75
|
+
sentiment: bucket.sentiment,
|
|
76
|
+
})) || [];
|
|
77
|
+
|
|
78
|
+
bookPrices.push(book?.price ?? null);
|
|
79
|
+
bookIndexes.push(index);
|
|
80
|
+
buckets.push(currentBuckets);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
bookPrices,
|
|
85
|
+
bookIndexes,
|
|
86
|
+
buckets,
|
|
87
|
+
bucketWidth,
|
|
88
|
+
sentimentThresholdMin,
|
|
89
|
+
sentimentThresholdMax,
|
|
90
|
+
hasValidBooks: true,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { GetPriceCandlesQuery } from '../../../../gql/types/graphql';
|
|
2
|
+
|
|
3
|
+
export const processPriceCandles = (
|
|
4
|
+
priceCandlesData: GetPriceCandlesQuery | undefined
|
|
5
|
+
) => {
|
|
6
|
+
const errorResult = {
|
|
7
|
+
minPrice: 0,
|
|
8
|
+
maxPrice: 0,
|
|
9
|
+
pipsLocation: 0,
|
|
10
|
+
hasValidCandles: false,
|
|
11
|
+
candlesOpen: [],
|
|
12
|
+
candlesClose: [],
|
|
13
|
+
candlesLow: [],
|
|
14
|
+
candlesHigh: [],
|
|
15
|
+
dates: [],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (
|
|
19
|
+
!priceCandlesData?.priceCandles?.candle?.length ||
|
|
20
|
+
!priceCandlesData?.priceCandles?.pipsLocation
|
|
21
|
+
) {
|
|
22
|
+
return errorResult;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { dates, candlesOpen, candlesClose, candlesLow, candlesHigh } =
|
|
26
|
+
priceCandlesData.priceCandles.candle.reduce(
|
|
27
|
+
(acc, candle) => {
|
|
28
|
+
if (!candle) {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
dates: [...acc.dates, candle.point],
|
|
34
|
+
candlesOpen: [...acc.candlesOpen, candle.open],
|
|
35
|
+
candlesClose: [...acc.candlesClose, candle.close],
|
|
36
|
+
candlesLow: [...acc.candlesLow, candle.low],
|
|
37
|
+
candlesHigh: [...acc.candlesHigh, candle.high],
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
dates: [] as string[],
|
|
42
|
+
candlesOpen: [] as number[],
|
|
43
|
+
candlesClose: [] as number[],
|
|
44
|
+
candlesLow: [] as number[],
|
|
45
|
+
candlesHigh: [] as number[],
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (dates.length === 0) {
|
|
50
|
+
return errorResult;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const minPrice = Math.min(...candlesLow);
|
|
54
|
+
const maxPrice = Math.max(...candlesHigh);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
minPrice,
|
|
58
|
+
maxPrice,
|
|
59
|
+
candlesOpen,
|
|
60
|
+
candlesClose,
|
|
61
|
+
candlesLow,
|
|
62
|
+
candlesHigh,
|
|
63
|
+
dates,
|
|
64
|
+
hasValidCandles: true,
|
|
65
|
+
pipsLocation: priceCandlesData.priceCandles.pipsLocation,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { GetSentimentsQuery } from '../../../../gql/types/graphql';
|
|
2
|
+
|
|
3
|
+
export const processSentiments = (
|
|
4
|
+
sentimentsData: GetSentimentsQuery | undefined,
|
|
5
|
+
dates: string[]
|
|
6
|
+
) => {
|
|
7
|
+
if (
|
|
8
|
+
!Array.isArray(dates) ||
|
|
9
|
+
dates.length === 0 ||
|
|
10
|
+
!sentimentsData?.sentiments?.sentiments?.length
|
|
11
|
+
) {
|
|
12
|
+
return {
|
|
13
|
+
sentimentLongs: [],
|
|
14
|
+
sentimentShorts: [],
|
|
15
|
+
hasValidSentiments: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sentimentMap = new Map(
|
|
20
|
+
sentimentsData.sentiments.sentiments.map((item) => [
|
|
21
|
+
item?.time,
|
|
22
|
+
{
|
|
23
|
+
sentimentShorts: item?.sentiment?.shortPercent ?? null,
|
|
24
|
+
sentimentLongs: item?.sentiment?.longPercent ?? null,
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const { sentimentLongs, sentimentShorts } = dates.reduce(
|
|
30
|
+
(acc, date) => {
|
|
31
|
+
const sentiment = sentimentMap.get(date);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
sentimentLongs: [
|
|
35
|
+
...acc.sentimentLongs,
|
|
36
|
+
sentiment?.sentimentLongs || null,
|
|
37
|
+
],
|
|
38
|
+
sentimentShorts: [
|
|
39
|
+
...acc.sentimentShorts,
|
|
40
|
+
sentiment?.sentimentShorts || null,
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
sentimentLongs: [] as (number | null)[],
|
|
46
|
+
sentimentShorts: [] as (number | null)[],
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
sentimentLongs,
|
|
52
|
+
sentimentShorts,
|
|
53
|
+
hasValidSentiments: true,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -6,12 +6,14 @@ import type {
|
|
|
6
6
|
export const validateData = (
|
|
7
7
|
priceCandlesData: GetPriceCandlesQuery | undefined,
|
|
8
8
|
orderPositionData: GetOrderPositionBooksQuery | undefined,
|
|
9
|
-
hasValidCandles: boolean
|
|
9
|
+
hasValidCandles: boolean,
|
|
10
|
+
hasValidBooks: boolean,
|
|
11
|
+
hasValidSentiments: boolean
|
|
10
12
|
): Error | null => {
|
|
11
13
|
const hasValidPriceData =
|
|
12
14
|
(priceCandlesData?.priceCandles?.candle?.length ?? 0) >= 1;
|
|
13
15
|
const hasValidOrderData =
|
|
14
|
-
(orderPositionData?.orderPositionBooks?.length ?? 0) >= 1;
|
|
16
|
+
(orderPositionData?.orderPositionBooks?.books?.length ?? 0) >= 1;
|
|
15
17
|
|
|
16
18
|
if (!hasValidPriceData) {
|
|
17
19
|
return new Error('Insufficient price candle data');
|
|
@@ -22,6 +24,12 @@ export const validateData = (
|
|
|
22
24
|
if (!hasValidCandles) {
|
|
23
25
|
return new Error('Invalid candle data');
|
|
24
26
|
}
|
|
27
|
+
if (!hasValidBooks) {
|
|
28
|
+
return new Error('Invalid book data');
|
|
29
|
+
}
|
|
30
|
+
if (!hasValidSentiments) {
|
|
31
|
+
return new Error('Invalid sentiment data');
|
|
32
|
+
}
|
|
25
33
|
|
|
26
34
|
return null;
|
|
27
35
|
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../constants';
|
|
2
|
+
import {
|
|
3
|
+
getDataZoomConfig,
|
|
4
|
+
getGridConfig,
|
|
5
|
+
getGridLines,
|
|
6
|
+
getSeriesCandlestickConfig,
|
|
7
|
+
getSeriesHeatmapConfig,
|
|
8
|
+
getSeriesSentimentConfig,
|
|
9
|
+
getTooltipConfig,
|
|
10
|
+
getVisualMapConfig,
|
|
11
|
+
getXAxisConfig,
|
|
12
|
+
getYAxisConfig,
|
|
13
|
+
} from './chartOptions';
|
|
14
|
+
import { isDifferenceGreaterThanTwoWeeks } from './chartUtils';
|
|
15
|
+
import { getChartStyles } from './chartUtils/getChartStyles';
|
|
16
|
+
import type { GetOptionType } from './types';
|
|
17
|
+
|
|
18
|
+
export const getOption: GetOptionType = ({
|
|
19
|
+
mainData: {
|
|
20
|
+
dates,
|
|
21
|
+
candlesOpen,
|
|
22
|
+
candlesClose,
|
|
23
|
+
candlesLow,
|
|
24
|
+
candlesHigh,
|
|
25
|
+
bookPrices,
|
|
26
|
+
bookIndexes,
|
|
27
|
+
sentimentShorts,
|
|
28
|
+
sentimentLongs,
|
|
29
|
+
},
|
|
30
|
+
additionalData: {
|
|
31
|
+
bucketWidth,
|
|
32
|
+
buckets,
|
|
33
|
+
displayPrecision,
|
|
34
|
+
bookType,
|
|
35
|
+
sentimentThresholdMin,
|
|
36
|
+
sentimentThresholdMax,
|
|
37
|
+
},
|
|
38
|
+
isDark,
|
|
39
|
+
isDesktop,
|
|
40
|
+
labelCallback,
|
|
41
|
+
}) => {
|
|
42
|
+
const styles = getChartStyles(isDark);
|
|
43
|
+
const selectedPriceRef = { current: 0 };
|
|
44
|
+
|
|
45
|
+
const visibleXAxisData = dates.slice(
|
|
46
|
+
(dates.length * CHART_CONFIG.INITIAL_START_ZOOM) / 100,
|
|
47
|
+
(dates.length * CHART_CONFIG.INITIAL_END_ZOOM) / 100
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(
|
|
51
|
+
visibleXAxisData[0],
|
|
52
|
+
visibleXAxisData[visibleXAxisData.length - 1]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
animation: false,
|
|
57
|
+
tooltip: getTooltipConfig({
|
|
58
|
+
bookType,
|
|
59
|
+
bucketWidth,
|
|
60
|
+
buckets,
|
|
61
|
+
displayPrecision,
|
|
62
|
+
labelCallback,
|
|
63
|
+
selectedPriceRef,
|
|
64
|
+
tooltipLinesColor: styles.tooltipLinesColor,
|
|
65
|
+
}),
|
|
66
|
+
grid: getGridConfig({ isDesktop }),
|
|
67
|
+
xAxis: getXAxisConfig({
|
|
68
|
+
dates,
|
|
69
|
+
isGreaterThanTwoWeeks,
|
|
70
|
+
}),
|
|
71
|
+
yAxis: getYAxisConfig({
|
|
72
|
+
bucketWidth,
|
|
73
|
+
displayPrecision,
|
|
74
|
+
isDesktop,
|
|
75
|
+
labelCallback,
|
|
76
|
+
}),
|
|
77
|
+
dataZoom: getDataZoomConfig(),
|
|
78
|
+
visualMap: getVisualMapConfig({
|
|
79
|
+
sentimentLongColor: styles.sentimentLongColor,
|
|
80
|
+
sentimentShortColor: styles.sentimentShortColor,
|
|
81
|
+
}),
|
|
82
|
+
graphic: getGridLines({ isDark }),
|
|
83
|
+
dataset: {
|
|
84
|
+
source: {
|
|
85
|
+
dates,
|
|
86
|
+
candlesOpen,
|
|
87
|
+
candlesClose,
|
|
88
|
+
candlesLow,
|
|
89
|
+
candlesHigh,
|
|
90
|
+
bookPrices: bookPrices ?? [],
|
|
91
|
+
bookIndexes: bookIndexes ?? [],
|
|
92
|
+
sentimentShorts,
|
|
93
|
+
sentimentLongs,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
series: [
|
|
97
|
+
getSeriesCandlestickConfig({
|
|
98
|
+
dates,
|
|
99
|
+
isGreaterThanTwoWeeks,
|
|
100
|
+
styles,
|
|
101
|
+
}),
|
|
102
|
+
getSeriesHeatmapConfig({
|
|
103
|
+
bucketWidth,
|
|
104
|
+
buckets,
|
|
105
|
+
isDark,
|
|
106
|
+
sentimentThresholdMax,
|
|
107
|
+
sentimentThresholdMin,
|
|
108
|
+
}),
|
|
109
|
+
getSeriesSentimentConfig({
|
|
110
|
+
styles,
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -19,36 +19,47 @@ export interface UseCrowdViewDataProps {
|
|
|
19
19
|
granularity: Granularity;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
interface CrowdViewMainData {
|
|
23
|
+
dates: string[];
|
|
24
|
+
candlesOpen: number[];
|
|
25
|
+
candlesClose: number[];
|
|
26
|
+
candlesLow: number[];
|
|
27
|
+
candlesHigh: number[];
|
|
28
|
+
bookPrices?: (number | null)[];
|
|
29
|
+
bookIndexes?: (number | null)[];
|
|
30
|
+
sentimentShorts: (number | null)[];
|
|
31
|
+
sentimentLongs: (number | null)[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface CrowdViewAdditionalData {
|
|
30
35
|
bucketWidth: number;
|
|
31
36
|
buckets: Bucket[][];
|
|
32
|
-
|
|
37
|
+
displayPrecision: number;
|
|
33
38
|
bookType: BookType;
|
|
34
|
-
|
|
39
|
+
sentimentThresholdMin: number;
|
|
40
|
+
sentimentThresholdMax: number;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export interface UseCrowdViewDataReturn {
|
|
38
|
-
|
|
44
|
+
mainData?: CrowdViewMainData | null;
|
|
45
|
+
additionalData?: CrowdViewAdditionalData | null;
|
|
39
46
|
loading: boolean;
|
|
40
47
|
error: boolean;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
) =>
|
|
50
|
+
interface GetOptionProps {
|
|
51
|
+
mainData: CrowdViewMainData;
|
|
52
|
+
additionalData: CrowdViewAdditionalData;
|
|
53
|
+
isDark: boolean;
|
|
54
|
+
isDesktop: boolean;
|
|
55
|
+
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type GetOptionType = (props: GetOptionProps) => EChartsOption;
|
|
49
59
|
|
|
50
60
|
export interface ChartProps {
|
|
51
|
-
|
|
61
|
+
mainData: CrowdViewMainData;
|
|
62
|
+
additionalData: CrowdViewAdditionalData;
|
|
52
63
|
isDesktop: boolean;
|
|
53
64
|
}
|
|
54
65
|
|
|
@@ -60,7 +71,7 @@ export interface ChartWithDataProps {
|
|
|
60
71
|
}
|
|
61
72
|
|
|
62
73
|
export interface GetLabelsDataProps {
|
|
63
|
-
|
|
74
|
+
dates: string[];
|
|
64
75
|
isGreaterThanTwoWeeks: boolean;
|
|
65
76
|
}
|
|
66
77
|
|