@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,68 @@
|
|
|
1
|
+
import { BUCKET_CONFIG, CHART_CONFIG } from '../../../constants';
|
|
2
|
+
export const getYAxisConfig = _ref => {
|
|
3
|
+
let {
|
|
4
|
+
bucketWidth,
|
|
5
|
+
displayPrecision,
|
|
6
|
+
isDesktop,
|
|
7
|
+
labelCallback
|
|
8
|
+
} = _ref;
|
|
9
|
+
return [{
|
|
10
|
+
type: 'value',
|
|
11
|
+
gridIndex: 0,
|
|
12
|
+
position: 'right',
|
|
13
|
+
min: val => val.min - bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
14
|
+
max: val => val.max + bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
15
|
+
axisLine: {
|
|
16
|
+
show: false
|
|
17
|
+
},
|
|
18
|
+
axisTick: {
|
|
19
|
+
show: false
|
|
20
|
+
},
|
|
21
|
+
axisLabel: {
|
|
22
|
+
showMinLabel: false,
|
|
23
|
+
showMaxLabel: false,
|
|
24
|
+
formatter: value => value.toFixed(displayPrecision - 1)
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
type: 'value',
|
|
28
|
+
gridIndex: 1,
|
|
29
|
+
position: 'left',
|
|
30
|
+
min: CHART_CONFIG.SENTIMENT_MIN,
|
|
31
|
+
max: CHART_CONFIG.SENTIMENT_MAX,
|
|
32
|
+
axisLine: {
|
|
33
|
+
show: false
|
|
34
|
+
},
|
|
35
|
+
axisTick: {
|
|
36
|
+
show: false
|
|
37
|
+
},
|
|
38
|
+
axisPointer: {
|
|
39
|
+
show: false
|
|
40
|
+
},
|
|
41
|
+
axisLabel: {
|
|
42
|
+
margin: isDesktop ? 4 : 2,
|
|
43
|
+
lineHeight: 20,
|
|
44
|
+
verticalAlignMinLabel: 'bottom',
|
|
45
|
+
verticalAlignMaxLabel: 'top',
|
|
46
|
+
customValues: [CHART_CONFIG.SENTIMENT_MIN, CHART_CONFIG.SENTIMENT_MAX / 5, CHART_CONFIG.SENTIMENT_MAX / 2, CHART_CONFIG.SENTIMENT_MAX * 4 / 5, CHART_CONFIG.SENTIMENT_MAX],
|
|
47
|
+
formatter: value => {
|
|
48
|
+
if (value === CHART_CONFIG.SENTIMENT_MIN) {
|
|
49
|
+
return "".concat(labelCallback('short'));
|
|
50
|
+
}
|
|
51
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX) {
|
|
52
|
+
return "".concat(labelCallback('long'));
|
|
53
|
+
}
|
|
54
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
|
|
55
|
+
return '50%';
|
|
56
|
+
}
|
|
57
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {
|
|
58
|
+
return '80%';
|
|
59
|
+
}
|
|
60
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX * 4 / 5) {
|
|
61
|
+
return '20%';
|
|
62
|
+
}
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}];
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=getYAxisConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getYAxisConfig.js","names":["BUCKET_CONFIG","CHART_CONFIG","getYAxisConfig","_ref","bucketWidth","displayPrecision","isDesktop","labelCallback","type","gridIndex","position","min","val","PRICE_MARGIN_MULTIPLIER","max","axisLine","show","axisTick","axisLabel","showMinLabel","showMaxLabel","formatter","value","toFixed","SENTIMENT_MIN","SENTIMENT_MAX","axisPointer","margin","lineHeight","verticalAlignMinLabel","verticalAlignMaxLabel","customValues","concat"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts"],"sourcesContent":["import type { YAXisComponentOption } from 'echarts';\n\nimport { BUCKET_CONFIG, CHART_CONFIG } from '../../../constants';\n\ninterface GetYAxisConfigParams {\n bucketWidth: number;\n displayPrecision: number;\n isDesktop: boolean;\n labelCallback: (key: string, params?: Record<string, unknown>) => string;\n}\n\nexport const getYAxisConfig = ({\n bucketWidth,\n displayPrecision,\n isDesktop,\n labelCallback,\n}: GetYAxisConfigParams): YAXisComponentOption[] => [\n {\n type: 'value',\n gridIndex: 0,\n position: 'right',\n min: (val: { min: number }) =>\n val.min - bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,\n max: (val: { max: number }) =>\n val.max + bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n showMinLabel: false,\n showMaxLabel: false,\n formatter: (value: number) => value.toFixed(displayPrecision - 1),\n },\n },\n {\n type: 'value',\n gridIndex: 1,\n position: 'left',\n min: CHART_CONFIG.SENTIMENT_MIN,\n max: CHART_CONFIG.SENTIMENT_MAX,\n axisLine: { show: false },\n axisTick: { show: false },\n axisPointer: {\n show: false,\n },\n axisLabel: {\n margin: isDesktop ? 4 : 2,\n lineHeight: 20,\n verticalAlignMinLabel: 'bottom',\n verticalAlignMaxLabel: 'top',\n customValues: [\n CHART_CONFIG.SENTIMENT_MIN,\n CHART_CONFIG.SENTIMENT_MAX / 5,\n CHART_CONFIG.SENTIMENT_MAX / 2,\n (CHART_CONFIG.SENTIMENT_MAX * 4) / 5,\n CHART_CONFIG.SENTIMENT_MAX,\n ],\n formatter: (value: number) => {\n if (value === CHART_CONFIG.SENTIMENT_MIN) {\n return `${labelCallback('short')}`;\n }\n if (value === CHART_CONFIG.SENTIMENT_MAX) {\n return `${labelCallback('long')}`;\n }\n if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {\n return '50%';\n }\n if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {\n return '80%';\n }\n if (value === (CHART_CONFIG.SENTIMENT_MAX * 4) / 5) {\n return '20%';\n }\n return '';\n },\n },\n },\n];\n"],"mappings":"AAEA,SAASA,aAAa,EAAEC,YAAY,QAAQ,oBAAoB;AAShE,OAAO,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAC7BC,WAAW;IACXC,gBAAgB;IAChBC,SAAS;IACTC;EACoB,CAAC,GAAAJ,IAAA;EAAA,OAA6B,CAClD;IACEK,IAAI,EAAE,OAAO;IACbC,SAAS,EAAE,CAAC;IACZC,QAAQ,EAAE,OAAO;IACjBC,GAAG,EAAGC,GAAoB,IACxBA,GAAG,CAACD,GAAG,GAAGP,WAAW,GAAGJ,aAAa,CAACa,uBAAuB;IAC/DC,GAAG,EAAGF,GAAoB,IACxBA,GAAG,CAACE,GAAG,GAAGV,WAAW,GAAGJ,aAAa,CAACa,uBAAuB;IAC/DE,QAAQ,EAAE;MAAEC,I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AE;UAC5C,OAAO,KAAK;QACd;QACA,IAAIH,KAAK,KAAKrB,YAAY,CAACwB,aAAa,GAAG,CAAC,EAAE;UAC5C,OAAO,KAAK;QACd;QACA,IAAIH,KAAK,KAAMrB,YAAY,CAACwB,aAAa,GAAG,CAAC,GAAI,CAAC,EAAE;UAClD,OAAO,KAAK;QACd;QACA,OAAO,EAAE;MACX;IACF;EACF,CAAC,CACF;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './getDataZoomConfig';
|
|
2
|
+
export * from './getGridConfig';
|
|
3
|
+
export * from './getGridLines';
|
|
4
|
+
export * from './getSeriesCandlestickConfig';
|
|
5
|
+
export * from './getSeriesHeatmapConfig';
|
|
6
|
+
export * from './getSeriesSentimentConfig';
|
|
7
|
+
export * from './getTooltipConfig';
|
|
8
|
+
export * from './getVisualMapConfig';
|
|
9
|
+
export * from './getXAxisConfig';
|
|
10
|
+
export * from './getYAxisConfig';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/index.ts"],"sourcesContent":["export * from './getDataZoomConfig';\nexport * from './getGridConfig';\nexport * from './getGridLines';\nexport * from './getSeriesCandlestickConfig';\nexport * from './getSeriesHeatmapConfig';\nexport * from './getSeriesSentimentConfig';\nexport * from './getTooltipConfig';\nexport * from './getVisualMapConfig';\nexport * from './getXAxisConfig';\nexport * from './getYAxisConfig';\n"],"mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,8BAA8B;AAC5C,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
+
export const formatXAxisLabel = (value, isGreaterThanTwoWeeks) => {
|
|
3
|
+
const date = new Date(value);
|
|
4
|
+
return isGreaterThanTwoWeeks ? "".concat(date.toLocaleTimeString(undefined, {
|
|
5
|
+
hour: '2-digit',
|
|
6
|
+
minute: '2-digit'
|
|
7
|
+
})) : "".concat(CHART_CONFIG.X_AXIS_DATE_PADDING).concat(date.toLocaleDateString(undefined, {
|
|
8
|
+
day: 'numeric'
|
|
9
|
+
})).concat(CHART_CONFIG.X_AXIS_DATE_PADDING);
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=formatXAxisLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatXAxisLabel.js","names":["CHART_CONFIG","formatXAxisLabel","value","isGreaterThanTwoWeeks","date","Date","concat","toLocaleTimeString","undefined","hour","minute","X_AXIS_DATE_PADDING","toLocaleDateString","day"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts"],"sourcesContent":["import { CHART_CONFIG } from '../../../constants';\n\nexport const formatXAxisLabel = (\n value: unknown,\n isGreaterThanTwoWeeks: boolean\n) => {\n const date = new Date(value as string);\n return isGreaterThanTwoWeeks\n ? `${date.toLocaleTimeString(undefined, {\n hour: '2-digit',\n minute: '2-digit',\n })}`\n : `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(undefined, {\n day: 'numeric',\n })}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AAEjD,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,KAAc,EACdC,qBAA8B,KAC3B;EACH,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACH,KAAe,CAAC;EACtC,OAAOC,qBAAqB,MAAAG,MAAA,CACrBF,IAAI,CAACG,kBAAkB,CAACC,SAAS,EAAE;IACpCC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC,CAAC,OAAAJ,MAAA,CACCN,YAAY,CAACW,mBAAmB,EAAAL,MAAA,CAAGF,IAAI,CAACQ,kBAAkB,CAACJ,SAAS,EAAE;IACvEK,GAAG,EAAE;EACP,CAAC,CAAC,EAAAP,MAAA,CAAGN,YAAY,CAACW,mBAAmB,CAAE;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -2,19 +2,19 @@ import { colorPalette } from '@oanda/labs-widget-common';
|
|
|
2
2
|
export const getChartStyles = isDark => {
|
|
3
3
|
const sentimentLongColor = isDark ? colorPalette.darkBlue90 : colorPalette.lightBlue90;
|
|
4
4
|
const sentimentShortColor = isDark ? colorPalette.darkYellow90 : colorPalette.lightYellow90;
|
|
5
|
+
const sentimentOutlineColor = isDark ? colorPalette.black : colorPalette.white;
|
|
6
|
+
const sentimentOutlineWidth = isDark ? 3 : 2;
|
|
5
7
|
const candleLongColor = isDark ? colorPalette.bottleGreenDark : colorPalette.bottleGreenLight;
|
|
6
8
|
const candleShortColor = isDark ? colorPalette.orange : colorPalette.raspberryLight;
|
|
7
|
-
const sentimentAreaOpacity = isDark ? 0.5 : 0.2;
|
|
8
9
|
const tooltipLinesColor = isDark ? colorPalette.orange : colorPalette.bottleGreenLight;
|
|
9
|
-
const sentimentLabelColor = isDark ? colorPalette.white : colorPalette.black;
|
|
10
10
|
return {
|
|
11
11
|
sentimentLongColor,
|
|
12
12
|
sentimentShortColor,
|
|
13
|
+
sentimentOutlineColor,
|
|
13
14
|
candleLongColor,
|
|
14
15
|
candleShortColor,
|
|
15
|
-
sentimentAreaOpacity,
|
|
16
16
|
tooltipLinesColor,
|
|
17
|
-
|
|
17
|
+
sentimentOutlineWidth
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=getChartStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChartStyles.js","names":["colorPalette","getChartStyles","isDark","sentimentLongColor","darkBlue90","lightBlue90","sentimentShortColor","darkYellow90","lightYellow90","sentimentOutlineColor","black","white","sentimentOutlineWidth","candleLongColor","bottleGreenDark","bottleGreenLight","candleShortColor","orange","raspberryLight","tooltipLinesColor"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nexport interface ChartStyles {\n sentimentLongColor: string;\n sentimentShortColor: string;\n sentimentOutlineColor: string;\n candleLongColor: string;\n candleShortColor: string;\n tooltipLinesColor: string;\n sentimentOutlineWidth: number;\n}\n\nexport const getChartStyles = (isDark: boolean): ChartStyles => {\n const sentimentLongColor = isDark\n ? colorPalette.darkBlue90\n : colorPalette.lightBlue90;\n const sentimentShortColor = isDark\n ? colorPalette.darkYellow90\n : colorPalette.lightYellow90;\n\n const sentimentOutlineColor = isDark\n ? colorPalette.black\n : colorPalette.white;\n const sentimentOutlineWidth = isDark ? 3 : 2;\n\n const candleLongColor = isDark\n ? colorPalette.bottleGreenDark\n : colorPalette.bottleGreenLight;\n const candleShortColor = isDark\n ? colorPalette.orange\n : colorPalette.raspberryLight;\n const tooltipLinesColor = isDark\n ? colorPalette.orange\n : colorPalette.bottleGreenLight;\n\n return {\n sentimentLongColor,\n sentimentShortColor,\n sentimentOutlineColor,\n candleLongColor,\n candleShortColor,\n tooltipLinesColor,\n sentimentOutlineWidth,\n };\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAYxD,OAAO,MAAMC,cAAc,GAAIC,MAAe,IAAkB;EAC9D,MAAMC,kBAAkB,GAAGD,MAAM,GAC7BF,YAAY,CAACI,UAAU,GACvBJ,YAAY,CAACK,WAAW;EAC5B,MAAMC,mBAAmB,GAAGJ,MAAM,GAC9BF,YAAY,CAACO,YAAY,GACzBP,YAAY,CAACQ,aAAa;EAE9B,MAAMC,qBAAqB,GAAGP,MAAM,GAChCF,YAAY,CAACU,KAAK,GAClBV,YAAY,CAACW,KAAK;EACtB,MAAMC,qBAAqB,GAAGV,MAAM,GAAG,CAAC,GAAG,CAAC;EAE5C,MAAMW,eAAe,GAAGX,MAAM,GAC1BF,YAAY,CAACc,eAAe,GAC5Bd,YAAY,CAACe,gBAAgB;EACjC,MAAMC,gBAAgB,GAAGd,MAAM,GAC3BF,YAAY,CAACiB,MAAM,GACnBjB,YAAY,CAACkB,cAAc;EAC/B,MAAMC,iBAAiB,GAAGjB,MAAM,GAC5BF,YAAY,CAACiB,MAAM,GACnBjB,YAAY,CAACe,gBAAgB;EAEjC,OAAO;IACLZ,kBAAkB;IAClBG,mBAAmB;IACnBG,qBAAqB;IACrBI,eAAe;IACfG,gBAAgB;IAChBG,iBAAiB;IACjBP;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import chroma from 'chroma-js';
|
|
2
|
+
export const getGradientColor = (value, startColor, targetColor, minThreshold, maxThreshold) => {
|
|
3
|
+
const colorScale = chroma.scale([startColor, targetColor]).domain([minThreshold, maxThreshold]).mode('rgb');
|
|
4
|
+
return colorScale(value).hex();
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=getGradientColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGradientColor.js","names":["chroma","getGradientColor","value","startColor","targetColor","minThreshold","maxThreshold","colorScale","scale","domain","mode","hex"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts"],"sourcesContent":["import chroma from 'chroma-js';\n\nexport const getGradientColor = (\n value: number,\n startColor: string,\n targetColor: string,\n minThreshold: number,\n maxThreshold: number\n): string => {\n const colorScale = chroma\n .scale([startColor, targetColor])\n .domain([minThreshold, maxThreshold])\n .mode('rgb');\n\n return colorScale(value).hex();\n};\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,WAAW;AAE9B,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,KAAa,EACbC,UAAkB,EAClBC,WAAmB,EACnBC,YAAoB,EACpBC,YAAoB,KACT;EACX,MAAMC,UAAU,GAAGP,MAAM,CACtBQ,KAAK,CAAC,CAACL,UAAU,EAAEC,WAAW,CAAC,CAAC,CAChCK,MAAM,CAAC,CAACJ,YAAY,EAAEC,YAAY,CAAC,CAAC,CACpCI,IAAI,CAAC,KAAK,CAAC;EAEd,OAAOH,UAAU,CAACL,KAAK,CAAC,CAACS,GAAG,CAAC,CAAC;AAChC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
+
export const getLabelData = _ref => {
|
|
3
|
+
let {
|
|
4
|
+
dates,
|
|
5
|
+
isGreaterThanTwoWeeks
|
|
6
|
+
} = _ref;
|
|
7
|
+
return dates.filter((record, index, arr) => {
|
|
8
|
+
if (index === 0) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const previousTimestamp = arr[index - 1];
|
|
12
|
+
const currentDate = new Date(record);
|
|
13
|
+
const previousDate = new Date(previousTimestamp);
|
|
14
|
+
return isGreaterThanTwoWeeks ? currentDate.getDate() !== previousDate.getDate() : currentDate.getMonth() !== previousDate.getMonth();
|
|
15
|
+
}).map(item => ({
|
|
16
|
+
name: new Date(item).toLocaleDateString(undefined, {
|
|
17
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
18
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined
|
|
19
|
+
}),
|
|
20
|
+
xAxis: item,
|
|
21
|
+
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
22
|
+
silent: true,
|
|
23
|
+
emphasis: {
|
|
24
|
+
disabled: true
|
|
25
|
+
},
|
|
26
|
+
label: {
|
|
27
|
+
fontFamily: 'Sofia W03',
|
|
28
|
+
fontSize: 10,
|
|
29
|
+
position: 'bottom',
|
|
30
|
+
align: 'center',
|
|
31
|
+
formatter: '{b}'
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=getLabelData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLabelData.js","names":["CHART_CONFIG","getLabelData","_ref","dates","isGreaterThanTwoWeeks","filter","record","index","arr","previousTimestamp","currentDate","Date","previousDate","getDate","getMonth","map","item","name","toLocaleDateString","undefined","month","day","xAxis","y","MAIN_HEIGHT","X_LABEL_SIZE","silent","emphasis","disabled","label","fontFamily","fontSize","position","align","formatter"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts"],"sourcesContent":["import { CHART_CONFIG } from '../../../constants';\nimport type { GetLabelsDataProps } from '../types';\n\nexport const getLabelData = ({\n dates,\n isGreaterThanTwoWeeks,\n}: GetLabelsDataProps) =>\n dates\n .filter((record, index, arr) => {\n if (index === 0) {\n return false;\n }\n const previousTimestamp = arr[index - 1];\n const currentDate = new Date(record);\n const previousDate = new Date(previousTimestamp);\n\n return isGreaterThanTwoWeeks\n ? currentDate.getDate() !== previousDate.getDate()\n : currentDate.getMonth() !== previousDate.getMonth();\n })\n .map(\n (item) =>\n ({\n name: new Date(item).toLocaleDateString(undefined, {\n month: isGreaterThanTwoWeeks ? 'short' : 'long',\n day: isGreaterThanTwoWeeks ? 'numeric' : undefined,\n }),\n xAxis: item,\n y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,\n silent: true,\n emphasis: {\n disabled: true,\n },\n label: {\n fontFamily: 'Sofia W03',\n fontSize: 10,\n position: 'bottom' as const,\n align: 'center' as const,\n formatter: '{b}',\n },\n }) as const\n );\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AAGjD,OAAO,MAAMC,YAAY,GAAGC,IAAA;EAAA,IAAC;IAC3BC,KAAK;IACLC;EACkB,CAAC,GAAAF,IAAA;EAAA,OACnBC,KAAK,CACFE,MAAM,CAAC,CAACC,MAAM,EAAEC,KAAK,EAAEC,GAAG,KAAK;IAC9B,IAAID,KAAK,KAAK,CAAC,EAAE;MACf,OAAO,KAAK;IACd;IACA,MAAME,iBAAiB,GAAGD,GAAG,CAACD,KAAK,GAAG,CAAC,CAAC;IACxC,MAAMG,WAAW,GAAG,IAAIC,IAAI,CAACL,MAAM,CAAC;IACpC,MAAMM,YAAY,GAAG,IAAID,IAAI,CAACF,iBAAiB,CAAC;IAEhD,OAAOL,qBAAqB,GACxBM,WAAW,CAACG,OAAO,CAAC,CAAC,KAAKD,YAAY,CAACC,OAAO,CAAC,CAAC,GAChDH,WAAW,CAACI,QAAQ,CAAC,CAAC,KAAKF,YAAY,CAACE,QAAQ,CAAC,CAAC;EACxD,CAAC,CAAC,CACDC,GAAG,CACDC,IAAI,KACF;IACCC,IAAI,EAAE,IAAIN,IAAI,CAACK,IAAI,CAAC,CAACE,kBAAkB,CAACC,SAAS,EAAE;MACjDC,KAAK,EAAEhB,qBAAqB,GAAG,OAAO,GAAG,MAAM;MAC/CiB,GAAG,EAAEjB,qBAAqB,GAAG,SAAS,GAAGe;IAC3C,CAAC,CAAC;IACFG,KAAK,EAAEN,IAAI;IACXO,CAAC,EAAEvB,YAAY,CAACwB,WAAW,GAAGxB,YAAY,CAACyB,YAAY,GAAG,EAAE;IAC5DC,MAAM,EAAE,IAAI;IACZC,QAAQ,EAAE;MACRC,QAAQ,EAAE;IACZ,CAAC;IACDC,KAAK,EAAE;MACLC,UAAU,EAAE,WAAW;MACvBC,QAAQ,EAAE,EAAE;MACZC,QAAQ,EAAE,QAAiB;MAC3BC,KAAK,EAAE,QAAiB;MACxBC,SAAS,EAAE;IACb;EACF,CAAC,CACL,CAAC;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { COLOR_MAP } from '../../../constants';
|
|
2
|
+
import { getGradientColor } from './getGradientColor';
|
|
3
|
+
export const getRectColor = (sentiment, isDark, minThreshold, maxThreshold) => {
|
|
4
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
5
|
+
return sentiment < 0 ? getGradientColor(sentiment * -1, colorPalette.short[0], colorPalette.short[1], minThreshold, maxThreshold) : getGradientColor(sentiment, colorPalette.long[0], colorPalette.long[1], minThreshold, maxThreshold);
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=getRectColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRectColor.js","names":["COLOR_MAP","getGradientColor","getRectColor","sentiment","isDark","minThreshold","maxThreshold","colorPalette","dark","light","short","long"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts"],"sourcesContent":["import { COLOR_MAP } from '../../../constants';\nimport { getGradientColor } from './getGradientColor';\n\nexport const getRectColor = (\n sentiment: number,\n isDark: boolean,\n minThreshold: number,\n maxThreshold: number\n) => {\n const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;\n\n return sentiment < 0\n ? getGradientColor(\n sentiment * -1,\n colorPalette.short[0],\n colorPalette.short[1],\n minThreshold,\n maxThreshold\n )\n : getGradientColor(\n sentiment,\n colorPalette.long[0],\n colorPalette.long[1],\n minThreshold,\n maxThreshold\n );\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,SAAiB,EACjBC,MAAe,EACfC,YAAoB,EACpBC,YAAoB,KACjB;EACH,MAAMC,YAAY,GAAGH,MAAM,GAAGJ,SAAS,CAACQ,IAAI,GAAGR,SAAS,CAACS,KAAK;EAE9D,OAAON,SAAS,GAAG,CAAC,GAChBF,gBAAgB,CACdE,SAAS,GAAG,CAAC,CAAC,EACdI,YAAY,CAACG,KAAK,CAAC,CAAC,CAAC,EACrBH,YAAY,CAACG,KAAK,CAAC,CAAC,CAAC,EACrBL,YAAY,EACZC,YACF,CAAC,GACDL,gBAAgB,CACdE,SAAS,EACTI,YAAY,CAACI,IAAI,CAAC,CAAC,CAAC,EACpBJ,YAAY,CAACI,IAAI,CAAC,CAAC,CAAC,EACpBN,YAAY,EACZC,YACF,CAAC;AACP,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BookType } from '../../../../gql/types/graphql';
|
|
2
|
+
const DATE_FORMAT_OPTIONS = {
|
|
3
|
+
hour: '2-digit',
|
|
4
|
+
minute: '2-digit',
|
|
5
|
+
year: 'numeric',
|
|
6
|
+
day: 'numeric',
|
|
7
|
+
month: 'numeric',
|
|
8
|
+
timeZoneName: 'short'
|
|
9
|
+
};
|
|
10
|
+
const SENTIMENT_DISPLAY_PRECISION = 2;
|
|
11
|
+
const calculateBucketDisplayPrecision = bucketWidth => {
|
|
12
|
+
var _bucketWidth$toString;
|
|
13
|
+
return ((_bucketWidth$toString = bucketWidth.toString().split('.')[1]) === null || _bucketWidth$toString === void 0 ? void 0 : _bucketWidth$toString.length) || 0;
|
|
14
|
+
};
|
|
15
|
+
const findSeriesParam = (params, seriesId) => {
|
|
16
|
+
return params.find(series => series.seriesId === seriesId);
|
|
17
|
+
};
|
|
18
|
+
const getSentimentOverbalanceLabel = (sentiment, bookType) => {
|
|
19
|
+
if (sentiment < 0) {
|
|
20
|
+
return bookType === BookType.Order ? 'sell_overbalance' : 'short_overbalance';
|
|
21
|
+
}
|
|
22
|
+
return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';
|
|
23
|
+
};
|
|
24
|
+
const formatCandleData = (candleData, labelCallback) => {
|
|
25
|
+
const [, open, close, low, high] = candleData;
|
|
26
|
+
return "<p><b>".concat(labelCallback('candle'), ":</b></p>\n<p>").concat(labelCallback('open_price'), ": ").concat(open, " </p>\n<p>").concat(labelCallback('close_price'), ": ").concat(close, " </p>\n<p>").concat(labelCallback('low'), ": ").concat(low, " </p>\n<p>").concat(labelCallback('high'), ": ").concat(high, " </p>\n");
|
|
27
|
+
};
|
|
28
|
+
const formatBookData = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
matchedBucket,
|
|
31
|
+
bucketWidth,
|
|
32
|
+
bucketDisplayPrecision,
|
|
33
|
+
bookType,
|
|
34
|
+
labelCallback
|
|
35
|
+
} = _ref;
|
|
36
|
+
const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';
|
|
37
|
+
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
38
|
+
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(bucketDisplayPrecision);
|
|
39
|
+
const sentimentLabel = getSentimentOverbalanceLabel(matchedBucket.sentiment, bookType);
|
|
40
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(bucketDisplayPrecision);
|
|
41
|
+
return "<br /><p><b>".concat(labelCallback(bookLabelKey), ":</b></p>\n<p>").concat(labelCallback('price_range'), ": ").concat(priceRangeStart, " - ").concat(priceRangeEnd, " </p>\n<p>").concat(labelCallback(sentimentLabel), ": ").concat(sentimentValue, "% </p>");
|
|
42
|
+
};
|
|
43
|
+
const formatSentimentData = (sentimentParam, labelCallback) => {
|
|
44
|
+
const [, shortPercent, longPercent] = sentimentParam.value;
|
|
45
|
+
return "<br /><p><b>".concat(labelCallback('sentiment'), ":</b></p>\n<p>").concat(labelCallback('long'), ": ").concat(longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </p>\n<p>").concat(labelCallback('short'), ": ").concat(shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </p>");
|
|
46
|
+
};
|
|
47
|
+
const hasValidCandleData = candleData => !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[3];
|
|
48
|
+
const hasValidSentimentData = sentimentParam => !!(sentimentParam !== null && sentimentParam !== void 0 && sentimentParam.value[1]) && !!(sentimentParam !== null && sentimentParam !== void 0 && sentimentParam.value[2]);
|
|
49
|
+
const findMatchingBucket = (buckets, bucketsIndex, selectedPrice, bucketWidth) => {
|
|
50
|
+
if (bucketsIndex === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const selectedBuckets = buckets[bucketsIndex];
|
|
54
|
+
return selectedBuckets === null || selectedBuckets === void 0 ? void 0 : selectedBuckets.find(_ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
price
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return selectedPrice >= price && selectedPrice < price + bucketWidth;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export const getTooltipFormatter = _ref3 => {
|
|
62
|
+
let {
|
|
63
|
+
params,
|
|
64
|
+
buckets,
|
|
65
|
+
bucketWidth,
|
|
66
|
+
selectedPrice,
|
|
67
|
+
bookType,
|
|
68
|
+
labelCallback
|
|
69
|
+
} = _ref3;
|
|
70
|
+
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
const candleParam = findSeriesParam(params, 'candlestick');
|
|
74
|
+
const booksParam = findSeriesParam(params, 'heatmap');
|
|
75
|
+
const sentimentParam = findSeriesParam(params, 'sentiment');
|
|
76
|
+
if (!candleParam) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);
|
|
80
|
+
const time = new Date(candleParam.axisValue);
|
|
81
|
+
const candleData = candleParam.value;
|
|
82
|
+
const bucketsIndex = booksParam === null || booksParam === void 0 ? void 0 : booksParam.value[2];
|
|
83
|
+
const matchedBucket = findMatchingBucket(buckets, bucketsIndex, selectedPrice, bucketWidth);
|
|
84
|
+
const showCandles = hasValidCandleData(candleData);
|
|
85
|
+
const showSentiment = hasValidSentimentData(sentimentParam);
|
|
86
|
+
if (!showCandles && !matchedBucket) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);
|
|
90
|
+
const candleSection = showCandles ? formatCandleData(candleData, labelCallback) : '';
|
|
91
|
+
const bookSection = matchedBucket ? formatBookData({
|
|
92
|
+
matchedBucket,
|
|
93
|
+
bucketWidth,
|
|
94
|
+
bucketDisplayPrecision,
|
|
95
|
+
bookType,
|
|
96
|
+
labelCallback
|
|
97
|
+
}) : '';
|
|
98
|
+
const sentimentSection = showSentiment && sentimentParam ? formatSentimentData(sentimentParam, labelCallback) : '';
|
|
99
|
+
return "<p>".concat(timeFormatted, "</p><br />\n").concat(candleSection, "\n").concat(bookSection, "\n").concat(sentimentSection);
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=getTooltipFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTooltipFormatter.js","names":["BookType","DATE_FORMAT_OPTIONS","hour","minute","year","day","month","timeZoneName","SENTIMENT_DISPLAY_PRECISION","calculateBucketDisplayPrecision","bucketWidth","_bucketWidth$toString","toString","split","length","findSeriesParam","params","seriesId","find","series","getSentimentOverbalanceLabel","sentiment","bookType","Order","formatCandleData","candleData","labelCallback","open","close","low","high","concat","formatBookData","_ref","matchedBucket","bucketDisplayPrecision","bookLabelKey","priceRangeStart","price","toFixed","priceRangeEnd","sentimentLabel","sentimentValue","Math","abs","formatSentimentData","sentimentParam","shortPercent","longPercent","value","hasValidCandleData","hasValidSentimentData","findMatchingBucket","buckets","bucketsIndex","selectedPrice","undefined","selectedBuckets","_ref2","getTooltipFormatter","_ref3","Array","isArray","candleParam","booksParam","time","Date","axisValue","showCandles","showSentiment","timeFormatted","toLocaleString","candleSection","bookSection","sentimentSection"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts"],"sourcesContent":["import { BookType } from '../../../../gql/types/graphql';\nimport type { Bucket, TooltipParam } from '../types';\n\nconst DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n year: 'numeric',\n day: 'numeric',\n month: 'numeric',\n timeZoneName: 'short',\n};\n\nconst SENTIMENT_DISPLAY_PRECISION = 2;\n\nconst calculateBucketDisplayPrecision = (bucketWidth: number): number => {\n return bucketWidth.toString().split('.')[1]?.length || 0;\n};\n\nconst findSeriesParam = <T extends TooltipParam['seriesId']>(\n params: TooltipParam[],\n seriesId: T\n): Extract<TooltipParam, { seriesId: T }> | undefined => {\n return params.find(\n (series): series is Extract<TooltipParam, { seriesId: T }> =>\n series.seriesId === seriesId\n );\n};\n\nconst getSentimentOverbalanceLabel = (\n sentiment: number,\n bookType: BookType\n): string => {\n if (sentiment < 0) {\n return bookType === BookType.Order\n ? 'sell_overbalance'\n : 'short_overbalance';\n }\n return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';\n};\n\nconst formatCandleData = (\n candleData: [number, number, number, number, number],\n labelCallback: (key: string) => string\n): string => {\n const [, open, close, low, high] = candleData;\n return `<p><b>${labelCallback('candle')}:</b></p>\n<p>${labelCallback('open_price')}: ${open} </p>\n<p>${labelCallback('close_price')}: ${close} </p>\n<p>${labelCallback('low')}: ${low} </p>\n<p>${labelCallback('high')}: ${high} </p>\n`;\n};\n\nconst formatBookData = ({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n}: {\n matchedBucket: Bucket;\n bucketWidth: number;\n bucketDisplayPrecision: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n}): string => {\n const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';\n const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);\n const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(\n bucketDisplayPrecision\n );\n const sentimentLabel = getSentimentOverbalanceLabel(\n matchedBucket.sentiment,\n bookType\n );\n const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(\n bucketDisplayPrecision\n );\n\n return `<br /><p><b>${labelCallback(bookLabelKey)}:</b></p>\n<p>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </p>\n<p>${labelCallback(sentimentLabel)}: ${sentimentValue}% </p>`;\n};\n\nconst formatSentimentData = (\n sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }>,\n labelCallback: (key: string) => string\n): string => {\n const [, shortPercent, longPercent] = sentimentParam.value;\n return `<br /><p><b>${labelCallback('sentiment')}:</b></p>\n<p>${labelCallback('long')}: ${longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>\n<p>${labelCallback('short')}: ${shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>`;\n};\n\nconst hasValidCandleData = (\n candleData: [number, number, number, number, number]\n): boolean =>\n !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[3];\nconst hasValidSentimentData = (\n sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }> | undefined\n): boolean => !!sentimentParam?.value[1] && !!sentimentParam?.value[2];\nconst findMatchingBucket = (\n buckets: Bucket[][],\n bucketsIndex: number | undefined,\n selectedPrice: number,\n bucketWidth: number\n): Bucket | undefined => {\n if (bucketsIndex === undefined) {\n return undefined;\n }\n const selectedBuckets = buckets[bucketsIndex];\n return selectedBuckets?.find(\n ({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth\n );\n};\n\nexport const getTooltipFormatter = ({\n params,\n buckets,\n bucketWidth,\n selectedPrice,\n bookType,\n labelCallback,\n}: {\n params: TooltipParam[];\n buckets: Bucket[][];\n bucketWidth: number;\n selectedPrice: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n}) => {\n if (!params || !Array.isArray(params) || params.length === 0) {\n return '';\n }\n\n const candleParam = findSeriesParam(params, 'candlestick');\n const booksParam = findSeriesParam(params, 'heatmap');\n const sentimentParam = findSeriesParam(params, 'sentiment');\n\n if (!candleParam) {\n return '';\n }\n\n const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);\n const time = new Date(candleParam.axisValue as string);\n const candleData = candleParam.value;\n const bucketsIndex = booksParam?.value[2];\n const matchedBucket = findMatchingBucket(\n buckets,\n bucketsIndex,\n selectedPrice,\n bucketWidth\n );\n const showCandles = hasValidCandleData(candleData);\n const showSentiment = hasValidSentimentData(sentimentParam);\n\n if (!showCandles && !matchedBucket) {\n return '';\n }\n\n const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);\n const candleSection = showCandles\n ? formatCandleData(candleData, labelCallback)\n : '';\n const bookSection = matchedBucket\n ? formatBookData({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n })\n : '';\n const sentimentSection =\n showSentiment && sentimentParam\n ? formatSentimentData(sentimentParam, labelCallback)\n : '';\n\n return `<p>${timeFormatted}</p><br />\n${candleSection}\n${bookSection}\n${sentimentSection}`;\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,+BAA+B;AAGxD,MAAMC,mBAA+C,GAAG;EACtDC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE,SAAS;EACfC,GAAG,EAAE,SAAS;EACdC,KAAK,EAAE,SAAS;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,MAAMC,2BAA2B,GAAG,CAAC;AAErC,MAAMC,+BAA+B,GAAIC,WAAmB,IAAa;EAAA,IAAAC,qBAAA;EACvE,OAAO,EAAAA,qBAAA,GAAAD,WAAW,CAACE,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAAF,qBAAA,uBAApCA,qBAAA,CAAsCG,MAAM,KAAI,CAAC;AAC1D,CAAC;AAED,MAAMC,eAAe,GAAGA,CACtBC,MAAsB,EACtBC,QAAW,KAC4C;EACvD,OAAOD,MAAM,CAACE,IAAI,CACfC,MAAM,IACLA,MAAM,CAACF,QAAQ,KAAKA,QACxB,CAAC;AACH,CAAC;AAED,MAAMG,4BAA4B,GAAGA,CACnCC,SAAiB,EACjBC,QAAkB,KACP;EACX,IAAID,SAAS,GAAG,CAAC,EAAE;IACjB,OAAOC,QAAQ,KAAKtB,QAAQ,CAACuB,KAAK,GAC9B,kBAAkB,GAClB,mBAAmB;EACzB;EACA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B,qBAAqB,CAACL,cAAc,CAAC;EAE3D,IAAI,CAACsB,WAAW,IAAI,CAAClC,aAAa,EAAE;IAClC,OAAO,EAAE;EACX;EAEA,MAAMoC,aAAa,GAAGL,IAAI,CAACM,cAAc,CAACf,SAAS,EAAEvD,mBAAmB,CAAC;EACzE,MAAMuE,aAAa,GAAGJ,WAAW,GAC7B5C,gBAAgB,CAACC,UAAU,EAAEC,aAAa,CAAC,GAC3C,EAAE;EACN,MAAM+C,WAAW,GAAGvC,aAAa,GAC7BF,cAAc,CAAC;IACbE,aAAa;IACbxB,WAAW;IACXyB,sBAAsB;IACtBb,QAAQ;IACRI;EACF,CAAC,CAAC,GACF,EAAE;EACN,MAAMgD,gBAAgB,GACpBL,aAAa,IAAIvB,cAAc,GAC3BD,mBAAmB,CAACC,cAAc,EAAEpB,aAAa,CAAC,GAClD,EAAE;EAER,aAAAK,MAAA,CAAauC,aAAa,kBAAAvC,MAAA,CAC1ByC,aAAa,QAAAzC,MAAA,CACb0C,WAAW,QAAA1C,MAAA,CACX2C,gBAAgB;AAClB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/index.ts"],"sourcesContent":["export * from './formatXAxisLabel';\nexport * from './getChartStyles';\nexport * from './getGradientColor';\nexport * from './getLabelData';\nexport * from './getRectColor';\nexport * from './getTooltipFormatter';\nexport * from './isDifferenceGreaterThanTwoWeeks';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,mCAAmC","ignoreList":[]}
|
package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TIME_THRESHOLDS } from '../../../constants';
|
|
2
|
+
export const isDifferenceGreaterThanTwoWeeks = (startDate, endDate) => {
|
|
3
|
+
const date1 = new Date(startDate);
|
|
4
|
+
const date2 = new Date(endDate);
|
|
5
|
+
const differenceInMs = Math.abs(date2.getTime() - date1.getTime());
|
|
6
|
+
return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=isDifferenceGreaterThanTwoWeeks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDifferenceGreaterThanTwoWeeks.js","names":["TIME_THRESHOLDS","isDifferenceGreaterThanTwoWeeks","startDate","endDate","date1","Date","date2","differenceInMs","Math","abs","getTime","TWO_WEEKS_MS"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts"],"sourcesContent":["import { TIME_THRESHOLDS } from '../../../constants';\n\nexport const isDifferenceGreaterThanTwoWeeks = (\n startDate: string,\n endDate: string\n) => {\n const date1 = new Date(startDate);\n const date2 = new Date(endDate);\n\n const differenceInMs = Math.abs(date2.getTime() - date1.getTime());\n\n return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAEpD,OAAO,MAAMC,+BAA+B,GAAGA,CAC7CC,SAAiB,EACjBC,OAAe,KACZ;EACH,MAAMC,KAAK,GAAG,IAAIC,IAAI,CAACH,SAAS,CAAC;EACjC,MAAMI,KAAK,GAAG,IAAID,IAAI,CAACF,OAAO,CAAC;EAE/B,MAAMI,cAAc,GAAGC,IAAI,CAACC,GAAG,CAACH,KAAK,CAACI,OAAO,CAAC,CAAC,GAAGN,KAAK,CAACM,OAAO,CAAC,CAAC,CAAC;EAElE,OAAOH,cAAc,GAAGP,eAAe,CAACW,YAAY;AACtD,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Division } from '
|
|
2
|
-
import { instrumentSelectConfig, instrumentSelectConfigOC } from '
|
|
1
|
+
import { Division } from '../../../../gql/types/graphql';
|
|
2
|
+
import { instrumentSelectConfig, instrumentSelectConfigOC } from '../../../selectConfig';
|
|
3
3
|
export const getInstrumentConfigForDivision = division => {
|
|
4
4
|
return division === Division.Oc ? instrumentSelectConfigOC : instrumentSelectConfig;
|
|
5
5
|
};
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=getInstrumentConfigForDivision.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInstrumentConfigForDivision.js","names":["Division","instrumentSelectConfig","instrumentSelectConfigOC","getInstrumentConfigForDivision","division","Oc"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.ts"],"sourcesContent":["import { Division } from '../../../../gql/types/graphql';\nimport {\n instrumentSelectConfig,\n instrumentSelectConfigOC,\n} from '../../../selectConfig';\n\nexport const getInstrumentConfigForDivision = (division: Division) => {\n return division === Division.Oc\n ? instrumentSelectConfigOC\n : instrumentSelectConfig;\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,+BAA+B;AACxD,SACEC,sBAAsB,EACtBC,wBAAwB,QACnB,uBAAuB;AAE9B,OAAO,MAAMC,8BAA8B,GAAIC,QAAkB,IAAK;EACpE,OAAOA,QAAQ,KAAKJ,QAAQ,CAACK,EAAE,GAC3BH,wBAAwB,GACxBD,sBAAsB;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Granularity, TimeSpan } from '../../../../gql/types/graphql';
|
|
2
|
+
export const getTimeSpanForGranularity = granularity => {
|
|
3
|
+
const granularityTimeSpanMap = {
|
|
4
|
+
[Granularity.M5]: TimeSpan.TwoDays,
|
|
5
|
+
[Granularity.M15]: TimeSpan.FiveDays,
|
|
6
|
+
[Granularity.H1]: TimeSpan.TwentyDays,
|
|
7
|
+
[Granularity.H4]: TimeSpan.NinetyDays
|
|
8
|
+
};
|
|
9
|
+
return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=getTimeSpanForGranularity.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTimeSpanForGranularity.js","names":["Granularity","TimeSpan","getTimeSpanForGranularity","granularity","granularityTimeSpanMap","M5","TwoDays","M15","FiveDays","H1","TwentyDays","H4","NinetyDays"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts"],"sourcesContent":["import { Granularity, TimeSpan } from '../../../../gql/types/graphql';\n\nexport const getTimeSpanForGranularity = (\n granularity: Granularity\n): TimeSpan => {\n const granularityTimeSpanMap: Record<Granularity, TimeSpan> = {\n [Granularity.M5]: TimeSpan.TwoDays,\n [Granularity.M15]: TimeSpan.FiveDays,\n [Granularity.H1]: TimeSpan.TwentyDays,\n [Granularity.H4]: TimeSpan.NinetyDays,\n };\n\n return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;\n};\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,+BAA+B;AAErE,OAAO,MAAMC,yBAAyB,GACpCC,WAAwB,IACX;EACb,MAAMC,sBAAqD,GAAG;IAC5D,CAACJ,WAAW,CAACK,EAAE,GAAGJ,QAAQ,CAACK,OAAO;IAClC,CAACN,WAAW,CAACO,GAAG,GAAGN,QAAQ,CAACO,QAAQ;IACpC,CAACR,WAAW,CAACS,EAAE,GAAGR,QAAQ,CAACS,UAAU;IACrC,CAACV,WAAW,CAACW,EAAE,GAAGV,QAAQ,CAACW;EAC7B,CAAC;EAED,OAAOR,sBAAsB,CAACD,WAAW,CAAC,IAAIF,QAAQ,CAACK,OAAO;AAChE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './getInstrumentConfigForDivision';
|
|
2
|
+
export * from './getTimeSpanForGranularity';
|
|
3
|
+
export * from './processOrderPositionBooks';
|
|
4
|
+
export * from './processPriceCandles';
|
|
5
|
+
export * from './processSentiments';
|
|
6
|
+
export * from './validateData';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/dataUtils/index.ts"],"sourcesContent":["export * from './getInstrumentConfigForDivision';\nexport * from './getTimeSpanForGranularity';\nexport * from './processOrderPositionBooks';\nexport * from './processPriceCandles';\nexport * from './processSentiments';\nexport * from './validateData';\n"],"mappings":"AAAA,cAAc,kCAAkC;AAChD,cAAc,6BAA6B;AAC3C,cAAc,6BAA6B;AAC3C,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const processOrderPositionBooks = (orderPositionData, dates) => {
|
|
2
|
+
var _orderPositionData$or, _orderPositionData$or2, _orderPositionData$or3, _orderPositionData$or4;
|
|
3
|
+
if (!Array.isArray(dates) || dates.length === 0) {
|
|
4
|
+
return {
|
|
5
|
+
bookPrices: [],
|
|
6
|
+
bookIndexes: [],
|
|
7
|
+
buckets: [],
|
|
8
|
+
bucketWidth: 0,
|
|
9
|
+
sentimentThresholdMin: 0,
|
|
10
|
+
sentimentThresholdMax: 0,
|
|
11
|
+
hasValidBooks: false
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (!(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or !== void 0 && (_orderPositionData$or = _orderPositionData$or.books) !== null && _orderPositionData$or !== void 0 && _orderPositionData$or.length) || !(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or2 = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or2 !== void 0 && _orderPositionData$or2.sentimentThresholdMin) || !(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or3 = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or3 !== void 0 && _orderPositionData$or3.sentimentThresholdMax) || !(orderPositionData !== null && orderPositionData !== void 0 && (_orderPositionData$or4 = orderPositionData.orderPositionBooks) !== null && _orderPositionData$or4 !== void 0 && _orderPositionData$or4.bucketWidth)) {
|
|
15
|
+
return {
|
|
16
|
+
bookPrices: [],
|
|
17
|
+
bookIndexes: [],
|
|
18
|
+
buckets: [],
|
|
19
|
+
bucketWidth: 0,
|
|
20
|
+
sentimentThresholdMin: 0,
|
|
21
|
+
sentimentThresholdMax: 0,
|
|
22
|
+
hasValidBooks: false
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
bucketWidth,
|
|
27
|
+
sentimentThresholdMin,
|
|
28
|
+
sentimentThresholdMax
|
|
29
|
+
} = orderPositionData.orderPositionBooks;
|
|
30
|
+
const booksDataMap = new Map(orderPositionData.orderPositionBooks.books.map(item => [item.time, {
|
|
31
|
+
price: item.price,
|
|
32
|
+
buckets: item.buckets
|
|
33
|
+
}]));
|
|
34
|
+
const bookPrices = [];
|
|
35
|
+
const bookIndexes = [];
|
|
36
|
+
const buckets = [];
|
|
37
|
+
dates.forEach((date, index) => {
|
|
38
|
+
var _book$price;
|
|
39
|
+
const book = booksDataMap.get(date);
|
|
40
|
+
const currentBuckets = (book === null || book === void 0 ? void 0 : book.buckets.filter(bucket => bucket !== null && typeof bucket.price === 'number' && typeof bucket.sentiment === 'number' && Math.abs(bucket.sentiment) >= sentimentThresholdMin).map(bucket => ({
|
|
41
|
+
price: bucket.price,
|
|
42
|
+
sentiment: bucket.sentiment
|
|
43
|
+
}))) || [];
|
|
44
|
+
bookPrices.push((_book$price = book === null || book === void 0 ? void 0 : book.price) !== null && _book$price !== void 0 ? _book$price : null);
|
|
45
|
+
bookIndexes.push(index);
|
|
46
|
+
buckets.push(currentBuckets);
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
bookPrices,
|
|
50
|
+
bookIndexes,
|
|
51
|
+
buckets,
|
|
52
|
+
bucketWidth,
|
|
53
|
+
sentimentThresholdMin,
|
|
54
|
+
sentimentThresholdMax,
|
|
55
|
+
hasValidBooks: true
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=processOrderPositionBooks.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processOrderPositionBooks.js","names":["processOrderPositionBooks","orderPositionData","dates","_orderPositionData$or","_orderPositionData$or2","_orderPositionData$or3","_orderPositionData$or4","Array","isArray","length","bookPrices","bookIndexes","buckets","bucketWidth","sentimentThresholdMin","sentimentThresholdMax","hasValidBooks","orderPositionBooks","books","booksDataMap","Map","map","item","time","price","forEach","date","index","_book$price","book","get","currentBuckets","filter","bucket","sentiment","Math","abs","push"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.ts"],"sourcesContent":["import type { GetOrderPositionBooksQuery } from '../../../../gql/types/graphql';\nimport type { Bucket } from '../types';\n\nexport const processOrderPositionBooks = (\n orderPositionData: GetOrderPositionBooksQuery | undefined,\n dates: string[]\n) => {\n // Input validation\n if (!Array.isArray(dates) || dates.length === 0) {\n return {\n bookPrices: [],\n bookIndexes: [],\n buckets: [],\n bucketWidth: 0,\n sentimentThresholdMin: 0,\n sentimentThresholdMax: 0,\n hasValidBooks: false,\n };\n }\n\n if (\n !orderPositionData?.orderPositionBooks?.books?.length ||\n !orderPositionData?.orderPositionBooks?.sentimentThresholdMin ||\n !orderPositionData?.orderPositionBooks?.sentimentThresholdMax ||\n !orderPositionData?.orderPositionBooks?.bucketWidth\n ) {\n return {\n bookPrices: [],\n bookIndexes: [],\n buckets: [],\n bucketWidth: 0,\n sentimentThresholdMin: 0,\n sentimentThresholdMax: 0,\n hasValidBooks: false,\n };\n }\n\n const { bucketWidth, sentimentThresholdMin, sentimentThresholdMax } =\n orderPositionData.orderPositionBooks;\n\n const booksDataMap = new Map(\n orderPositionData.orderPositionBooks.books.map((item) => [\n item.time,\n {\n price: item.price,\n buckets: item.buckets,\n },\n ])\n );\n\n // Use forEach + push for O(n) performance instead of reduce with spreads (O(n²))\n const bookPrices: (number | null)[] = [];\n const bookIndexes: number[] = [];\n const buckets: Bucket[][] = [];\n\n dates.forEach((date, index) => {\n const book = booksDataMap.get(date);\n\n const currentBuckets =\n book?.buckets\n .filter(\n (\n bucket\n ): bucket is {\n price: number;\n sentiment: number;\n } =>\n bucket !== null &&\n typeof bucket.price === 'number' &&\n typeof bucket.sentiment === 'number' &&\n Math.abs(bucket.sentiment) >= sentimentThresholdMin\n )\n .map((bucket) => ({\n price: bucket.price,\n sentiment: bucket.sentiment,\n })) || [];\n\n bookPrices.push(book?.price ?? null);\n bookIndexes.push(index);\n buckets.push(currentBuckets);\n });\n\n return {\n bookPrices,\n bookIndexes,\n buckets,\n bucketWidth,\n sentimentThresholdMin,\n sentimentThresholdMax,\n hasValidBooks: true,\n };\n};\n"],"mappings":"AAGA,OAAO,MAAMA,yBAAyB,GAAGA,CACvCC,iBAAyD,EACzDC,KAAe,KACZ;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA,EAAAC,sBAAA;EAEH,IAAI,CAACC,KAAK,CAAC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AAC","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const processPriceCandles = priceCandlesData => {
|
|
2
|
+
var _priceCandlesData$pri, _priceCandlesData$pri2;
|
|
3
|
+
const errorResult = {
|
|
4
|
+
minPrice: 0,
|
|
5
|
+
maxPrice: 0,
|
|
6
|
+
pipsLocation: 0,
|
|
7
|
+
hasValidCandles: false,
|
|
8
|
+
candlesOpen: [],
|
|
9
|
+
candlesClose: [],
|
|
10
|
+
candlesLow: [],
|
|
11
|
+
candlesHigh: [],
|
|
12
|
+
dates: []
|
|
13
|
+
};
|
|
14
|
+
if (!(priceCandlesData !== null && priceCandlesData !== void 0 && (_priceCandlesData$pri = priceCandlesData.priceCandles) !== null && _priceCandlesData$pri !== void 0 && (_priceCandlesData$pri = _priceCandlesData$pri.candle) !== null && _priceCandlesData$pri !== void 0 && _priceCandlesData$pri.length) || !(priceCandlesData !== null && priceCandlesData !== void 0 && (_priceCandlesData$pri2 = priceCandlesData.priceCandles) !== null && _priceCandlesData$pri2 !== void 0 && _priceCandlesData$pri2.pipsLocation)) {
|
|
15
|
+
return errorResult;
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
dates,
|
|
19
|
+
candlesOpen,
|
|
20
|
+
candlesClose,
|
|
21
|
+
candlesLow,
|
|
22
|
+
candlesHigh
|
|
23
|
+
} = priceCandlesData.priceCandles.candle.reduce((acc, candle) => {
|
|
24
|
+
if (!candle) {
|
|
25
|
+
return acc;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
dates: [...acc.dates, candle.point],
|
|
29
|
+
candlesOpen: [...acc.candlesOpen, candle.open],
|
|
30
|
+
candlesClose: [...acc.candlesClose, candle.close],
|
|
31
|
+
candlesLow: [...acc.candlesLow, candle.low],
|
|
32
|
+
candlesHigh: [...acc.candlesHigh, candle.high]
|
|
33
|
+
};
|
|
34
|
+
}, {
|
|
35
|
+
dates: [],
|
|
36
|
+
candlesOpen: [],
|
|
37
|
+
candlesClose: [],
|
|
38
|
+
candlesLow: [],
|
|
39
|
+
candlesHigh: []
|
|
40
|
+
});
|
|
41
|
+
if (dates.length === 0) {
|
|
42
|
+
return errorResult;
|
|
43
|
+
}
|
|
44
|
+
const minPrice = Math.min(...candlesLow);
|
|
45
|
+
const maxPrice = Math.max(...candlesHigh);
|
|
46
|
+
return {
|
|
47
|
+
minPrice,
|
|
48
|
+
maxPrice,
|
|
49
|
+
candlesOpen,
|
|
50
|
+
candlesClose,
|
|
51
|
+
candlesLow,
|
|
52
|
+
candlesHigh,
|
|
53
|
+
dates,
|
|
54
|
+
hasValidCandles: true,
|
|
55
|
+
pipsLocation: priceCandlesData.priceCandles.pipsLocation
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=processPriceCandles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processPriceCandles.js","names":["processPriceCandles","priceCandlesData","_priceCandlesData$pri","_priceCandlesData$pri2","errorResult","minPrice","maxPrice","pipsLocation","hasValidCandles","candlesOpen","candlesClose","candlesLow","candlesHigh","dates","priceCandles","candle","length","reduce","acc","point","open","close","low","high","Math","min","max"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts"],"sourcesContent":["import type { GetPriceCandlesQuery } from '../../../../gql/types/graphql';\n\nexport const processPriceCandles = (\n priceCandlesData: GetPriceCandlesQuery | undefined\n) => {\n const errorResult = {\n minPrice: 0,\n maxPrice: 0,\n pipsLocation: 0,\n hasValidCandles: false,\n candlesOpen: [],\n candlesClose: [],\n candlesLow: [],\n candlesHigh: [],\n dates: [],\n };\n\n if (\n !priceCandlesData?.priceCandles?.candle?.length ||\n !priceCandlesData?.priceCandles?.pipsLocation\n ) {\n return errorResult;\n }\n\n const { dates, candlesOpen, candlesClose, candlesLow, candlesHigh } =\n priceCandlesData.priceCandles.candle.reduce(\n (acc, candle) => {\n if (!candle) {\n return acc;\n }\n\n return {\n dates: [...acc.dates, candle.point],\n candlesOpen: [...acc.candlesOpen, candle.open],\n candlesClose: [...acc.candlesClose, candle.close],\n candlesLow: [...acc.candlesLow, candle.low],\n candlesHigh: [...acc.candlesHigh, candle.high],\n };\n },\n {\n dates: [] as string[],\n candlesOpen: [] as number[],\n candlesClose: [] as number[],\n candlesLow: [] as number[],\n candlesHigh: [] as number[],\n }\n );\n\n if (dates.length === 0) {\n return errorResult;\n }\n\n const minPrice = Math.min(...candlesLow);\n const maxPrice = Math.max(...candlesHigh);\n\n return {\n minPrice,\n maxPrice,\n candlesOpen,\n candlesClose,\n candlesLow,\n candlesHigh,\n dates,\n hasValidCandles: true,\n pipsLocation: priceCandlesData.priceCandles.pipsLocation,\n };\n};\n"],"mappings":"AAEA,OAAO,MAAMA,mBAAmB,GAC9BC,gBAAkD,IAC/C;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EACH,MAAMC,WAAW,GAAG;IAClBC,QAAQ,EAAE,CAAC;IACXC,QAAQ,EAAE,CAAC;IACXC,YAAY,EAAE,CAAC;IACfC,eAAe,EAAE,KAAK;IACtBC,WAAW,EAAE,EAAE;IACfC,YAAY,EAAE,EAAE;IAChBC,UAAU,EAAE,EAAE;IACdC,WAAW,EAAE,EAAE;IACfC,KAAK,EAAE;EACT,CAAC;EAED,IACE,EAACZ,gBAAgB,aAAhBA,gBAAgB,gBAAAC,qBAAA,GAAhBD,gBAAgB,CAAEa,YAAY,cAAAZ,qBAAA,gBAAAA,qBAAA,GAA9BA,qBAAA,CAAgCa,MAAM,cAAAb,qBAAA,eAAtCA,qBAAA,CAAwCc,MAAM,KAC/C,EAACf,gBAAgB,aAAhBA,gBAAgB,gBAAAE,sBAAA,GAAhBF,gBAAgB,CAAEa,YAAY,cAAAX,sBAAA,eAA9BA,sBAAA,CAAgCI,YAAY,GAC7C;IACA,OAAOH,WAAW;EACpB;EAEA,MAAM;IAAES,KAAK;IAAEJ,WAAW;IAAEC,YAAY;IAAEC,UAAU;IAAEC;EAAY,CAAC,G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_sentimentsData$senti;
|
|
3
|
+
if (!Array.isArray(dates) || dates.length === 0 || !(sentimentsData !== null && sentimentsData !== void 0 && (_sentimentsData$senti = sentimentsData.sentiments) !== null && _sentimentsData$senti !== void 0 && (_sentimentsData$senti = _sentimentsData$senti.sentiments) !== null && _sentimentsData$senti !== void 0 && _sentimentsData$senti.length)) {
|
|
4
|
+
return {
|
|
5
|
+
sentimentLongs: [],
|
|
6
|
+
sentimentShorts: [],
|
|
7
|
+
hasValidSentiments: false
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const sentimentMap = new Map(sentimentsData.sentiments.sentiments.map(item => {
|
|
11
|
+
var _item$sentiment$short, _item$sentiment, _item$sentiment$longP, _item$sentiment2;
|
|
12
|
+
return [item === null || item === void 0 ? void 0 : item.time, {
|
|
13
|
+
sentimentShorts: (_item$sentiment$short = item === null || item === void 0 || (_item$sentiment = item.sentiment) === null || _item$sentiment === void 0 ? void 0 : _item$sentiment.shortPercent) !== null && _item$sentiment$short !== void 0 ? _item$sentiment$short : null,
|
|
14
|
+
sentimentLongs: (_item$sentiment$longP = item === null || item === void 0 || (_item$sentiment2 = item.sentiment) === null || _item$sentiment2 === void 0 ? void 0 : _item$sentiment2.longPercent) !== null && _item$sentiment$longP !== void 0 ? _item$sentiment$longP : null
|
|
15
|
+
}];
|
|
16
|
+
}));
|
|
17
|
+
const {
|
|
18
|
+
sentimentLongs,
|
|
19
|
+
sentimentShorts
|
|
20
|
+
} = dates.reduce((acc, date) => {
|
|
21
|
+
const sentiment = sentimentMap.get(date);
|
|
22
|
+
return {
|
|
23
|
+
sentimentLongs: [...acc.sentimentLongs, (sentiment === null || sentiment === void 0 ? void 0 : sentiment.sentimentLongs) || null],
|
|
24
|
+
sentimentShorts: [...acc.sentimentShorts, (sentiment === null || sentiment === void 0 ? void 0 : sentiment.sentimentShorts) || null]
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
sentimentLongs: [],
|
|
28
|
+
sentimentShorts: []
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
sentimentLongs,
|
|
32
|
+
sentimentShorts,
|
|
33
|
+
hasValidSentiments: true
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=processSentiments.js.map
|