@oanda/labs-instruments-price-chart-widget 1.0.1

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 (150) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +18 -0
  3. package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +40 -0
  4. package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
  5. package/dist/main/InstrumentsPriceChartWidget/Main.js +52 -0
  6. package/dist/main/InstrumentsPriceChartWidget/Main.js.map +1 -0
  7. package/dist/main/InstrumentsPriceChartWidget/components/Chart.js +39 -0
  8. package/dist/main/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
  9. package/dist/main/InstrumentsPriceChartWidget/components/constants.js +12 -0
  10. package/dist/main/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
  11. package/dist/main/InstrumentsPriceChartWidget/components/formatters.js +15 -0
  12. package/dist/main/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
  13. package/dist/main/InstrumentsPriceChartWidget/components/getOption.js +119 -0
  14. package/dist/main/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
  15. package/dist/main/InstrumentsPriceChartWidget/components/types.js +6 -0
  16. package/dist/main/InstrumentsPriceChartWidget/components/types.js.map +1 -0
  17. package/dist/main/InstrumentsPriceChartWidget/config.js +44 -0
  18. package/dist/main/InstrumentsPriceChartWidget/config.js.map +1 -0
  19. package/dist/main/InstrumentsPriceChartWidget/index.js +28 -0
  20. package/dist/main/InstrumentsPriceChartWidget/index.js.map +1 -0
  21. package/dist/main/InstrumentsPriceChartWidget/render.js +42 -0
  22. package/dist/main/InstrumentsPriceChartWidget/render.js.map +1 -0
  23. package/dist/main/InstrumentsPriceChartWidget/types.js +16 -0
  24. package/dist/main/InstrumentsPriceChartWidget/types.js.map +1 -0
  25. package/dist/main/gql/mock/getPriceCandles.js +30 -0
  26. package/dist/main/gql/mock/getPriceCandles.js.map +1 -0
  27. package/dist/main/gql/mock/handlers.js +62 -0
  28. package/dist/main/gql/mock/handlers.js.map +1 -0
  29. package/dist/main/gql/mock/schema.graphqls +59 -0
  30. package/dist/main/gql/types/fragment-masking.js +23 -0
  31. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  32. package/dist/main/gql/types/gql.js +17 -0
  33. package/dist/main/gql/types/gql.js.map +1 -0
  34. package/dist/main/gql/types/graphql.js +438 -0
  35. package/dist/main/gql/types/graphql.js.map +1 -0
  36. package/dist/main/gql/types/index.js +28 -0
  37. package/dist/main/gql/types/index.js.map +1 -0
  38. package/dist/main/gql/validateInstruments.js +16 -0
  39. package/dist/main/gql/validateInstruments.js.map +1 -0
  40. package/dist/main/index.js +17 -0
  41. package/dist/main/index.js.map +1 -0
  42. package/dist/main/translations/index.js +27 -0
  43. package/dist/main/translations/index.js.map +1 -0
  44. package/dist/main/translations/sources/en.json +2 -0
  45. package/dist/main/translations/sources/es.json +2 -0
  46. package/dist/main/translations/sources/th.json +2 -0
  47. package/dist/main/translations/sources/zh_TW.json +2 -0
  48. package/dist/main/translations/translations.js +8 -0
  49. package/dist/main/translations/translations.js.map +1 -0
  50. package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +33 -0
  51. package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
  52. package/dist/module/InstrumentsPriceChartWidget/Main.js +44 -0
  53. package/dist/module/InstrumentsPriceChartWidget/Main.js.map +1 -0
  54. package/dist/module/InstrumentsPriceChartWidget/components/Chart.js +29 -0
  55. package/dist/module/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
  56. package/dist/module/InstrumentsPriceChartWidget/components/constants.js +6 -0
  57. package/dist/module/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
  58. package/dist/module/InstrumentsPriceChartWidget/components/formatters.js +8 -0
  59. package/dist/module/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
  60. package/dist/module/InstrumentsPriceChartWidget/components/getOption.js +112 -0
  61. package/dist/module/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
  62. package/dist/module/InstrumentsPriceChartWidget/components/types.js +2 -0
  63. package/dist/module/InstrumentsPriceChartWidget/components/types.js.map +1 -0
  64. package/dist/module/InstrumentsPriceChartWidget/config.js +39 -0
  65. package/dist/module/InstrumentsPriceChartWidget/config.js.map +1 -0
  66. package/dist/module/InstrumentsPriceChartWidget/index.js +3 -0
  67. package/dist/module/InstrumentsPriceChartWidget/index.js.map +1 -0
  68. package/dist/module/InstrumentsPriceChartWidget/render.js +39 -0
  69. package/dist/module/InstrumentsPriceChartWidget/render.js.map +1 -0
  70. package/dist/module/InstrumentsPriceChartWidget/types.js +10 -0
  71. package/dist/module/InstrumentsPriceChartWidget/types.js.map +1 -0
  72. package/dist/module/gql/mock/getPriceCandles.js +25 -0
  73. package/dist/module/gql/mock/getPriceCandles.js.map +1 -0
  74. package/dist/module/gql/mock/handlers.js +56 -0
  75. package/dist/module/gql/mock/handlers.js.map +1 -0
  76. package/dist/module/gql/mock/schema.graphqls +59 -0
  77. package/dist/module/gql/types/fragment-masking.js +15 -0
  78. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  79. package/dist/module/gql/types/gql.js +9 -0
  80. package/dist/module/gql/types/gql.js.map +1 -0
  81. package/dist/module/gql/types/graphql.js +432 -0
  82. package/dist/module/gql/types/graphql.js.map +1 -0
  83. package/dist/module/gql/types/index.js +3 -0
  84. package/dist/module/gql/types/index.js.map +1 -0
  85. package/dist/module/gql/validateInstruments.js +10 -0
  86. package/dist/module/gql/validateInstruments.js.map +1 -0
  87. package/dist/module/index.js +2 -0
  88. package/dist/module/index.js.map +1 -0
  89. package/dist/module/translations/index.js +20 -0
  90. package/dist/module/translations/index.js.map +1 -0
  91. package/dist/module/translations/sources/en.json +2 -0
  92. package/dist/module/translations/sources/es.json +2 -0
  93. package/dist/module/translations/sources/th.json +2 -0
  94. package/dist/module/translations/sources/zh_TW.json +2 -0
  95. package/dist/module/translations/translations.js +2 -0
  96. package/dist/module/translations/translations.js.map +1 -0
  97. package/dist/types/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.d.ts +4 -0
  98. package/dist/types/InstrumentsPriceChartWidget/Main.d.ts +4 -0
  99. package/dist/types/InstrumentsPriceChartWidget/components/Chart.d.ts +3 -0
  100. package/dist/types/InstrumentsPriceChartWidget/components/constants.d.ts +5 -0
  101. package/dist/types/InstrumentsPriceChartWidget/components/formatters.d.ts +1 -0
  102. package/dist/types/InstrumentsPriceChartWidget/components/getOption.d.ts +2 -0
  103. package/dist/types/InstrumentsPriceChartWidget/components/types.d.ts +14 -0
  104. package/dist/types/InstrumentsPriceChartWidget/config.d.ts +10 -0
  105. package/dist/types/InstrumentsPriceChartWidget/index.d.ts +2 -0
  106. package/dist/types/InstrumentsPriceChartWidget/render.d.ts +1 -0
  107. package/dist/types/InstrumentsPriceChartWidget/types.d.ts +15 -0
  108. package/dist/types/gql/mock/getPriceCandles.d.ts +2 -0
  109. package/dist/types/gql/mock/handlers.d.ts +1 -0
  110. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  111. package/dist/types/gql/types/gql.d.ts +47 -0
  112. package/dist/types/gql/types/graphql.d.ts +468 -0
  113. package/dist/types/gql/types/index.d.ts +2 -0
  114. package/dist/types/gql/validateInstruments.d.ts +1 -0
  115. package/dist/types/index.d.ts +1 -0
  116. package/dist/types/translations/index.d.ts +4 -0
  117. package/dist/types/translations/translations.d.ts +1 -0
  118. package/index.ts +1 -0
  119. package/lokalise.config.json +18 -0
  120. package/package.json +24 -0
  121. package/src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx +40 -0
  122. package/src/InstrumentsPriceChartWidget/Main.tsx +59 -0
  123. package/src/InstrumentsPriceChartWidget/components/Chart.tsx +47 -0
  124. package/src/InstrumentsPriceChartWidget/components/constants.ts +5 -0
  125. package/src/InstrumentsPriceChartWidget/components/formatters.ts +7 -0
  126. package/src/InstrumentsPriceChartWidget/components/getOption.ts +127 -0
  127. package/src/InstrumentsPriceChartWidget/components/types.ts +19 -0
  128. package/src/InstrumentsPriceChartWidget/config.ts +47 -0
  129. package/src/InstrumentsPriceChartWidget/index.ts +2 -0
  130. package/src/InstrumentsPriceChartWidget/render.tsx +52 -0
  131. package/src/InstrumentsPriceChartWidget/types.ts +20 -0
  132. package/src/gql/mock/getPriceCandles.ts +26 -0
  133. package/src/gql/mock/handlers.ts +66 -0
  134. package/src/gql/mock/schema.graphqls +59 -0
  135. package/src/gql/types/fragment-masking.ts +86 -0
  136. package/src/gql/types/gql.ts +54 -0
  137. package/src/gql/types/graphql.ts +723 -0
  138. package/src/gql/types/index.ts +2 -0
  139. package/src/gql/validateInstruments.ts +10 -0
  140. package/src/index.ts +1 -0
  141. package/src/translations/index.ts +17 -0
  142. package/src/translations/sources/en.json +2 -0
  143. package/src/translations/sources/es.json +2 -0
  144. package/src/translations/sources/th.json +2 -0
  145. package/src/translations/sources/zh_TW.json +2 -0
  146. package/src/translations/translations.ts +1 -0
  147. package/test/Main.test.tsx +26 -0
  148. package/test/mocks/chartMock.ts +52 -0
  149. package/test/mocks/index.ts +1 -0
  150. package/tsconfig.types.json +12 -0
