@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
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import chroma from 'chroma-js';
|
|
2
|
-
|
|
3
|
-
import { CHART_CONFIG, CHART_CONFIG_CALCULATED } from '../../constants';
|
|
4
|
-
import type { Bucket, GetOptionType, TooltipParam } from './types';
|
|
5
|
-
import {
|
|
6
|
-
formatXAxisLabel,
|
|
7
|
-
getLabelData,
|
|
8
|
-
getRectColor,
|
|
9
|
-
getTooltipFormatter,
|
|
10
|
-
isDifferenceGreaterThanTwoWeeks,
|
|
11
|
-
} from './utils/chartUtils';
|
|
12
|
-
import { getChartStyles } from './utils/getChartStyles';
|
|
13
|
-
import { getGridLines } from './utils/getGridLines';
|
|
14
|
-
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
export const getOption: GetOptionType = (
|
|
17
|
-
{
|
|
18
|
-
xAxisData,
|
|
19
|
-
candlesSeriesData,
|
|
20
|
-
orderPositionBooks,
|
|
21
|
-
bucketWidth,
|
|
22
|
-
buckets,
|
|
23
|
-
precision,
|
|
24
|
-
bookType,
|
|
25
|
-
sentiments,
|
|
26
|
-
},
|
|
27
|
-
isDark,
|
|
28
|
-
isDesktop,
|
|
29
|
-
labelCallback
|
|
30
|
-
) => {
|
|
31
|
-
let selectedPrice: number;
|
|
32
|
-
const {
|
|
33
|
-
sentimentLongColor,
|
|
34
|
-
sentimentShortColor,
|
|
35
|
-
candleLongColor,
|
|
36
|
-
candleShortColor,
|
|
37
|
-
sentimentAreaOpacity,
|
|
38
|
-
tooltipLinesColor,
|
|
39
|
-
sentimentLabelColor,
|
|
40
|
-
} = getChartStyles(isDark);
|
|
41
|
-
|
|
42
|
-
const visibleXAxisData = xAxisData.slice(
|
|
43
|
-
(xAxisData.length * CHART_CONFIG.INITIAL_START_ZOOM) / 100,
|
|
44
|
-
(xAxisData.length * CHART_CONFIG.INITIAL_END_ZOOM) / 100
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(
|
|
48
|
-
visibleXAxisData[0],
|
|
49
|
-
visibleXAxisData[visibleXAxisData.length - 1]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const labelsData = getLabelData({
|
|
53
|
-
xAxisData,
|
|
54
|
-
isGreaterThanTwoWeeks,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const gridMainLines = getGridLines({
|
|
58
|
-
isDark,
|
|
59
|
-
isDesktop,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
animation: false,
|
|
64
|
-
dataZoom: [
|
|
65
|
-
{
|
|
66
|
-
id: 'main',
|
|
67
|
-
type: 'inside',
|
|
68
|
-
xAxisIndex: 0,
|
|
69
|
-
start: CHART_CONFIG.INITIAL_START_ZOOM,
|
|
70
|
-
end: CHART_CONFIG.INITIAL_END_ZOOM,
|
|
71
|
-
filterMode: 'filter',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: 'sentiment',
|
|
75
|
-
type: 'inside',
|
|
76
|
-
xAxisIndex: 1,
|
|
77
|
-
start: CHART_CONFIG.INITIAL_START_ZOOM,
|
|
78
|
-
end: CHART_CONFIG.INITIAL_END_ZOOM,
|
|
79
|
-
filterMode: 'none',
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
tooltip: {
|
|
83
|
-
trigger: 'axis',
|
|
84
|
-
axisPointer: {
|
|
85
|
-
type: 'cross',
|
|
86
|
-
axis: 'x',
|
|
87
|
-
lineStyle: {
|
|
88
|
-
color: tooltipLinesColor,
|
|
89
|
-
},
|
|
90
|
-
crossStyle: {
|
|
91
|
-
color: tooltipLinesColor,
|
|
92
|
-
},
|
|
93
|
-
label: {
|
|
94
|
-
padding: 0,
|
|
95
|
-
lineHeight: 24,
|
|
96
|
-
formatter: (params) => {
|
|
97
|
-
if (params.axisDimension === 'y' && params.axisIndex === 0) {
|
|
98
|
-
selectedPrice = Number(params.value);
|
|
99
|
-
return ` ${Number(params.value).toFixed(precision)} `;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return null;
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
confine: true,
|
|
107
|
-
formatter: (params: TooltipParam[]) =>
|
|
108
|
-
getTooltipFormatter({
|
|
109
|
-
params,
|
|
110
|
-
buckets,
|
|
111
|
-
bucketWidth,
|
|
112
|
-
selectedPrice,
|
|
113
|
-
labelCallback,
|
|
114
|
-
precision,
|
|
115
|
-
bookType,
|
|
116
|
-
}),
|
|
117
|
-
},
|
|
118
|
-
xAxis: [
|
|
119
|
-
{
|
|
120
|
-
type: 'category',
|
|
121
|
-
name: 'xAxis-less-than-two-weeks',
|
|
122
|
-
nameTextStyle: {
|
|
123
|
-
fontSize: 0,
|
|
124
|
-
},
|
|
125
|
-
id: 'main-xAxis',
|
|
126
|
-
data: xAxisData,
|
|
127
|
-
splitNumber: 1,
|
|
128
|
-
axisTick: {
|
|
129
|
-
show: false,
|
|
130
|
-
},
|
|
131
|
-
axisLabel: {
|
|
132
|
-
padding: [8, 16, 8, 16],
|
|
133
|
-
margin: 0,
|
|
134
|
-
formatter: (value) => formatXAxisLabel(value, isGreaterThanTwoWeeks),
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
type: 'category',
|
|
139
|
-
gridIndex: 1,
|
|
140
|
-
show: false,
|
|
141
|
-
data: xAxisData,
|
|
142
|
-
splitNumber: 1,
|
|
143
|
-
axisTick: {
|
|
144
|
-
show: false,
|
|
145
|
-
},
|
|
146
|
-
axisLabel: {
|
|
147
|
-
show: false,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
yAxis: [
|
|
152
|
-
{
|
|
153
|
-
type: 'value',
|
|
154
|
-
gridIndex: 0,
|
|
155
|
-
position: 'right',
|
|
156
|
-
min: (val) => val.min - bucketWidth * 2,
|
|
157
|
-
max: (val) => val.max + bucketWidth * 2,
|
|
158
|
-
axisLine: { show: false },
|
|
159
|
-
axisTick: { show: false },
|
|
160
|
-
axisLabel: {
|
|
161
|
-
showMaxLabel: false,
|
|
162
|
-
showMinLabel: false,
|
|
163
|
-
margin: isDesktop ? 4 : 2,
|
|
164
|
-
formatter: (value: number) => value.toFixed(precision - 1),
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
type: 'value',
|
|
169
|
-
gridIndex: 1,
|
|
170
|
-
position: 'right',
|
|
171
|
-
min: CHART_CONFIG.SENTIMENT_MIN,
|
|
172
|
-
max: CHART_CONFIG.SENTIMENT_MAX,
|
|
173
|
-
interval: CHART_CONFIG.SENTIMENT_INTERVAL,
|
|
174
|
-
axisLine: { show: false },
|
|
175
|
-
axisTick: { show: false },
|
|
176
|
-
axisLabel: {
|
|
177
|
-
verticalAlignMaxLabel: 'top',
|
|
178
|
-
verticalAlignMinLabel: 'bottom',
|
|
179
|
-
lineHeight: 20,
|
|
180
|
-
margin: isDesktop ? 4 : 2,
|
|
181
|
-
rich: {
|
|
182
|
-
shortRect: {
|
|
183
|
-
backgroundColor: chroma(sentimentShortColor).alpha(0.3).css(),
|
|
184
|
-
borderColor: sentimentShortColor,
|
|
185
|
-
borderWidth: 1,
|
|
186
|
-
width: 8,
|
|
187
|
-
height: 8,
|
|
188
|
-
},
|
|
189
|
-
longRect: {
|
|
190
|
-
backgroundColor: chroma(sentimentLongColor).alpha(0.3).css(),
|
|
191
|
-
borderColor: sentimentLongColor,
|
|
192
|
-
borderWidth: 1,
|
|
193
|
-
width: 8,
|
|
194
|
-
height: 8,
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
formatter: (value: number) => {
|
|
198
|
-
if (value === CHART_CONFIG.SENTIMENT_MIN) {
|
|
199
|
-
return `{shortRect| } ${labelCallback('short')}`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX) {
|
|
203
|
-
return `{longRect| } ${labelCallback('long')}`;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
|
|
207
|
-
return '50%';
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return undefined;
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
axisPointer: {
|
|
216
|
-
link: [
|
|
217
|
-
{
|
|
218
|
-
xAxisIndex: 'all',
|
|
219
|
-
},
|
|
220
|
-
],
|
|
221
|
-
},
|
|
222
|
-
visualMap: {
|
|
223
|
-
show: false,
|
|
224
|
-
seriesId: 'sentiment',
|
|
225
|
-
dimension: 1,
|
|
226
|
-
pieces: [
|
|
227
|
-
{
|
|
228
|
-
lt: CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
229
|
-
color: sentimentShortColor,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
gte: CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
233
|
-
lte: CHART_CONFIG.SENTIMENT_MAX,
|
|
234
|
-
color: sentimentLongColor,
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
gt: CHART_CONFIG.SENTIMENT_MAX,
|
|
238
|
-
color: sentimentLongColor,
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
},
|
|
242
|
-
series: [
|
|
243
|
-
{
|
|
244
|
-
type: 'candlestick',
|
|
245
|
-
id: 'candlestick',
|
|
246
|
-
gridIndex: 0,
|
|
247
|
-
xAxisIndex: 0,
|
|
248
|
-
yAxisIndex: 0,
|
|
249
|
-
data: candlesSeriesData,
|
|
250
|
-
itemStyle: {
|
|
251
|
-
color: chroma(candleShortColor).desaturate().css(),
|
|
252
|
-
color0: chroma(candleLongColor).desaturate().css(),
|
|
253
|
-
borderColor: candleShortColor,
|
|
254
|
-
borderColor0: candleLongColor,
|
|
255
|
-
},
|
|
256
|
-
emphasis: {
|
|
257
|
-
itemStyle: {
|
|
258
|
-
color: candleShortColor,
|
|
259
|
-
color0: candleLongColor,
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
markPoint: {
|
|
263
|
-
symbol: 'circle',
|
|
264
|
-
symbolSize: 0,
|
|
265
|
-
data: labelsData,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
type: 'custom',
|
|
270
|
-
gridIndex: 0,
|
|
271
|
-
name: 'heatmap',
|
|
272
|
-
id: 'heatmap',
|
|
273
|
-
xAxisIndex: 0,
|
|
274
|
-
yAxisIndex: 0,
|
|
275
|
-
silent: true,
|
|
276
|
-
clip: true,
|
|
277
|
-
renderItem: (_params, api) => {
|
|
278
|
-
const xVal = api.value(0);
|
|
279
|
-
const bucketIndex = api.value(2) as number;
|
|
280
|
-
const metaValues = buckets[bucketIndex];
|
|
281
|
-
|
|
282
|
-
const [rectWidth, rectHeight] = api.size!([
|
|
283
|
-
0,
|
|
284
|
-
bucketWidth,
|
|
285
|
-
]) as number[];
|
|
286
|
-
|
|
287
|
-
const items = metaValues.map(({ price, sentiment }: Bucket) => {
|
|
288
|
-
const start = api.coord([xVal, price]);
|
|
289
|
-
|
|
290
|
-
return {
|
|
291
|
-
type: 'rect',
|
|
292
|
-
shape: {
|
|
293
|
-
x: start[0] - rectWidth / 2,
|
|
294
|
-
y: start[1] - rectHeight,
|
|
295
|
-
width: rectWidth + 1,
|
|
296
|
-
height: rectHeight,
|
|
297
|
-
},
|
|
298
|
-
style: {
|
|
299
|
-
fill: getRectColor(sentiment, isDark),
|
|
300
|
-
},
|
|
301
|
-
silent: true,
|
|
302
|
-
emphasisDisabled: true,
|
|
303
|
-
};
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
return {
|
|
307
|
-
type: 'group',
|
|
308
|
-
children: items,
|
|
309
|
-
silent: true,
|
|
310
|
-
emphasisDisabled: true,
|
|
311
|
-
};
|
|
312
|
-
},
|
|
313
|
-
data: orderPositionBooks,
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
type: 'line',
|
|
317
|
-
name: 'sentiment-short',
|
|
318
|
-
id: 'sentiment',
|
|
319
|
-
xAxisIndex: 1,
|
|
320
|
-
yAxisIndex: 1,
|
|
321
|
-
data: sentiments,
|
|
322
|
-
showSymbol: false,
|
|
323
|
-
symbol: 'none',
|
|
324
|
-
lineStyle: {
|
|
325
|
-
width: 3,
|
|
326
|
-
opacity: 1,
|
|
327
|
-
},
|
|
328
|
-
areaStyle: {
|
|
329
|
-
color: sentimentShortColor,
|
|
330
|
-
opacity: sentimentAreaOpacity,
|
|
331
|
-
},
|
|
332
|
-
emphasis: {
|
|
333
|
-
areaStyle: {
|
|
334
|
-
opacity: 0,
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
stack: 'sentiment',
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
type: 'line',
|
|
341
|
-
name: 'sentiment-long',
|
|
342
|
-
id: 'sentiment-long',
|
|
343
|
-
xAxisIndex: 1,
|
|
344
|
-
yAxisIndex: 1,
|
|
345
|
-
data: sentiments.map((sentiment) => [sentiment[0], sentiment[2]]),
|
|
346
|
-
symbol: 'none',
|
|
347
|
-
lineStyle: {
|
|
348
|
-
color: 'transparent',
|
|
349
|
-
width: 0,
|
|
350
|
-
},
|
|
351
|
-
areaStyle: {
|
|
352
|
-
color: sentimentLongColor,
|
|
353
|
-
opacity: sentimentAreaOpacity,
|
|
354
|
-
},
|
|
355
|
-
stack: 'sentiment',
|
|
356
|
-
emphasis: {
|
|
357
|
-
disabled: true,
|
|
358
|
-
},
|
|
359
|
-
tooltip: {
|
|
360
|
-
show: false,
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
],
|
|
364
|
-
grid: [
|
|
365
|
-
{
|
|
366
|
-
name: 'main-grid',
|
|
367
|
-
id: 'main-grid',
|
|
368
|
-
height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
|
|
369
|
-
top: '0px',
|
|
370
|
-
left: '0px',
|
|
371
|
-
right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
|
|
372
|
-
bottom: `${CHART_CONFIG.X_LABEL_SIZE}px`,
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
name: 'sentiment-grid',
|
|
376
|
-
id: 'sentiment-grid',
|
|
377
|
-
height: `${CHART_CONFIG.SENTIMENT_HEIGHT}px`,
|
|
378
|
-
bottom: `0px`,
|
|
379
|
-
left: '0px',
|
|
380
|
-
right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
|
|
381
|
-
},
|
|
382
|
-
],
|
|
383
|
-
graphic: [
|
|
384
|
-
...gridMainLines,
|
|
385
|
-
{
|
|
386
|
-
type: 'text',
|
|
387
|
-
silent: true,
|
|
388
|
-
z: 1,
|
|
389
|
-
left: 4,
|
|
390
|
-
bottom: CHART_CONFIG_CALCULATED.SENTIMENT_TEXT_POSITION,
|
|
391
|
-
style: {
|
|
392
|
-
text: `${labelCallback('sentiment')}:`,
|
|
393
|
-
fontFamily: 'Sofia W03',
|
|
394
|
-
fontSize: 14,
|
|
395
|
-
fontWeight: 'bold',
|
|
396
|
-
fill: sentimentLabelColor,
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
],
|
|
400
|
-
};
|
|
401
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js';
|
|
2
|
-
|
|
3
|
-
import type { Bucket } from '../types';
|
|
4
|
-
|
|
5
|
-
export const aggregateBuckets = (
|
|
6
|
-
buckets: Bucket[],
|
|
7
|
-
newBucketWidth: number
|
|
8
|
-
): Bucket[] => {
|
|
9
|
-
if (!buckets.length) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const bucketWidthDecimal = new Decimal(newBucketWidth);
|
|
14
|
-
|
|
15
|
-
const aggregatedMap = new Map<string, Decimal>();
|
|
16
|
-
|
|
17
|
-
for (const bucket of buckets) {
|
|
18
|
-
const priceDecimal = new Decimal(bucket.price);
|
|
19
|
-
const sentimentDecimal = new Decimal(bucket.sentiment);
|
|
20
|
-
|
|
21
|
-
const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();
|
|
22
|
-
const groupingKey = bucketIndex.mul(bucketWidthDecimal);
|
|
23
|
-
|
|
24
|
-
const groupingKeyStr = groupingKey.toString();
|
|
25
|
-
|
|
26
|
-
const currentSentiment =
|
|
27
|
-
aggregatedMap.get(groupingKeyStr) ?? new Decimal(0);
|
|
28
|
-
aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(
|
|
32
|
-
([priceStr, sentimentDecimal]) => {
|
|
33
|
-
const price = new Decimal(priceStr).toNumber();
|
|
34
|
-
const sentiment = sentimentDecimal.toNumber();
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
price,
|
|
38
|
-
sentiment,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return aggregatedBuckets;
|
|
44
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import chroma from 'chroma-js';
|
|
2
|
-
|
|
3
|
-
import { BookType, Granularity, TimeSpan } from '../../../../gql/types/graphql';
|
|
4
|
-
import {
|
|
5
|
-
BOOKS_THRESHOLDS,
|
|
6
|
-
CHART_CONFIG,
|
|
7
|
-
COLOR_MAP,
|
|
8
|
-
TIME_THRESHOLDS,
|
|
9
|
-
} from '../../../constants';
|
|
10
|
-
import type { Bucket, GetLabelsDataProps, TooltipParam } from '../types';
|
|
11
|
-
|
|
12
|
-
export const getLabelData = ({
|
|
13
|
-
xAxisData,
|
|
14
|
-
isGreaterThanTwoWeeks,
|
|
15
|
-
}: GetLabelsDataProps) =>
|
|
16
|
-
xAxisData
|
|
17
|
-
.filter((record, index, arr) => {
|
|
18
|
-
if (index === 0) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const previousTimestamp = arr[index - 1];
|
|
22
|
-
const currentDate = new Date(record);
|
|
23
|
-
const previousDate = new Date(previousTimestamp);
|
|
24
|
-
|
|
25
|
-
return isGreaterThanTwoWeeks
|
|
26
|
-
? currentDate.getDate() !== previousDate.getDate()
|
|
27
|
-
: currentDate.getMonth() !== previousDate.getMonth();
|
|
28
|
-
})
|
|
29
|
-
.map((item) => ({
|
|
30
|
-
name: new Date(item).toLocaleDateString(undefined, {
|
|
31
|
-
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
32
|
-
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
33
|
-
}),
|
|
34
|
-
xAxis: item,
|
|
35
|
-
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
36
|
-
silent: true,
|
|
37
|
-
emphasis: {
|
|
38
|
-
disabled: true,
|
|
39
|
-
},
|
|
40
|
-
label: {
|
|
41
|
-
fontFamily: 'Sofia W03',
|
|
42
|
-
fontSize: 10,
|
|
43
|
-
position: 'bottom',
|
|
44
|
-
align: 'center',
|
|
45
|
-
formatter: '{b}',
|
|
46
|
-
},
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
export const isDifferenceGreaterThanTwoWeeks = (
|
|
50
|
-
startDate: string,
|
|
51
|
-
endDate: string
|
|
52
|
-
) => {
|
|
53
|
-
const date1 = new Date(startDate);
|
|
54
|
-
const date2 = new Date(endDate);
|
|
55
|
-
|
|
56
|
-
const differenceInMs = Math.abs(date2.getTime() - date1.getTime());
|
|
57
|
-
|
|
58
|
-
return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const getTimeSpanForGranularity = (
|
|
62
|
-
granularity: Granularity
|
|
63
|
-
): TimeSpan => {
|
|
64
|
-
const granularityTimeSpanMap: Record<Granularity, TimeSpan> = {
|
|
65
|
-
[Granularity.M5]: TimeSpan.TwoDays,
|
|
66
|
-
[Granularity.M15]: TimeSpan.FiveDays,
|
|
67
|
-
[Granularity.H1]: TimeSpan.TwentyDays,
|
|
68
|
-
[Granularity.H4]: TimeSpan.NinetyDays,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const getGradientColor = (
|
|
75
|
-
value: number,
|
|
76
|
-
startColor: string,
|
|
77
|
-
targetColor: string
|
|
78
|
-
): string => {
|
|
79
|
-
const startThreshold = BOOKS_THRESHOLDS.MIN;
|
|
80
|
-
const endThreshold = BOOKS_THRESHOLDS.MAX;
|
|
81
|
-
|
|
82
|
-
const colorScale = chroma
|
|
83
|
-
.scale([startColor, targetColor])
|
|
84
|
-
.domain([startThreshold, endThreshold])
|
|
85
|
-
.mode('rgb');
|
|
86
|
-
|
|
87
|
-
return colorScale(value).hex();
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const getRectColor = (sentiment: number, isDark: boolean) => {
|
|
91
|
-
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
92
|
-
|
|
93
|
-
return sentiment < 0
|
|
94
|
-
? getGradientColor(
|
|
95
|
-
sentiment * -1,
|
|
96
|
-
colorPalette.short[0],
|
|
97
|
-
colorPalette.short[1]
|
|
98
|
-
)
|
|
99
|
-
: getGradientColor(sentiment, colorPalette.long[0], colorPalette.long[1]);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export const getTooltipFormatter = ({
|
|
103
|
-
params,
|
|
104
|
-
buckets,
|
|
105
|
-
bucketWidth,
|
|
106
|
-
selectedPrice,
|
|
107
|
-
precision,
|
|
108
|
-
bookType,
|
|
109
|
-
labelCallback,
|
|
110
|
-
}: {
|
|
111
|
-
params: TooltipParam[];
|
|
112
|
-
buckets: Bucket[][];
|
|
113
|
-
bucketWidth: number;
|
|
114
|
-
selectedPrice: number;
|
|
115
|
-
precision: number;
|
|
116
|
-
bookType: BookType;
|
|
117
|
-
labelCallback: (key: string) => string;
|
|
118
|
-
}) => {
|
|
119
|
-
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
const candleParam = params.find(
|
|
123
|
-
(series): series is Extract<TooltipParam, { seriesId: 'candlestick' }> =>
|
|
124
|
-
series.seriesId === 'candlestick'
|
|
125
|
-
);
|
|
126
|
-
const booksParam = params.find(
|
|
127
|
-
(series): series is Extract<TooltipParam, { seriesId: 'heatmap' }> =>
|
|
128
|
-
series.seriesId === 'heatmap'
|
|
129
|
-
);
|
|
130
|
-
const sentimentParam = params.find(
|
|
131
|
-
(series): series is Extract<TooltipParam, { seriesId: 'sentiment' }> =>
|
|
132
|
-
series.seriesId === 'sentiment'
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
if (!candleParam) {
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|
|
138
|
-
const time = new Date(candleParam.axisValue as string);
|
|
139
|
-
|
|
140
|
-
const candleData = candleParam.value;
|
|
141
|
-
const bucketsIndex = booksParam?.value[2];
|
|
142
|
-
const selectedBuckets =
|
|
143
|
-
bucketsIndex !== undefined ? buckets[bucketsIndex] : undefined;
|
|
144
|
-
|
|
145
|
-
const matchedBucket = selectedBuckets?.find(
|
|
146
|
-
({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth
|
|
147
|
-
);
|
|
148
|
-
const showCandles =
|
|
149
|
-
!!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];
|
|
150
|
-
|
|
151
|
-
if (!showCandles && !matchedBucket) {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const showSentiment =
|
|
156
|
-
!!sentimentParam?.value[1] && !!sentimentParam?.value[2];
|
|
157
|
-
|
|
158
|
-
return `<p>${time.toLocaleString(undefined, {
|
|
159
|
-
hour: '2-digit',
|
|
160
|
-
minute: '2-digit',
|
|
161
|
-
year: 'numeric',
|
|
162
|
-
day: 'numeric',
|
|
163
|
-
month: 'numeric',
|
|
164
|
-
timeZoneName: 'short',
|
|
165
|
-
})}</p><br />
|
|
166
|
-
${
|
|
167
|
-
showCandles
|
|
168
|
-
? `<p><b>${labelCallback('candle')}:</b></p>
|
|
169
|
-
<p>${labelCallback('open_price')}: ${candleData[1]} </p>
|
|
170
|
-
<p>${labelCallback('close_price')}: ${candleData[2]} </p>
|
|
171
|
-
<p>${labelCallback('low')}: ${candleData[3]} </p>
|
|
172
|
-
<p>${labelCallback('high')}: ${candleData[4]} </p>
|
|
173
|
-
`
|
|
174
|
-
: ''
|
|
175
|
-
}
|
|
176
|
-
${
|
|
177
|
-
matchedBucket
|
|
178
|
-
? `<br /><p><b>${labelCallback(bookType === BookType.Order ? 'orders' : 'positions')}:</b></p>
|
|
179
|
-
<p>${labelCallback('price_range')}: ${matchedBucket.price.toFixed(precision - 1)} - ${Number(matchedBucket.price + bucketWidth).toFixed(precision - 1)} </p>
|
|
180
|
-
<p>${
|
|
181
|
-
matchedBucket.sentiment < 0
|
|
182
|
-
? labelCallback(
|
|
183
|
-
bookType === BookType.Order
|
|
184
|
-
? 'sell_overbalance'
|
|
185
|
-
: 'short_overbalance'
|
|
186
|
-
)
|
|
187
|
-
: labelCallback(
|
|
188
|
-
bookType === BookType.Order
|
|
189
|
-
? 'buy_overbalance'
|
|
190
|
-
: 'long_overbalance'
|
|
191
|
-
)
|
|
192
|
-
}: ${Math.abs(matchedBucket.sentiment)}% </p>`
|
|
193
|
-
: ''
|
|
194
|
-
}${
|
|
195
|
-
showSentiment && sentimentParam
|
|
196
|
-
? `<br /><p><b>${labelCallback('sentiment')}:</b></p>
|
|
197
|
-
<p>${labelCallback('long')}: ${sentimentParam.value[2].toFixed(2)}% </p>
|
|
198
|
-
<p>${labelCallback('short')}: ${sentimentParam.value[1].toFixed(2)}% </p>`
|
|
199
|
-
: ''
|
|
200
|
-
}`;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export const formatXAxisLabel = (
|
|
204
|
-
value: unknown,
|
|
205
|
-
isGreaterThanTwoWeeks: boolean
|
|
206
|
-
) => {
|
|
207
|
-
const date = new Date(value as string);
|
|
208
|
-
return isGreaterThanTwoWeeks
|
|
209
|
-
? `${date.toLocaleTimeString(undefined, {
|
|
210
|
-
hour: '2-digit',
|
|
211
|
-
minute: '2-digit',
|
|
212
|
-
})}`
|
|
213
|
-
: `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(undefined, {
|
|
214
|
-
day: 'numeric',
|
|
215
|
-
})}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;
|
|
216
|
-
};
|