@operato/scene-scichart 7.0.2 → 7.0.3

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/db.sqlite +0 -0
  3. package/dist/charts/ox-scichart.d.ts +2 -1
  4. package/dist/charts/ox-scichart.js +20 -9
  5. package/dist/charts/ox-scichart.js.map +1 -1
  6. package/dist/index.d.ts +0 -2
  7. package/dist/index.js +0 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/templates/index.d.ts +51 -0
  10. package/dist/templates/index.js +1 -3
  11. package/dist/templates/index.js.map +1 -1
  12. package/icons/scichart-timeseries.png +0 -0
  13. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +35 -0
  14. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +15 -0
  15. package/logs/application-2024-07-05-16.log +106 -0
  16. package/logs/application-2024-07-05-19.log +1 -0
  17. package/logs/application-2024-07-05-20.log +5 -0
  18. package/logs/application-2024-07-05-21.log +1 -0
  19. package/logs/application-2024-07-05-22.log +105 -0
  20. package/logs/application-2024-07-05-23.log +1 -0
  21. package/logs/application-2024-07-06-00.log +105 -0
  22. package/logs/connections-2024-07-05-16.log +50 -0
  23. package/logs/connections-2024-07-05-22.log +50 -0
  24. package/logs/connections-2024-07-06-00.log +50 -0
  25. package/logs/system/.ff447eb42e255d0436b200b50a92dc6546166b36-audit.json +25 -0
  26. package/logs/system/scenario-/353/251/224/354/235/270 /354/247/221/354/247/204/352/270/260 /354/204/274/354/213/261 /353/215/260/354/235/264/355/204/260 /354/241/260/355/232/214 - /354/213/244/354/213/234/352/260/204-2024-07-05-16.log" +7 -0
  27. package/logs/system/scenario-/353/251/224/354/235/270 /354/247/221/354/247/204/352/270/260 /354/204/274/354/213/261 /353/215/260/354/235/264/355/204/260 /354/241/260/355/232/214 - /354/213/244/354/213/234/352/260/204-2024-07-05-19.log" +7 -0
  28. package/logs/system/scenario-/353/251/224/354/235/270 /354/247/221/354/247/204/352/270/260 /354/204/274/354/213/261 /353/215/260/354/235/264/355/204/260 /354/241/260/355/232/214 - /354/213/244/354/213/234/352/260/204-2024-07-05-20.log" +35 -0
  29. package/logs/system/scenario-/353/251/224/354/235/270 /354/247/221/354/247/204/352/270/260 /354/204/274/354/213/261 /353/215/260/354/235/264/355/204/260 /354/241/260/355/232/214 - /354/213/244/354/213/234/352/260/204-2024-07-05-21.log" +7 -0
  30. package/logs/system/scenario-/353/251/224/354/235/270 /354/247/221/354/247/204/352/270/260 /354/204/274/354/213/261 /353/215/260/354/235/264/355/204/260 /354/241/260/355/232/214 - /354/213/244/354/213/234/352/260/204-2024-07-05-23.log" +7 -0
  31. package/package.json +2 -2
  32. package/src/charts/ox-scichart.ts +18 -8
  33. package/src/index.ts +0 -2
  34. package/src/templates/index.ts +1 -3
  35. package/tsconfig.tsbuildinfo +1 -1
  36. package/dist/charts/sci-candle-stick-chart.d.ts +0 -19
  37. package/dist/charts/sci-candle-stick-chart.js +0 -249
  38. package/dist/charts/sci-candle-stick-chart.js.map +0 -1
  39. package/dist/charts/volume-pallette-provider.d.ts +0 -12
  40. package/dist/charts/volume-pallette-provider.js +0 -21
  41. package/dist/charts/volume-pallette-provider.js.map +0 -1
  42. package/dist/data/binance-rest-client.d.ts +0 -14
  43. package/dist/data/binance-rest-client.js +0 -53
  44. package/dist/data/binance-rest-client.js.map +0 -1
  45. package/dist/scichart-candle-stick.d.ts +0 -10
  46. package/dist/scichart-candle-stick.js +0 -50
  47. package/dist/scichart-candle-stick.js.map +0 -1
  48. package/dist/scichart.d.ts +0 -21
  49. package/dist/scichart.js +0 -72
  50. package/dist/scichart.js.map +0 -1
  51. package/dist/templates/scichart-candle-stick.d.ts +0 -14
  52. package/dist/templates/scichart-candle-stick.js +0 -16
  53. package/dist/templates/scichart-candle-stick.js.map +0 -1
  54. package/dist/templates/scichart.d.ts +0 -14
  55. package/dist/templates/scichart.js +0 -16
  56. package/dist/templates/scichart.js.map +0 -1
  57. package/dist/themes/app-theme.d.ts +0 -56
  58. package/dist/themes/app-theme.js +0 -35
  59. package/dist/themes/app-theme.js.map +0 -1
  60. package/icons/scichart-candle-stick.png +0 -0
  61. package/icons/scichart.png +0 -0
  62. package/src/charts/sci-candle-stick-chart.ts +0 -306
  63. package/src/charts/volume-pallette-provider.ts +0 -41
  64. package/src/data/binance-rest-client.ts +0 -74
  65. package/src/scichart-candle-stick.ts +0 -60
  66. package/src/scichart.ts +0 -90
  67. package/src/templates/scichart-candle-stick.ts +0 -16
  68. package/src/templates/scichart.ts +0 -16
  69. package/src/themes/app-theme.ts +0 -72