@@ -0,0 +1,468 @@
1
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ export type MakeEmpty<T extends {
16
+ [key: string]: unknown;
17
+ }, K extends keyof T> = {
18
+ [_ in K]?: never;
19
+ };
20
+ export type Incremental<T> = T | {
21
+ [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
22
+ };
23
+ /** All built-in and custom scalars, mapped to their actual values */
24
+ export type Scalars = {
25
+ ID: {
26
+ input: string;
27
+ output: string;
28
+ };
29
+ String: {
30
+ input: string;
31
+ output: string;
32
+ };
33
+ Boolean: {
34
+ input: boolean;
35
+ output: boolean;
36
+ };
37
+ Int: {
38
+ input: number;
39
+ output: number;
40
+ };
41
+ Float: {
42
+ input: number;
43
+ output: number;
44
+ };
45
+ };
46
+ export type AssetClass = {
47
+ __typename?: 'AssetClass';
48
+ instruments: Array<Instrument>;
49
+ name: Scalars['String']['output'];
50
+ };
51
+ export declare enum AssetClassName {
52
+ Commodities = "COMMODITIES",
53
+ Cryptocurrency = "CRYPTOCURRENCY",
54
+ Currency = "CURRENCY",
55
+ EquityShares = "EQUITY_SHARES",
56
+ Etfs = "ETFS",
57
+ Indices = "INDICES",
58
+ Rates = "RATES"
59
+ }
60
+ export declare enum BookType {
61
+ Order = "ORDER",
62
+ Position = "POSITION"
63
+ }
64
+ export type Candle = {
65
+ __typename?: 'Candle';
66
+ high: Scalars['Float']['output'];
67
+ };
68
+ export type CandlesData = {
69
+ __typename?: 'CandlesData';
70
+ candle: Candle;
71
+ time: Scalars['String']['output'];
72
+ timeSpan: TimeSpan;
73
+ unixTime: Scalars['Int']['output'];
74
+ };
75
+ export type CorrelationHeatmap = {
76
+ __typename?: 'CorrelationHeatmap';
77
+ baseInstrument: Instrument;
78
+ heatmap: Array<Heatmap>;
79
+ };
80
+ export type CorrelationMatrix = {
81
+ __typename?: 'CorrelationMatrix';
82
+ baseTimeUnit: CorrelationTimeUnit;
83
+ matrix: Array<Matrix>;
84
+ };
85
+ export declare enum CorrelationTimeUnit {
86
+ H1 = "H1",
87
+ H4 = "H4",
88
+ H24 = "H24",
89
+ M1 = "M1",
90
+ M3 = "M3",
91
+ M6 = "M6",
92
+ W1 = "W1",
93
+ Y1 = "Y1"
94
+ }
95
+ export declare enum CurrencyName {
96
+ Aud = "AUD",
97
+ Cad = "CAD",
98
+ Chf = "CHF",
99
+ Eur = "EUR",
100
+ Gbp = "GBP",
101
+ Jpy = "JPY",
102
+ Nzd = "NZD",
103
+ Usd = "USD"
104
+ }
105
+ export type CurrencyPower = {
106
+ __typename?: 'CurrencyPower';
107
+ /** UTC Timestamp */
108
+ point: Scalars['String']['output'];
109
+ price: Scalars['Float']['output'];
110
+ };
111
+ export type CurrencyPowerBalance = {
112
+ __typename?: 'CurrencyPowerBalance';
113
+ currency: CurrencyName;
114
+ power: Array<CurrencyPower>;
115
+ updatedAt: Scalars['String']['output'];
116
+ };
117
+ export declare enum CurrencyPowerBalanceTimeUnit {
118
+ CurrentDay = "CURRENT_DAY",
119
+ H4 = "H4",
120
+ H8 = "H8",
121
+ H24 = "H24",
122
+ M1 = "M1",
123
+ M3 = "M3",
124
+ PreviousDay = "PREVIOUS_DAY",
125
+ W1 = "W1"
126
+ }
127
+ export type CurrencyStrength = {
128
+ __typename?: 'CurrencyStrength';
129
+ currency: CurrencyName;
130
+ strengthRelation?: Maybe<Array<StrengthRelation>>;
131
+ updatedAt: Scalars['String']['output'];
132
+ };
133
+ export declare enum DataSource {
134
+ Ny4 = "NY4",
135
+ Ty3 = "TY3"
136
+ }
137
+ export declare enum Division {
138
+ Oap = "OAP",
139
+ Oau = "OAU",
140
+ Oc = "OC",
141
+ Ocan = "OCAN",
142
+ Oel = "OEL",
143
+ Ogm = "OGM",
144
+ Oj = "OJ",
145
+ Opt = "OPT",
146
+ Otms = "OTMS"
147
+ }
148
+ export declare enum Granularity {
149
+ Day_1 = "DAY_1",
150
+ Hour_1 = "HOUR_1",
151
+ Hour_4 = "HOUR_4",
152
+ Minute_5 = "MINUTE_5",
153
+ Minute_15 = "MINUTE_15",
154
+ Minute_30 = "MINUTE_30"
155
+ }
156
+ export type Heatmap = {
157
+ __typename?: 'Heatmap';
158
+ instrument: Instrument;
159
+ timeCorrelation: Array<TimeCorrelation>;
160
+ };
161
+ export type Instrument = {
162
+ __typename?: 'Instrument';
163
+ displayName: Scalars['String']['output'];
164
+ name: Scalars['String']['output'];
165
+ };
166
+ export type InstrumentCorrelation = {
167
+ __typename?: 'InstrumentCorrelation';
168
+ instrument: Instrument;
169
+ value?: Maybe<Scalars['Float']['output']>;
170
+ };
171
+ export declare enum InstrumentDataSource {
172
+ Mt5 = "MT5",
173
+ V20 = "V20"
174
+ }
175
+ export type InstrumentTableResult = {
176
+ __typename?: 'InstrumentTableResult';
177
+ instruments: Array<Instrument>;
178
+ totalCount: Scalars['Int']['output'];
179
+ };
180
+ export type Matrix = {
181
+ __typename?: 'Matrix';
182
+ instrument: Instrument;
183
+ instrumentCorrelation: Array<InstrumentCorrelation>;
184
+ };
185
+ export type OrderPositionBucket = {
186
+ __typename?: 'OrderPositionBucket';
187
+ longCountPercent: Scalars['Float']['output'];
188
+ price: Scalars['Float']['output'];
189
+ shortCountPercent: Scalars['Float']['output'];
190
+ };
191
+ export type OrderPositionData = {
192
+ __typename?: 'OrderPositionData';
193
+ bucketWidth: Scalars['Float']['output'];
194
+ buckets: Array<Maybe<OrderPositionBucket>>;
195
+ dataSource?: Maybe<Scalars['String']['output']>;
196
+ instrument: Scalars['String']['output'];
197
+ price?: Maybe<Scalars['Float']['output']>;
198
+ region?: Maybe<Scalars['String']['output']>;
199
+ time: Scalars['String']['output'];
200
+ unixTime: Scalars['Int']['output'];
201
+ };
202
+ export type Query = {
203
+ __typename?: 'Query';
204
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
205
+ correlationHeatmap: CorrelationHeatmap;
206
+ correlationMatrix: CorrelationMatrix;
207
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
208
+ currencyStrength?: Maybe<Array<CurrencyStrength>>;
209
+ getPriceCandles: Array<CandlesData>;
210
+ isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
211
+ mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
212
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
213
+ resolveInstrumentsByDivision?: Maybe<Array<Instrument>>;
214
+ resolveInstrumentsWithFilters?: Maybe<InstrumentTableResult>;
215
+ sentiment?: Maybe<Array<SentimentInstrument>>;
216
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
217
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
218
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
219
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
220
+ valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
221
+ valueAtRiskChart?: Maybe<ValueAtRiskChart>;
222
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
223
+ volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
224
+ };
225
+ export type QueryAssetClassesArgs = {
226
+ division: Division;
227
+ };
228
+ export type QueryCorrelationHeatmapArgs = {
229
+ division: Division;
230
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
231
+ timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
232
+ };
233
+ export type QueryCorrelationMatrixArgs = {
234
+ division: Division;
235
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
236
+ };
237
+ export type QueryCurrencyPowerBalanceArgs = {
238
+ timeUnit: CurrencyPowerBalanceTimeUnit;
239
+ };
240
+ export type QueryGetPriceCandlesArgs = {
241
+ division?: InputMaybe<Division>;
242
+ granularity: Granularity;
243
+ instrument: Scalars['String']['input'];
244
+ timeSpan: TimeSpan;
245
+ };
246
+ export type QueryIsAllowedPartnerArgs = {
247
+ url: Scalars['String']['input'];
248
+ };
249
+ export type QueryMapInstrumentNamesArgs = {
250
+ division?: InputMaybe<Division>;
251
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
252
+ };
253
+ export type QueryOrderPositionBooksArgs = {
254
+ bookType: BookType;
255
+ dataSource?: InputMaybe<DataSource>;
256
+ instrument: Scalars['String']['input'];
257
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
258
+ region?: InputMaybe<Region>;
259
+ };
260
+ export type QueryResolveInstrumentsByDivisionArgs = {
261
+ division: Division;
262
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
263
+ };
264
+ export type QueryResolveInstrumentsWithFiltersArgs = {
265
+ assetClass?: InputMaybe<Array<InputMaybe<AssetClassName>>>;
266
+ count?: InputMaybe<Scalars['Int']['input']>;
267
+ dataSource?: InputMaybe<InstrumentDataSource>;
268
+ division: Division;
269
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
270
+ offset?: InputMaybe<Scalars['Int']['input']>;
271
+ searchPattern?: InputMaybe<Scalars['String']['input']>;
272
+ };
273
+ export type QuerySentimentArgs = {
274
+ division?: InputMaybe<Division>;
275
+ name: Scalars['String']['input'];
276
+ };
277
+ export type QuerySentimentListArgs = {
278
+ division?: InputMaybe<Division>;
279
+ sort?: InputMaybe<Sort>;
280
+ };
281
+ export type QueryTopicalInstrumentsArgs = {
282
+ assetClass?: InputMaybe<AssetClassName>;
283
+ count?: InputMaybe<Scalars['Int']['input']>;
284
+ division?: InputMaybe<Division>;
285
+ offset?: InputMaybe<Scalars['Int']['input']>;
286
+ sort: TopicalSort;
287
+ };
288
+ export type QueryTopicalInstrumentsChartsArgs = {
289
+ division?: InputMaybe<Division>;
290
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
291
+ };
292
+ export type QueryTopicalInstrumentsTotalCountArgs = {
293
+ assetClass?: InputMaybe<AssetClassName>;
294
+ division?: InputMaybe<Division>;
295
+ sort: TopicalSort;
296
+ };
297
+ export type QueryValueAtRiskAssetClassesArgs = {
298
+ division?: InputMaybe<Division>;
299
+ };
300
+ export type QueryValueAtRiskChartArgs = {
301
+ bars: ValueAtRiskBars;
302
+ division?: InputMaybe<Division>;
303
+ duration: ValueAtRiskDuration;
304
+ instrument: Scalars['String']['input'];
305
+ };
306
+ export type QueryVolatilityChartArgs = {
307
+ division?: InputMaybe<Division>;
308
+ instrument: Scalars['String']['input'];
309
+ timeSpan: VolatilityChartTimeSpan;
310
+ timeUnit: VolatilityChartTimeUnit;
311
+ };
312
+ export type QueryVolatilityChartAssetClassesArgs = {
313
+ division?: InputMaybe<Division>;
314
+ };
315
+ export declare enum Region {
316
+ Amer = "AMER",
317
+ Apac = "APAC",
318
+ Emea = "EMEA"
319
+ }
320
+ export type Sentiment = {
321
+ __typename?: 'Sentiment';
322
+ longPercent: Scalars['Float']['output'];
323
+ shortPercent: Scalars['Float']['output'];
324
+ };
325
+ export type SentimentInstrument = {
326
+ __typename?: 'SentimentInstrument';
327
+ displayName: Scalars['String']['output'];
328
+ name: Scalars['String']['output'];
329
+ sentiment: Sentiment;
330
+ updatedAt: Scalars['String']['output'];
331
+ };
332
+ export declare enum Sort {
333
+ Bearish = "BEARISH",
334
+ Bullish = "BULLISH"
335
+ }
336
+ export type StrengthRelation = {
337
+ __typename?: 'StrengthRelation';
338
+ currency: CurrencyName;
339
+ percentage: Scalars['Float']['output'];
340
+ };
341
+ export type TimeCorrelation = {
342
+ __typename?: 'TimeCorrelation';
343
+ timeUnit: CorrelationTimeUnit;
344
+ value?: Maybe<Scalars['Float']['output']>;
345
+ };
346
+ export declare enum TimeSpan {
347
+ Day_1 = "DAY_1",
348
+ Day_2 = "DAY_2",
349
+ Hour_1 = "HOUR_1",
350
+ Hour_12 = "HOUR_12",
351
+ Month_1 = "MONTH_1",
352
+ Month_3 = "MONTH_3",
353
+ Month_6 = "MONTH_6",
354
+ Week_1 = "WEEK_1",
355
+ Week_2 = "WEEK_2",
356
+ Week_3 = "WEEK_3",
357
+ Year_1 = "YEAR_1"
358
+ }
359
+ export type TopicalInstrument = {
360
+ __typename?: 'TopicalInstrument';
361
+ assetClass?: Maybe<AssetClassName>;
362
+ displayName: Scalars['String']['output'];
363
+ name: Scalars['String']['output'];
364
+ sentiment: Sentiment;
365
+ updatedAt: Scalars['String']['output'];
366
+ };
367
+ export type TopicalInstrumentChart = {
368
+ __typename?: 'TopicalInstrumentChart';
369
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
370
+ name: Scalars['String']['output'];
371
+ };
372
+ export declare enum TopicalSort {
373
+ Bearish = "BEARISH",
374
+ Bullish = "BULLISH",
375
+ Hot = "HOT",
376
+ Popular = "POPULAR",
377
+ Volatile = "VOLATILE"
378
+ }
379
+ export declare enum ValueAtRiskBars {
380
+ C100 = "C100",
381
+ C200 = "C200",
382
+ C300 = "C300"
383
+ }
384
+ export type ValueAtRiskChart = {
385
+ __typename?: 'ValueAtRiskChart';
386
+ down: ValueAtRiskChartData;
387
+ up: ValueAtRiskChartData;
388
+ };
389
+ export type ValueAtRiskChartData = {
390
+ __typename?: 'ValueAtRiskChartData';
391
+ average: Scalars['Float']['output'];
392
+ max: Scalars['Float']['output'];
393
+ median: Scalars['Float']['output'];
394
+ points?: Maybe<Array<ValueAtRiskChartPoint>>;
395
+ threshold: Scalars['Float']['output'];
396
+ };
397
+ export type ValueAtRiskChartPoint = {
398
+ __typename?: 'ValueAtRiskChartPoint';
399
+ percent: Scalars['Float']['output'];
400
+ pips: Scalars['Float']['output'];
401
+ };
402
+ export declare enum ValueAtRiskDuration {
403
+ C1 = "C1",
404
+ C2 = "C2",
405
+ C3 = "C3",
406
+ C4 = "C4",
407
+ C5 = "C5",
408
+ C10 = "C10"
409
+ }
410
+ export type VolatilityChart = {
411
+ __typename?: 'VolatilityChart';
412
+ pips: Scalars['Float']['output'];
413
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
414
+ point: Scalars['String']['output'];
415
+ updatedAt: Scalars['String']['output'];
416
+ };
417
+ export declare enum VolatilityChartTimeSpan {
418
+ /** Valid for: H */
419
+ D5 = "D5",
420
+ /** Valid for: H */
421
+ D10 = "D10",
422
+ /** Valid for: D */
423
+ M1 = "M1",
424
+ /** Valid for: D */
425
+ M3 = "M3",
426
+ /** Valid for: W */
427
+ W5 = "W5",
428
+ /** Valid for: W */
429
+ W10 = "W10"
430
+ }
431
+ export declare enum VolatilityChartTimeUnit {
432
+ D = "D",
433
+ H = "H",
434
+ W = "W"
435
+ }
436
+ export type GetPriceCandlesQueryVariables = Exact<{
437
+ division?: InputMaybe<Division>;
438
+ instrument: Scalars['String']['input'];
439
+ granularity: Granularity;
440
+ timeSpan: TimeSpan;
441
+ }>;
442
+ export type GetPriceCandlesQuery = {
443
+ __typename?: 'Query';
444
+ getPriceCandles: Array<{
445
+ __typename?: 'CandlesData';
446
+ time: string;
447
+ unixTime: number;
448
+ timeSpan: TimeSpan;
449
+ candle: {
450
+ __typename?: 'Candle';
451
+ high: number;
452
+ };
453
+ }>;
454
+ };
455
+ export type ValidateInstrumentsQueryVariables = Exact<{
456
+ instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
457
+ division?: InputMaybe<Division>;
458
+ }>;
459
+ export type ValidateInstrumentsQuery = {
460
+ __typename?: 'Query';
461
+ mapInstrumentNames?: Array<{
462
+ __typename?: 'Instrument';
463
+ name: string;
464
+ displayName: string;
465
+ } | null> | null;
466
+ };
467
+ export declare const GetPriceCandlesDocument: DocumentNode<GetPriceCandlesQuery, GetPriceCandlesQueryVariables>;
468
+ export declare const ValidateInstrumentsDocument: DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
@@ -0,0 +1,2 @@
1
+ export * from './fragment-masking';
2
+ export * from './gql';
@@ -0,0 +1 @@
1
+ export declare const validateInstruments: import("@apollo/client").DocumentNode;
@@ -0,0 +1 @@
1
+ export * from './InstrumentsPriceChartWidget';
@@ -0,0 +1,4 @@
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import type { defaultTranslations } from './translations';
3
+ export type TranslationKey = keyof typeof defaultTranslations;
4
+ export declare const translations: Translations;
@@ -0,0 +1 @@
1
+ export declare const defaultTranslations: {};
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,18 @@
1
+ {
2
+ "projectId": "19607517615e88022ba782.45168463",
3
+ "outputDir": "src/translations/sources",
4
+ "esModuleTranslations": "src/translations/translations.ts",
5
+ "messagesFormat": "esModule",
6
+ "esModuleConstName": "defaultTranslations",
7
+ "includeEmptyTranslations": true,
8
+ "downloadOptions": {
9
+ "format": "json",
10
+ "add_newline_eof": true,
11
+ "placeholder_format": "i18n",
12
+ "indentation": "2sp",
13
+ "plural_format": "i18next",
14
+ "export_empty_as": "skip",
15
+ "include_tags": ["common_widgets"],
16
+ "filter_langs": ["en", "zh_TW", "es", "th"]
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@oanda/labs-instruments-price-chart-widget",
3
+ "version": "1.0.1",
4
+ "description": "Labs Instruments Price Chart Widget",
5
+ "main": "dist/main/index.js",
6
+ "module": "dist/module/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "scripts": {
9
+ "codegen": "graphql-codegen --config codegen.ts"
10
+ },
11
+ "keywords": [],
12
+ "author": "OANDA",
13
+ "license": "UNLICENSED",
14
+ "dependencies": {
15
+ "@oanda/labs-widget-common": "^1.0.205",
16
+ "@oanda/mono-i18n": "10.0.1",
17
+ "graphql": "16.8.1"
18
+ },
19
+ "devDependencies": {
20
+ "@graphql-codegen/cli": "5.0.0",
21
+ "@graphql-codegen/client-preset": "4.1.0"
22
+ },
23
+ "gitHead": "c3d9e64eb9cf5a50d714b8147501b7dfe7aa4aed"
24
+ }
@@ -0,0 +1,40 @@
1
+ import { ApolloClient, InMemoryCache } from '@apollo/client';
2
+ import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
3
+ import React from 'react';
4
+
5
+ import { translations } from '../translations';
6
+ import { Main } from './Main';
7
+ import type { InstrumentsPriceChartConfig } from './types';
8
+
9
+ const InstrumentsPriceChartWidget = ({
10
+ graphqlUrl,
11
+ locale,
12
+ theme,
13
+ isParamError,
14
+ logoLink,
15
+ division,
16
+ }: InstrumentsPriceChartConfig) => {
17
+ const client = new ApolloClient({
18
+ uri: graphqlUrl,
19
+ cache: new InMemoryCache(),
20
+ });
21
+
22
+ return (
23
+ <WidgetProvider
24
+ client={client}
25
+ locale={locale}
26
+ theme={theme}
27
+ translations={translations}
28
+ >
29
+ <WidgetWrapper
30
+ isParamError={isParamError}
31
+ linkArea="logo"
32
+ logoLink={logoLink}
33
+ >
34
+ <Main division={division} />
35
+ </WidgetWrapper>
36
+ </WidgetProvider>
37
+ );
38
+ };
39
+
40
+ export { InstrumentsPriceChartWidget };
@@ -0,0 +1,59 @@
1
+ import { useQuery } from '@apollo/client';
2
+ import {
3
+ Spinner,
4
+ SpinnerSize,
5
+ TimeUnitSwitch,
6
+ } from '@oanda/labs-widget-common';
7
+ import React, { useState } from 'react';
8
+
9
+ import { getPriceCandles } from '../gql/mock/getPriceCandles';
10
+ import { type GetPriceCandlesQuery } from '../gql/types/graphql';
11
+ import { Chart } from './components/Chart';
12
+ import { timeUnitConfig } from './config';
13
+ import { type MainProps, TimeSpanSubset } from './types';
14
+
15
+ const Main = ({ division }: MainProps) => {
16
+ const [selectedTimeUnit, setSelectedTimeUnit] = useState(
17
+ TimeSpanSubset.Day_1
18
+ );
19
+
20
+ const { loading, data, error } = useQuery<GetPriceCandlesQuery>(
21
+ getPriceCandles,
22
+ {
23
+ variables: {
24
+ timeSpan: TimeSpanSubset.Day_1,
25
+ division,
26
+ },
27
+ fetchPolicy: 'cache-and-network',
28
+ }
29
+ );
30
+
31
+ const showError =
32
+ data?.getPriceCandles.length === 0 || !data?.getPriceCandles || !!error;
33
+
34
+ return (
35
+ <div data-testid="instruments-price-chart-wrapper">
36
+ {loading && (
37
+ <div className="lw-mb-[50px] lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
38
+ <Spinner size={SpinnerSize.lg} />
39
+ </div>
40
+ )}
41
+
42
+ {!loading && !showError && (
43
+ <div data-testid="instruments-price-chart-widget">
44
+ <div className="lw-flex lw-pt-2">
45
+ <TimeUnitSwitch<TimeSpanSubset>
46
+ callback={setSelectedTimeUnit}
47
+ options={timeUnitConfig}
48
+ selected={selectedTimeUnit}
49
+ />
50
+ </div>
51
+
52
+ <Chart values={data?.getPriceCandles} />
53
+ </div>
54
+ )}
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export { Main };
@@ -0,0 +1,47 @@
1
+ import {
2
+ BaseChart,
3
+ getChartTheme,
4
+ Theme,
5
+ useLayoutProvider,
6
+ } from '@oanda/labs-widget-common';
7
+ import { CustomChart, LineChart } from 'echarts/charts';
8
+ import {
9
+ DatasetComponent,
10
+ GraphicComponent,
11
+ GridSimpleComponent,
12
+ } from 'echarts/components';
13
+ import * as echarts from 'echarts/core';
14
+ import { CanvasRenderer } from 'echarts/renderers';
15
+ import React from 'react';
16
+
17
+ import { CHART_HEIGHT } from './constants';
18
+ import { getOption } from './getOption';
19
+ import type { ChartProps } from './types';
20
+
21
+ echarts.use([
22
+ GridSimpleComponent,
23
+ GraphicComponent,
24
+ LineChart,
25
+ DatasetComponent,
26
+ CustomChart,
27
+ CanvasRenderer,
28
+ ]);
29
+
30
+ echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
31
+ echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
32
+
33
+ export const Chart = ({ values }: ChartProps) => {
34
+ const { isDark } = useLayoutProvider();
35
+
36
+ return (
37
+ <BaseChart
38
+ chartHeight={CHART_HEIGHT}
39
+ echarts={echarts}
40
+ isDark={isDark}
41
+ option={getOption({
42
+ values,
43
+ isDark,
44
+ })}
45
+ />
46
+ );
47
+ };
@@ -0,0 +1,5 @@
1
+ export const X_LABEL_SIZE = 40;
2
+ export const Y_LABEL_SIZE_DESKTOP = 45;
3
+ export const CHART_WIDTH = 9999;
4
+ export const CHART_HEIGHT = 425;
5
+ export const CHART_INTERVAL = 0.01;
@@ -0,0 +1,7 @@
1
+ export const dailyFormatter = (timestamp: string) => {
2
+ const date = new Date(timestamp);
3
+ return date.toLocaleTimeString(undefined, {
4
+ hour: 'numeric',
5
+ hour12: true,
6
+ });
7
+ };