@@ -1,14 +0,0 @@
1
- declare const _default: {
2
- type: string;
3
- description: string;
4
- group: string;
5
- icon: string;
6
- model: {
7
- type: string;
8
- left: number;
9
- top: number;
10
- width: number;
11
- height: number;
12
- };
13
- };
14
- export default _default;
@@ -1,16 +0,0 @@
1
- const icon = new URL('../../icons/scichart.png', import.meta.url).href;
2
- export default {
3
- type: 'scichart',
4
- description: 'scichart',
5
- /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
6
- group: 'chartAndGauge',
7
- icon,
8
- model: {
9
- type: 'scichart',
10
- left: 10,
11
- top: 10,
12
- width: 400,
13
- height: 300
14
- }
15
- };
16
- //# sourceMappingURL=scichart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scichart.js","sourceRoot":"","sources":["../../src/templates/scichart.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAEtE,eAAe;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,gGAAgG;IAChG,KAAK,EAAE,eAAe;IACtB,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;KACZ;CACF,CAAA","sourcesContent":["const icon = new URL('../../icons/scichart.png', import.meta.url).href\n\nexport default {\n type: 'scichart',\n description: 'scichart',\n /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */\n group: 'chartAndGauge',\n icon,\n model: {\n type: 'scichart',\n left: 10,\n top: 10,\n width: 400,\n height: 300\n }\n}\n"]}
@@ -1,56 +0,0 @@
1
- import { IThemeProvider, SciChartJsNavyTheme } from 'scichart';
2
- export interface AppThemeBase {
3
- SciChartJsTheme: IThemeProvider;
4
- ForegroundColor: string;
5
- Background: string;
6
- VividSkyBlue: string;
7
- VividPink: string;
8
- VividTeal: string;
9
- VividOrange: string;
10
- VividBlue: string;
11
- VividPurple: string;
12
- VividGreen: string;
13
- VividRed: string;
14
- MutedSkyBlue: string;
15
- MutedPink: string;
16
- MutedTeal: string;
17
- MutedOrange: string;
18
- MutedBlue: string;
19
- MutedPurple: string;
20
- MutedRed: string;
21
- PaleSkyBlue: string;
22
- PalePink: string;
23
- PaleTeal: string;
24
- PaleOrange: string;
25
- PaleBlue: string;
26
- PalePurple: string;
27
- }
28
- export declare class SciChartAppTheme implements AppThemeBase {
29
- SciChartJsTheme: SciChartJsNavyTheme;
30
- ForegroundColor: string;
31
- Background: string;
32
- VividSkyBlue: string;
33
- VividPink: string;
34
- VividTeal: string;
35
- VividOrange: string;
36
- VividBlue: string;
37
- VividPurple: string;
38
- VividGreen: string;
39
- VividRed: string;
40
- DarkIndigo: string;
41
- Indigo: string;
42
- MutedSkyBlue: string;
43
- MutedPink: string;
44
- MutedTeal: string;
45
- MutedOrange: string;
46
- MutedBlue: string;
47
- MutedPurple: string;
48
- MutedRed: string;
49
- PaleSkyBlue: string;
50
- PalePink: string;
51
- PaleTeal: string;
52
- PaleOrange: string;
53
- PaleBlue: string;
54
- PalePurple: string;
55
- }
56
- export declare const appTheme: SciChartAppTheme;
@@ -1,35 +0,0 @@
1
- import { SciChartJsNavyTheme } from 'scichart';
2
- export class SciChartAppTheme {
3
- constructor() {
4
- this.SciChartJsTheme = new SciChartJsNavyTheme();
5
- // General colors
6
- this.ForegroundColor = '#FFFFFF';
7
- this.Background = this.SciChartJsTheme.sciChartBackground;
8
- // Series colors
9
- this.VividSkyBlue = '#50C7E0';
10
- this.VividPink = '#EC0F6C';
11
- this.VividTeal = '#30BC9A';
12
- this.VividOrange = '#F48420';
13
- this.VividBlue = '#364BA0';
14
- this.VividPurple = '#882B91';
15
- this.VividGreen = '#67BDAF';
16
- this.VividRed = '#C52E60';
17
- this.DarkIndigo = '#14233C';
18
- this.Indigo = '#264B93';
19
- this.MutedSkyBlue = '#83D2F5';
20
- this.MutedPink = '#DF69A8';
21
- this.MutedTeal = '#7BCAAB';
22
- this.MutedOrange = '#E7C565';
23
- this.MutedBlue = '#537ABD';
24
- this.MutedPurple = '#A16DAE';
25
- this.MutedRed = '#DC7969';
26
- this.PaleSkyBlue = '#E4F5FC';
27
- this.PalePink = '#EEB3D2';
28
- this.PaleTeal = '#B9E0D4';
29
- this.PaleOrange = '#F1CFB5';
30
- this.PaleBlue = '#B5BEDF';
31
- this.PalePurple = '#CFB4D5';
32
- }
33
- }
34
- export const appTheme = new SciChartAppTheme();
35
- //# sourceMappingURL=app-theme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-theme.js","sourceRoot":"","sources":["../../src/themes/app-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAmC9D,MAAM,OAAO,gBAAgB;IAA7B;QACE,oBAAe,GAAG,IAAI,mBAAmB,EAAE,CAAA;QAE3C,iBAAiB;QACjB,oBAAe,GAAG,SAAS,CAAA;QAC3B,eAAU,GAAG,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAA;QAEpD,gBAAgB;QAChB,iBAAY,GAAG,SAAS,CAAA;QACxB,cAAS,GAAG,SAAS,CAAA;QACrB,cAAS,GAAG,SAAS,CAAA;QACrB,gBAAW,GAAG,SAAS,CAAA;QACvB,cAAS,GAAG,SAAS,CAAA;QACrB,gBAAW,GAAG,SAAS,CAAA;QACvB,eAAU,GAAG,SAAS,CAAA;QACtB,aAAQ,GAAG,SAAS,CAAA;QAEpB,eAAU,GAAG,SAAS,CAAA;QACtB,WAAM,GAAG,SAAS,CAAA;QAElB,iBAAY,GAAG,SAAS,CAAA;QACxB,cAAS,GAAG,SAAS,CAAA;QACrB,cAAS,GAAG,SAAS,CAAA;QACrB,gBAAW,GAAG,SAAS,CAAA;QACvB,cAAS,GAAG,SAAS,CAAA;QACrB,gBAAW,GAAG,SAAS,CAAA;QACvB,aAAQ,GAAG,SAAS,CAAA;QAEpB,gBAAW,GAAG,SAAS,CAAA;QACvB,aAAQ,GAAG,SAAS,CAAA;QACpB,aAAQ,GAAG,SAAS,CAAA;QACpB,eAAU,GAAG,SAAS,CAAA;QACtB,aAAQ,GAAG,SAAS,CAAA;QACpB,eAAU,GAAG,SAAS,CAAA;IACxB,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAA","sourcesContent":["import { IThemeProvider, SciChartJsNavyTheme } from 'scichart'\n\nexport interface AppThemeBase {\n SciChartJsTheme: IThemeProvider\n\n // general colors\n ForegroundColor: string\n Background: string\n\n // Series colors\n VividSkyBlue: string\n VividPink: string\n VividTeal: string\n VividOrange: string\n VividBlue: string\n VividPurple: string\n VividGreen: string\n VividRed: string\n\n MutedSkyBlue: string\n MutedPink: string\n MutedTeal: string\n MutedOrange: string\n MutedBlue: string\n MutedPurple: string\n MutedRed: string\n\n PaleSkyBlue: string\n PalePink: string\n PaleTeal: string\n PaleOrange: string\n PaleBlue: string\n PalePurple: string\n}\n\nexport class SciChartAppTheme implements AppThemeBase {\n SciChartJsTheme = new SciChartJsNavyTheme()\n\n // General colors\n ForegroundColor = '#FFFFFF'\n Background = this.SciChartJsTheme.sciChartBackground\n\n // Series colors\n VividSkyBlue = '#50C7E0'\n VividPink = '#EC0F6C'\n VividTeal = '#30BC9A'\n VividOrange = '#F48420'\n VividBlue = '#364BA0'\n VividPurple = '#882B91'\n VividGreen = '#67BDAF'\n VividRed = '#C52E60'\n\n DarkIndigo = '#14233C'\n Indigo = '#264B93'\n\n MutedSkyBlue = '#83D2F5'\n MutedPink = '#DF69A8'\n MutedTeal = '#7BCAAB'\n MutedOrange = '#E7C565'\n MutedBlue = '#537ABD'\n MutedPurple = '#A16DAE'\n MutedRed = '#DC7969'\n\n PaleSkyBlue = '#E4F5FC'\n PalePink = '#EEB3D2'\n PaleTeal = '#B9E0D4'\n PaleOrange = '#F1CFB5'\n PaleBlue = '#B5BEDF'\n PalePurple = '#CFB4D5'\n}\n\nexport const appTheme = new SciChartAppTheme()\n"]}
Binary file
Binary file
@@ -1,306 +0,0 @@
1
- import { LitElement, PropertyValues, PropertyValueMap, css, html } from 'lit'
2
- import { customElement, property, query, state } from 'lit/decorators.js'
3
-
4
- import {
5
- SciChartSurface,
6
- NumberRange,
7
- NumericAxis,
8
- OhlcDataSeries,
9
- FastCandlestickRenderableSeries,
10
- ZoomPanModifier,
11
- ZoomExtentsModifier,
12
- MouseWheelZoomModifier,
13
- ENumericFormat,
14
- DateTimeNumericAxis,
15
- EAutoRange,
16
- FastLineRenderableSeries,
17
- XyMovingAverageFilter,
18
- SciChartOverview,
19
- CursorModifier,
20
- CursorTooltipSvgAnnotation,
21
- SeriesInfo,
22
- EDataSeriesType,
23
- ESeriesType,
24
- IRenderableSeries,
25
- FastMountainRenderableSeries,
26
- GradientParams,
27
- Point,
28
- OhlcSeriesInfo,
29
- FastColumnRenderableSeries,
30
- XyDataSeries,
31
- FastOhlcRenderableSeries
32
- } from 'scichart'
33
-
34
- import { appTheme } from '../themes/app-theme'
35
- import { VolumePaletteProvider } from './volume-pallette-provider'
36
- import { simpleBinanceRestClient } from '../data/binance-rest-client'
37
-
38
- const Y_AXIS_VOLUME_ID = 'Y_AXIS_VOLUME_ID'
39
-
40
- SciChartSurface.UseCommunityLicense()
41
- SciChartSurface.configure({
42
- dataUrl: `/node_modules/scichart/_wasm/scichart2d.data`,
43
- wasmUrl: `/node_modules/scichart/_wasm/scichart2d.wasm`
44
- })
45
-
46
- @customElement('sci-candle-stock-chart')
47
- export class SciCandleStockChart extends LitElement {
48
- static styles = [
49
- css`
50
- :host {
51
- display: flex;
52
- flex-direction: column;
53
-
54
- width: 100%;
55
- }
56
-
57
- #chart {
58
- flex: 8;
59
- }
60
-
61
- #overview {
62
- flex: 2;
63
- }
64
- `
65
- ]
66
-
67
- render() {
68
- return html`
69
- <div id="chart"></div>
70
- <div id="overview"></div>
71
- `
72
- }
73
-
74
- @property({ type: String, attribute: 'series-type' }) seriesType: 'candle-stick' | 'ohlc' = 'candle-stick'
75
-
76
- @state() candlestickChartSeries!: FastCandlestickRenderableSeries
77
- @state() ohlcChartSeries!: FastOhlcRenderableSeries
78
- @state() sciChartSurface?: SciChartSurface
79
- @state() sciChartOverview?: SciChartOverview
80
-
81
- @query('#chart') chart!: HTMLDivElement
82
- @query('#overview') overview!: HTMLDivElement
83
-
84
- disconnectedCallback(): void {
85
- if (this.sciChartSurface) {
86
- this.sciChartSurface.delete()
87
- this.sciChartOverview!.delete()
88
- this.sciChartSurface = undefined
89
- this.sciChartOverview = undefined
90
- return
91
- }
92
- }
93
-
94
- protected async firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): Promise<void> {
95
- const { sciChartSurface, overview, candlestickSeries, ohlcSeries } = await this.build()
96
-
97
- this.candlestickChartSeries = candlestickSeries
98
- this.ohlcChartSeries = ohlcSeries
99
- this.sciChartSurface = sciChartSurface
100
- this.sciChartOverview = overview
101
-
102
- this.candlestickChartSeries.isVisible = this.seriesType == 'candle-stick'
103
- this.ohlcChartSeries.isVisible = this.seriesType == 'ohlc'
104
- }
105
-
106
- updated(changes: PropertyValues<this>) {
107
- if (changes.has('seriesType') && this.candlestickChartSeries) {
108
- this.candlestickChartSeries.isVisible = this.seriesType == 'candle-stick'
109
- this.ohlcChartSeries.isVisible = this.seriesType == 'ohlc'
110
- }
111
- }
112
-
113
- // Override the Renderableseries to display on the scichart overview
114
- private getOverviewSeries(defaultSeries: IRenderableSeries) {
115
- if (defaultSeries.type === ESeriesType.CandlestickSeries) {
116
- // Swap the default candlestick series on the overview chart for a mountain series. Same data
117
- return new FastMountainRenderableSeries(defaultSeries.parentSurface.webAssemblyContext2D, {
118
- dataSeries: defaultSeries.dataSeries,
119
- fillLinearGradient: new GradientParams(new Point(0, 0), new Point(0, 1), [
120
- { color: appTheme.VividSkyBlue + '77', offset: 0 },
121
- { color: 'Transparent', offset: 1 }
122
- ]),
123
- stroke: appTheme.VividSkyBlue
124
- })
125
- }
126
- }
127
-
128
- // Override the standard tooltip displayed by CursorModifier
129
- private getTooltipLegendTemplate(seriesInfos: SeriesInfo[], svgAnnotation: CursorTooltipSvgAnnotation) {
130
- let outputSvgString = ''
131
-
132
- // Foreach series there will be a seriesInfo supplied by SciChart. This contains info about the series under the house
133
- seriesInfos.forEach((seriesInfo, index) => {
134
- const y = 20 + index * 20
135
- const textColor = seriesInfo.stroke
136
- let legendText = seriesInfo.formattedYValue
137
- if (seriesInfo.dataSeriesType === EDataSeriesType.Ohlc) {
138
- const o = seriesInfo as OhlcSeriesInfo
139
- legendText = `Open=${o.formattedOpenValue} High=${o.formattedHighValue} Low=${o.formattedLowValue} Close=${o.formattedCloseValue}`
140
- }
141
- outputSvgString += `<text x="8" y="${y}" font-size="13" font-family="Verdana" fill="${textColor}">
142
- ${seriesInfo.seriesName}: ${legendText}
143
- </text>`
144
- })
145
-
146
- return `<svg width="100%" height="100%">
147
- ${outputSvgString}
148
- </svg>`
149
- }
150
-
151
- private async build() {
152
- // Create a SciChartSurface
153
- const { sciChartSurface, wasmContext } = await SciChartSurface.create(this.chart, {
154
- theme: appTheme.SciChartJsTheme
155
- })
156
-
157
- // Add an XAxis of type DateTimeAxis
158
- // Note for crypto data this is fine, but for stocks/forex you will need to use CategoryAxis which collapses gaps at weekends
159
- // In future we have a hybrid IndexDateAxis which 'magically' solves problems of different # of points in stock market datasetd with gaps
160
- const xAxis = new DateTimeNumericAxis(wasmContext, {
161
- // autoRange.never as we're setting visibleRange explicitly below. If you dont do this, leave this flag default
162
- autoRange: EAutoRange.Never
163
- })
164
- sciChartSurface.xAxes.add(xAxis)
165
-
166
- // Create a NumericAxis on the YAxis with 2 Decimal Places
167
- sciChartSurface.yAxes.add(
168
- new NumericAxis(wasmContext, {
169
- growBy: new NumberRange(0.1, 0.1),
170
- labelFormat: ENumericFormat.Decimal,
171
- labelPrecision: 2,
172
- labelPrefix: '$',
173
- autoRange: EAutoRange.Always
174
- })
175
- )
176
-
177
- // Create a secondary YAxis to host volume data on its own scale
178
- sciChartSurface.yAxes.add(
179
- new NumericAxis(wasmContext, {
180
- id: Y_AXIS_VOLUME_ID,
181
- growBy: new NumberRange(0, 4),
182
- isVisible: false,
183
- autoRange: EAutoRange.Always
184
- })
185
- )
186
-
187
- // Fetch data from now to 300 1hr candles ago
188
- const endDate = new Date(Date.now())
189
- const startDate = new Date()
190
- startDate.setHours(endDate.getHours() - 300)
191
- const priceBars = await simpleBinanceRestClient.getCandles('BTCUSDT', '1h', startDate, endDate)
192
-
193
- // Maps PriceBar { date, open, high, low, close, volume } to structure-of-arrays expected by scichart
194
- const xValues: number[] = []
195
- const openValues: number[] = []
196
- const highValues: number[] = []
197
- const lowValues: number[] = []
198
- const closeValues: number[] = []
199
- const volumeValues: number[] = []
200
- priceBars.forEach((priceBar: any) => {
201
- xValues.push(priceBar.date)
202
- openValues.push(priceBar.open)
203
- highValues.push(priceBar.high)
204
- lowValues.push(priceBar.low)
205
- closeValues.push(priceBar.close)
206
- volumeValues.push(priceBar.volume)
207
- })
208
-
209
- // Zoom to the latest 100 candles
210
- const startViewportRange = new Date()
211
- startViewportRange.setHours(startDate.getHours() - 100)
212
- xAxis.visibleRange = new NumberRange(startViewportRange.getTime() / 1000, endDate.getTime() / 1000)
213
-
214
- // Create and add the Candlestick series
215
- // The Candlestick Series requires a special dataseries type called OhlcDataSeries with o,h,l,c and date values
216
- const candleDataSeries = new OhlcDataSeries(wasmContext, {
217
- xValues,
218
- openValues,
219
- highValues,
220
- lowValues,
221
- closeValues,
222
- dataSeriesName: 'BTC/USDT'
223
- })
224
- const candlestickSeries = new FastCandlestickRenderableSeries(wasmContext, {
225
- dataSeries: candleDataSeries,
226
- stroke: appTheme.ForegroundColor, // used by cursorModifier below
227
- strokeThickness: 1,
228
- brushUp: appTheme.VividGreen + '77',
229
- brushDown: appTheme.MutedRed + '77',
230
- strokeUp: appTheme.VividGreen,
231
- strokeDown: appTheme.MutedRed
232
- })
233
- sciChartSurface.renderableSeries.add(candlestickSeries)
234
-
235
- // Add an Ohlcseries. this will be invisible to begin with
236
- const ohlcSeries = new FastOhlcRenderableSeries(wasmContext, {
237
- dataSeries: candleDataSeries,
238
- stroke: appTheme.ForegroundColor, // used by cursorModifier below
239
- strokeThickness: 1,
240
- dataPointWidth: 0.9,
241
- strokeUp: appTheme.VividGreen,
242
- strokeDown: appTheme.MutedRed,
243
- isVisible: false
244
- })
245
- sciChartSurface.renderableSeries.add(ohlcSeries)
246
-
247
- // Add some moving averages using SciChart's filters/transforms API
248
- // when candleDataSeries updates, XyMovingAverageFilter automatically recomputes
249
- sciChartSurface.renderableSeries.add(
250
- new FastLineRenderableSeries(wasmContext, {
251
- dataSeries: new XyMovingAverageFilter(candleDataSeries, {
252
- dataSeriesName: 'Moving Average (20)',
253
- length: 20
254
- }),
255
- stroke: appTheme.VividSkyBlue
256
- })
257
- )
258
-
259
- sciChartSurface.renderableSeries.add(
260
- new FastLineRenderableSeries(wasmContext, {
261
- dataSeries: new XyMovingAverageFilter(candleDataSeries, {
262
- dataSeriesName: 'Moving Average (50)',
263
- length: 50
264
- }),
265
- stroke: appTheme.VividPink
266
- })
267
- )
268
-
269
- // Add volume data onto the chart
270
- sciChartSurface.renderableSeries.add(
271
- new FastColumnRenderableSeries(wasmContext, {
272
- dataSeries: new XyDataSeries(wasmContext, { xValues, yValues: volumeValues, dataSeriesName: 'Volume' }),
273
- strokeThickness: 0,
274
- // This is how we get volume to scale - on a hidden YAxis
275
- yAxisId: Y_AXIS_VOLUME_ID,
276
- // This is how we colour volume bars red or green
277
- paletteProvider: new VolumePaletteProvider(
278
- candleDataSeries,
279
- appTheme.VividGreen + '77',
280
- appTheme.MutedRed + '77'
281
- )
282
- })
283
- )
284
-
285
- // Optional: Add some interactivity modifiers
286
- sciChartSurface.chartModifiers.add(
287
- new ZoomExtentsModifier(),
288
- new ZoomPanModifier(),
289
- new MouseWheelZoomModifier(),
290
- new CursorModifier({
291
- crosshairStroke: appTheme.VividOrange,
292
- axisLabelFill: appTheme.VividOrange,
293
- tooltipLegendTemplate: this.getTooltipLegendTemplate
294
- })
295
- )
296
-
297
- // Add Overview chart. This will automatically bind to the parent surface
298
- // displaying its series. Zooming the chart will zoom the overview and vice versa
299
- const overview = await SciChartOverview.create(sciChartSurface, this.overview, {
300
- theme: appTheme.SciChartJsTheme,
301
- transformRenderableSeries: this.getOverviewSeries as any
302
- })
303
-
304
- return { sciChartSurface, overview, candlestickSeries, ohlcSeries }
305
- }
306
- }
@@ -1,41 +0,0 @@
1
- import {
2
- OhlcDataSeries,
3
- IRenderableSeries,
4
- EFillPaletteMode,
5
- IFillPaletteProvider,
6
- IPointMetadata,
7
- parseColorToUIntArgb
8
- } from 'scichart'
9
-
10
- export class VolumePaletteProvider implements IFillPaletteProvider {
11
- fillPaletteMode: EFillPaletteMode = EFillPaletteMode.SOLID
12
- private ohlcDataSeries: OhlcDataSeries
13
- private upColorArgb: number
14
- private downColorArgb: number
15
-
16
- constructor(masterData: OhlcDataSeries, upColor: string, downColor: string) {
17
- this.upColorArgb = parseColorToUIntArgb(upColor)
18
- this.downColorArgb = parseColorToUIntArgb(downColor)
19
- this.ohlcDataSeries = masterData
20
- }
21
- onAttached(parentSeries: IRenderableSeries): void {}
22
- onDetached(): void {}
23
-
24
- // Return up or down color for the volume bars depending on Ohlc data
25
- overrideFillArgb(xValue: number, yValue: number, index: number, opacity?: number, metadata?: IPointMetadata): number {
26
- const isUpCandle =
27
- this.ohlcDataSeries.getNativeOpenValues().get(index) >= this.ohlcDataSeries.getNativeCloseValues().get(index)
28
- return isUpCandle ? this.upColorArgb : this.downColorArgb
29
- }
30
-
31
- // Override stroke as well, even though strokethickness is 0, because stroke is used if column thickness goes to 0.
32
- overrideStrokeArgb(
33
- xValue: number,
34
- yValue: number,
35
- index: number,
36
- opacity?: number,
37
- metadata?: IPointMetadata
38
- ): number {
39
- return this.overrideFillArgb(xValue, yValue, index, opacity, metadata)
40
- }
41
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * Defines a price bar with Open, High, Low, Close and Date encoded as number
3
- */
4
- export type TPriceBar = {
5
- date: number
6
- open: number
7
- high: number
8
- low: number
9
- close: number
10
- volume: number
11
- }
12
-
13
- /**
14
- * Parses JSON candles into TPriceBar array
15
- * @param candles
16
- */
17
- const parseCandles = (candles: any[]): TPriceBar[] => {
18
- const priceBars: TPriceBar[] = []
19
-
20
- candles.forEach((candle: any) => {
21
- const [timestamp, open, high, low, close, volume] = candle
22
- const openValue = parseFloat(open)
23
- const highValue = parseFloat(high)
24
- const lowValue = parseFloat(low)
25
- const closeValue = parseFloat(close)
26
- const volumeValue = parseFloat(volume)
27
-
28
- priceBars.push({
29
- date: timestamp / 1000,
30
- open: openValue,
31
- high: highValue,
32
- low: lowValue,
33
- close: closeValue,
34
- volume: volumeValue
35
- })
36
- })
37
-
38
- return priceBars
39
- }
40
-
41
- /**
42
- * Fetches candles from Binance Rest API
43
- */
44
- const getCandles = async (
45
- symbol: string,
46
- interval: string,
47
- startTime?: Date,
48
- endTime?: Date,
49
- limit: number = 500
50
- ): Promise<TPriceBar[]> => {
51
- let url = `https://api.binance.us/api/v3/klines?symbol=${symbol}&interval=${interval}`
52
- if (startTime) {
53
- url += `&startTime=${startTime.getTime()}`
54
- }
55
- if (endTime) {
56
- url += `&endTime=${endTime.getTime()}`
57
- }
58
- if (limit) {
59
- url += `&limit=${limit}`
60
- }
61
- try {
62
- console.log(`SimpleBinanceClient: Fetching ${symbol} ${interval} from ${startTime} to ${endTime}`)
63
- const response = await fetch(url)
64
- const data = await response.json()
65
- return parseCandles(data)
66
- } catch (err) {
67
- console.error(err)
68
- return []
69
- }
70
- }
71
-
72
- export const simpleBinanceRestClient = {
73
- getCandles
74
- }
@@ -1,60 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- const NATURE = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'select',
12
- label: 'series',
13
- name: 'series',
14
- property: {
15
- options: ['', 'candle-stick', 'ohlc']
16
- }
17
- }
18
- ]
19
- }
20
-
21
- import './charts/sci-candle-stick-chart'
22
- import { Component, HTMLOverlayContainer, Properties, ComponentNature, error } from '@hatiolab/things-scene'
23
-
24
- import { SciCandleStockChart } from './charts/sci-candle-stick-chart'
25
-
26
- export default class ScichartCandleStick extends HTMLOverlayContainer {
27
- static get nature(): ComponentNature {
28
- return NATURE
29
- }
30
-
31
- dispose() {
32
- super.dispose()
33
- }
34
-
35
- /*
36
- * 컴포넌트의 생성 또는 속성 변화 시에 호출되며,
37
- * 그에 따른 html element의 반영이 필요한 부분을 구현한다.
38
- *
39
- * ThingsComponent state => HTML element properties
40
- */
41
- setElementProperties(chart: SciCandleStockChart) {
42
- const { series = 'candle-stick' } = this.state
43
-
44
- chart.seriesType = series
45
- }
46
-
47
- /*
48
- * 컴포넌트가 ready 상태가 되거나, 컴포넌트의 속성이 변화될 시 setElementProperties 뒤에 호출된다.
49
- * 변화에 따른 기본적인 html 속성이 super.reposition()에서 진행되고, 그 밖의 작업이 필요할 때, 오버라이드 한다.
50
- */
51
- reposition() {
52
- super.reposition()
53
- }
54
-
55
- get tagName() {
56
- return 'sci-candle-stock-chart'
57
- }
58
- }
59
-
60
- Component.register('scichart-candle-stick', ScichartCandleStick)