@oanda/labs-ticker-tape-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 (161) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/TickerTapeWidget/Main.js +87 -0
  4. package/dist/main/TickerTapeWidget/Main.js.map +1 -0
  5. package/dist/main/TickerTapeWidget/TickerTapeWidget.js +56 -0
  6. package/dist/main/TickerTapeWidget/TickerTapeWidget.js.map +1 -0
  7. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +46 -0
  8. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  9. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/index.js +28 -0
  10. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  11. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/types.js +6 -0
  12. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  13. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/utils.js +25 -0
  14. package/dist/main/TickerTapeWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  15. package/dist/main/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js +42 -0
  16. package/dist/main/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  17. package/dist/main/TickerTapeWidget/components/LineChartWithData/index.js +17 -0
  18. package/dist/main/TickerTapeWidget/components/LineChartWithData/index.js.map +1 -0
  19. package/dist/main/TickerTapeWidget/components/LineChartWithData/types.js +6 -0
  20. package/dist/main/TickerTapeWidget/components/LineChartWithData/types.js.map +1 -0
  21. package/dist/main/TickerTapeWidget/constant.js +8 -0
  22. package/dist/main/TickerTapeWidget/constant.js.map +1 -0
  23. package/dist/main/TickerTapeWidget/index.js +28 -0
  24. package/dist/main/TickerTapeWidget/index.js.map +1 -0
  25. package/dist/main/TickerTapeWidget/render.js +55 -0
  26. package/dist/main/TickerTapeWidget/render.js.map +1 -0
  27. package/dist/main/TickerTapeWidget/types.js +20 -0
  28. package/dist/main/TickerTapeWidget/types.js.map +1 -0
  29. package/dist/main/TickerTapeWidget/utils.js +43 -0
  30. package/dist/main/TickerTapeWidget/utils.js.map +1 -0
  31. package/dist/main/gql/getInstrumentsChart.js +16 -0
  32. package/dist/main/gql/getInstrumentsChart.js.map +1 -0
  33. package/dist/main/gql/types/fragment-masking.js +23 -0
  34. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  35. package/dist/main/gql/types/gql.js +17 -0
  36. package/dist/main/gql/types/gql.js.map +1 -0
  37. package/dist/main/gql/types/graphql.js +326 -0
  38. package/dist/main/gql/types/graphql.js.map +1 -0
  39. package/dist/main/gql/types/index.js +28 -0
  40. package/dist/main/gql/types/index.js.map +1 -0
  41. package/dist/main/gql/validateInstruments.js +16 -0
  42. package/dist/main/gql/validateInstruments.js.map +1 -0
  43. package/dist/main/index.js +17 -0
  44. package/dist/main/index.js.map +1 -0
  45. package/dist/main/translations/index.js +27 -0
  46. package/dist/main/translations/index.js.map +1 -0
  47. package/dist/main/translations/sources/en.json +4 -0
  48. package/dist/main/translations/sources/es.json +4 -0
  49. package/dist/main/translations/sources/th.json +4 -0
  50. package/dist/main/translations/sources/zh_TW.json +4 -0
  51. package/dist/main/translations/translations.js +11 -0
  52. package/dist/main/translations/translations.js.map +1 -0
  53. package/dist/module/TickerTapeWidget/Main.js +78 -0
  54. package/dist/module/TickerTapeWidget/Main.js.map +1 -0
  55. package/dist/module/TickerTapeWidget/TickerTapeWidget.js +49 -0
  56. package/dist/module/TickerTapeWidget/TickerTapeWidget.js.map +1 -0
  57. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +38 -0
  58. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  59. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/index.js +3 -0
  60. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  61. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/types.js +2 -0
  62. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  63. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/utils.js +18 -0
  64. package/dist/module/TickerTapeWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  65. package/dist/module/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js +35 -0
  66. package/dist/module/TickerTapeWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  67. package/dist/module/TickerTapeWidget/components/LineChartWithData/index.js +2 -0
  68. package/dist/module/TickerTapeWidget/components/LineChartWithData/index.js.map +1 -0
  69. package/dist/module/TickerTapeWidget/components/LineChartWithData/types.js +2 -0
  70. package/dist/module/TickerTapeWidget/components/LineChartWithData/types.js.map +1 -0
  71. package/dist/module/TickerTapeWidget/constant.js +3 -0
  72. package/dist/module/TickerTapeWidget/constant.js.map +1 -0
  73. package/dist/module/TickerTapeWidget/index.js +3 -0
  74. package/dist/module/TickerTapeWidget/index.js.map +1 -0
  75. package/dist/module/TickerTapeWidget/render.js +52 -0
  76. package/dist/module/TickerTapeWidget/render.js.map +1 -0
  77. package/dist/module/TickerTapeWidget/types.js +3 -0
  78. package/dist/module/TickerTapeWidget/types.js.map +1 -0
  79. package/dist/module/TickerTapeWidget/utils.js +36 -0
  80. package/dist/module/TickerTapeWidget/utils.js.map +1 -0
  81. package/dist/module/gql/getInstrumentsChart.js +10 -0
  82. package/dist/module/gql/getInstrumentsChart.js.map +1 -0
  83. package/dist/module/gql/types/fragment-masking.js +15 -0
  84. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  85. package/dist/module/gql/types/gql.js +9 -0
  86. package/dist/module/gql/types/gql.js.map +1 -0
  87. package/dist/module/gql/types/graphql.js +320 -0
  88. package/dist/module/gql/types/graphql.js.map +1 -0
  89. package/dist/module/gql/types/index.js +3 -0
  90. package/dist/module/gql/types/index.js.map +1 -0
  91. package/dist/module/gql/validateInstruments.js +10 -0
  92. package/dist/module/gql/validateInstruments.js.map +1 -0
  93. package/dist/module/index.js +2 -0
  94. package/dist/module/index.js.map +1 -0
  95. package/dist/module/translations/index.js +20 -0
  96. package/dist/module/translations/index.js.map +1 -0
  97. package/dist/module/translations/sources/en.json +4 -0
  98. package/dist/module/translations/sources/es.json +4 -0
  99. package/dist/module/translations/sources/th.json +4 -0
  100. package/dist/module/translations/sources/zh_TW.json +4 -0
  101. package/dist/module/translations/translations.js +5 -0
  102. package/dist/module/translations/translations.js.map +1 -0
  103. package/dist/types/TickerTapeWidget/Main.d.ts +4 -0
  104. package/dist/types/TickerTapeWidget/TickerTapeWidget.d.ts +4 -0
  105. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +4 -0
  106. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/index.d.ts +2 -0
  107. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/types.d.ts +9 -0
  108. package/dist/types/TickerTapeWidget/components/InstrumentRateWithChart/utils.d.ts +3 -0
  109. package/dist/types/TickerTapeWidget/components/LineChartWithData/LineChartWithData.d.ts +4 -0
  110. package/dist/types/TickerTapeWidget/components/LineChartWithData/index.d.ts +1 -0
  111. package/dist/types/TickerTapeWidget/components/LineChartWithData/types.d.ts +8 -0
  112. package/dist/types/TickerTapeWidget/constant.d.ts +2 -0
  113. package/dist/types/TickerTapeWidget/index.d.ts +2 -0
  114. package/dist/types/TickerTapeWidget/render.d.ts +1 -0
  115. package/dist/types/TickerTapeWidget/types.d.ts +21 -0
  116. package/dist/types/TickerTapeWidget/utils.d.ts +11 -0
  117. package/dist/types/gql/getInstrumentsChart.d.ts +1 -0
  118. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  119. package/dist/types/gql/types/gql.d.ts +45 -0
  120. package/dist/types/gql/types/graphql.d.ts +397 -0
  121. package/dist/types/gql/types/index.d.ts +2 -0
  122. package/dist/types/gql/validateInstruments.d.ts +1 -0
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/translations/index.d.ts +4 -0
  125. package/dist/types/translations/translations.d.ts +4 -0
  126. package/index.ts +1 -0
  127. package/lokalise.config.json +18 -0
  128. package/package.json +26 -0
  129. package/src/TickerTapeWidget/Main.tsx +91 -0
  130. package/src/TickerTapeWidget/TickerTapeWidget.tsx +57 -0
  131. package/src/TickerTapeWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +43 -0
  132. package/src/TickerTapeWidget/components/InstrumentRateWithChart/index.ts +2 -0
  133. package/src/TickerTapeWidget/components/InstrumentRateWithChart/types.ts +10 -0
  134. package/src/TickerTapeWidget/components/InstrumentRateWithChart/utils.ts +25 -0
  135. package/src/TickerTapeWidget/components/LineChartWithData/LineChartWithData.tsx +43 -0
  136. package/src/TickerTapeWidget/components/LineChartWithData/index.ts +1 -0
  137. package/src/TickerTapeWidget/components/LineChartWithData/types.tsx +9 -0
  138. package/src/TickerTapeWidget/constant.ts +5 -0
  139. package/src/TickerTapeWidget/index.ts +2 -0
  140. package/src/TickerTapeWidget/render.tsx +51 -0
  141. package/src/TickerTapeWidget/types.tsx +24 -0
  142. package/src/TickerTapeWidget/utils.ts +48 -0
  143. package/src/gql/getInstrumentsChart.ts +10 -0
  144. package/src/gql/types/fragment-masking.ts +66 -0
  145. package/src/gql/types/gql.ts +47 -0
  146. package/src/gql/types/graphql.ts +432 -0
  147. package/src/gql/types/index.ts +2 -0
  148. package/src/gql/validateInstruments.ts +10 -0
  149. package/src/index.ts +1 -0
  150. package/src/translations/index.ts +17 -0
  151. package/src/translations/sources/en.json +4 -0
  152. package/src/translations/sources/es.json +4 -0
  153. package/src/translations/sources/th.json +4 -0
  154. package/src/translations/sources/zh_TW.json +4 -0
  155. package/src/translations/translations.ts +4 -0
  156. package/test/LineChartWithData.test.tsx +164 -0
  157. package/test/Main.test.tsx +27 -0
  158. package/test/components/InstrumentRateWithChart.test.tsx +62 -0
  159. package/test/components/utils.test.ts +13 -0
  160. package/test/mocks.ts +52 -0
  161. package/tsconfig.types.json +12 -0
@@ -0,0 +1,397 @@
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
+ Indices = "INDICES",
57
+ Rates = "RATES"
58
+ }
59
+ export declare enum BookType {
60
+ Order = "ORDER",
61
+ Position = "POSITION"
62
+ }
63
+ export type CorrelationHeatmap = {
64
+ __typename?: 'CorrelationHeatmap';
65
+ baseInstrument: Instrument;
66
+ heatmap: Array<Heatmap>;
67
+ };
68
+ export type CorrelationMatrix = {
69
+ __typename?: 'CorrelationMatrix';
70
+ baseTimeUnit: CorrelationTimeUnit;
71
+ matrix: Array<Matrix>;
72
+ };
73
+ export declare enum CorrelationTimeUnit {
74
+ H1 = "H1",
75
+ H4 = "H4",
76
+ H24 = "H24",
77
+ M1 = "M1",
78
+ M3 = "M3",
79
+ M6 = "M6",
80
+ W1 = "W1",
81
+ Y1 = "Y1"
82
+ }
83
+ export declare enum CurrencyName {
84
+ Aud = "AUD",
85
+ Cad = "CAD",
86
+ Chf = "CHF",
87
+ Eur = "EUR",
88
+ Gbp = "GBP",
89
+ Jpy = "JPY",
90
+ Nzd = "NZD",
91
+ Usd = "USD"
92
+ }
93
+ export type CurrencyPower = {
94
+ __typename?: 'CurrencyPower';
95
+ /** UTC Timestamp */
96
+ point: Scalars['String']['output'];
97
+ price: Scalars['Float']['output'];
98
+ };
99
+ export type CurrencyPowerBalance = {
100
+ __typename?: 'CurrencyPowerBalance';
101
+ currency: CurrencyName;
102
+ power: Array<CurrencyPower>;
103
+ updatedAt: Scalars['String']['output'];
104
+ };
105
+ export declare enum CurrencyPowerBalanceTimeUnit {
106
+ CurrentDay = "CURRENT_DAY",
107
+ H4 = "H4",
108
+ H8 = "H8",
109
+ H24 = "H24",
110
+ M1 = "M1",
111
+ M3 = "M3",
112
+ PreviousDay = "PREVIOUS_DAY",
113
+ W1 = "W1"
114
+ }
115
+ export type CurrencyStrength = {
116
+ __typename?: 'CurrencyStrength';
117
+ currency: CurrencyName;
118
+ strengthRelation?: Maybe<Array<StrengthRelation>>;
119
+ updatedAt: Scalars['String']['output'];
120
+ };
121
+ export declare enum DataSource {
122
+ Ny4 = "NY4",
123
+ Ty3 = "TY3"
124
+ }
125
+ export declare enum Division {
126
+ Oap = "OAP",
127
+ Oau = "OAU",
128
+ Oc = "OC",
129
+ Ocan = "OCAN",
130
+ Oel = "OEL",
131
+ Ogm = "OGM",
132
+ Oj = "OJ",
133
+ Opt = "OPT",
134
+ Otms = "OTMS"
135
+ }
136
+ export type Heatmap = {
137
+ __typename?: 'Heatmap';
138
+ instrument: Instrument;
139
+ timeCorrelation: Array<TimeCorrelation>;
140
+ };
141
+ export type Instrument = {
142
+ __typename?: 'Instrument';
143
+ displayName: Scalars['String']['output'];
144
+ name: Scalars['String']['output'];
145
+ };
146
+ export type InstrumentCorrelation = {
147
+ __typename?: 'InstrumentCorrelation';
148
+ instrument: Instrument;
149
+ value?: Maybe<Scalars['Float']['output']>;
150
+ };
151
+ export type Matrix = {
152
+ __typename?: 'Matrix';
153
+ instrument: Instrument;
154
+ instrumentCorrelation: Array<InstrumentCorrelation>;
155
+ };
156
+ export type OrderPositionBucket = {
157
+ __typename?: 'OrderPositionBucket';
158
+ longCountPercent: Scalars['Float']['output'];
159
+ price: Scalars['Float']['output'];
160
+ shortCountPercent: Scalars['Float']['output'];
161
+ };
162
+ export type OrderPositionData = {
163
+ __typename?: 'OrderPositionData';
164
+ bucketWidth: Scalars['Float']['output'];
165
+ buckets: Array<Maybe<OrderPositionBucket>>;
166
+ dataSource?: Maybe<Scalars['String']['output']>;
167
+ instrument: Scalars['String']['output'];
168
+ price?: Maybe<Scalars['Float']['output']>;
169
+ region?: Maybe<Scalars['String']['output']>;
170
+ time: Scalars['String']['output'];
171
+ unixTime: Scalars['Int']['output'];
172
+ };
173
+ export type Query = {
174
+ __typename?: 'Query';
175
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
176
+ correlationHeatmap: CorrelationHeatmap;
177
+ correlationMatrix: CorrelationMatrix;
178
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
179
+ currencyStrength?: Maybe<Array<CurrencyStrength>>;
180
+ isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
181
+ mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
182
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
183
+ sentiment?: Maybe<Array<SentimentInstrument>>;
184
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
185
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
186
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
187
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
188
+ valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
189
+ valueAtRiskChart?: Maybe<ValueAtRiskChart>;
190
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
191
+ volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
192
+ };
193
+ export type QueryAssetClassesArgs = {
194
+ division: Division;
195
+ };
196
+ export type QueryCorrelationHeatmapArgs = {
197
+ division: Division;
198
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
199
+ timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
200
+ };
201
+ export type QueryCorrelationMatrixArgs = {
202
+ division: Division;
203
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
204
+ };
205
+ export type QueryCurrencyPowerBalanceArgs = {
206
+ timeUnit: CurrencyPowerBalanceTimeUnit;
207
+ };
208
+ export type QueryIsAllowedPartnerArgs = {
209
+ url: Scalars['String']['input'];
210
+ };
211
+ export type QueryMapInstrumentNamesArgs = {
212
+ division?: InputMaybe<Division>;
213
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
214
+ };
215
+ export type QueryOrderPositionBooksArgs = {
216
+ bookType: BookType;
217
+ dataSource?: InputMaybe<DataSource>;
218
+ instrument: Scalars['String']['input'];
219
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
220
+ region?: InputMaybe<Region>;
221
+ };
222
+ export type QuerySentimentArgs = {
223
+ division?: InputMaybe<Division>;
224
+ name: Scalars['String']['input'];
225
+ };
226
+ export type QuerySentimentListArgs = {
227
+ division?: InputMaybe<Division>;
228
+ sort?: InputMaybe<Sort>;
229
+ };
230
+ export type QueryTopicalInstrumentsArgs = {
231
+ assetClass?: InputMaybe<AssetClassName>;
232
+ count?: InputMaybe<Scalars['Int']['input']>;
233
+ division?: InputMaybe<Division>;
234
+ offset?: InputMaybe<Scalars['Int']['input']>;
235
+ sort: TopicalSort;
236
+ };
237
+ export type QueryTopicalInstrumentsChartsArgs = {
238
+ division?: InputMaybe<Division>;
239
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
240
+ };
241
+ export type QueryTopicalInstrumentsTotalCountArgs = {
242
+ assetClass?: InputMaybe<AssetClassName>;
243
+ division?: InputMaybe<Division>;
244
+ sort: TopicalSort;
245
+ };
246
+ export type QueryValueAtRiskAssetClassesArgs = {
247
+ division?: InputMaybe<Division>;
248
+ };
249
+ export type QueryValueAtRiskChartArgs = {
250
+ bars: ValueAtRiskBars;
251
+ division?: InputMaybe<Division>;
252
+ duration: ValueAtRiskDuration;
253
+ instrument: Scalars['String']['input'];
254
+ };
255
+ export type QueryVolatilityChartArgs = {
256
+ division?: InputMaybe<Division>;
257
+ instrument: Scalars['String']['input'];
258
+ timeSpan: VolatilityChartTimeSpan;
259
+ timeUnit: VolatilityChartTimeUnit;
260
+ };
261
+ export type QueryVolatilityChartAssetClassesArgs = {
262
+ division?: InputMaybe<Division>;
263
+ };
264
+ export declare enum Region {
265
+ Amer = "AMER",
266
+ Apac = "APAC",
267
+ Emea = "EMEA"
268
+ }
269
+ export type Sentiment = {
270
+ __typename?: 'Sentiment';
271
+ longPercent: Scalars['Float']['output'];
272
+ shortPercent: Scalars['Float']['output'];
273
+ };
274
+ export type SentimentInstrument = {
275
+ __typename?: 'SentimentInstrument';
276
+ displayName: Scalars['String']['output'];
277
+ name: Scalars['String']['output'];
278
+ sentiment: Sentiment;
279
+ updatedAt: Scalars['String']['output'];
280
+ };
281
+ export declare enum Sort {
282
+ Bearish = "BEARISH",
283
+ Bullish = "BULLISH"
284
+ }
285
+ export type StrengthRelation = {
286
+ __typename?: 'StrengthRelation';
287
+ currency: CurrencyName;
288
+ percentage: Scalars['Float']['output'];
289
+ };
290
+ export type TimeCorrelation = {
291
+ __typename?: 'TimeCorrelation';
292
+ timeUnit: CorrelationTimeUnit;
293
+ value?: Maybe<Scalars['Float']['output']>;
294
+ };
295
+ export type TopicalInstrument = {
296
+ __typename?: 'TopicalInstrument';
297
+ assetClass?: Maybe<AssetClassName>;
298
+ displayName: Scalars['String']['output'];
299
+ name: Scalars['String']['output'];
300
+ sentiment: Sentiment;
301
+ updatedAt: Scalars['String']['output'];
302
+ };
303
+ export type TopicalInstrumentChart = {
304
+ __typename?: 'TopicalInstrumentChart';
305
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
306
+ name: Scalars['String']['output'];
307
+ };
308
+ export declare enum TopicalSort {
309
+ Bearish = "BEARISH",
310
+ Bullish = "BULLISH",
311
+ Hot = "HOT",
312
+ Popular = "POPULAR",
313
+ Volatile = "VOLATILE"
314
+ }
315
+ export declare enum ValueAtRiskBars {
316
+ C100 = "C100",
317
+ C200 = "C200",
318
+ C300 = "C300"
319
+ }
320
+ export type ValueAtRiskChart = {
321
+ __typename?: 'ValueAtRiskChart';
322
+ down: ValueAtRiskChartData;
323
+ up: ValueAtRiskChartData;
324
+ };
325
+ export type ValueAtRiskChartData = {
326
+ __typename?: 'ValueAtRiskChartData';
327
+ average: Scalars['Float']['output'];
328
+ max: Scalars['Float']['output'];
329
+ median: Scalars['Float']['output'];
330
+ points?: Maybe<Array<ValueAtRiskChartPoint>>;
331
+ threshold: Scalars['Float']['output'];
332
+ };
333
+ export type ValueAtRiskChartPoint = {
334
+ __typename?: 'ValueAtRiskChartPoint';
335
+ percent: Scalars['Float']['output'];
336
+ pips: Scalars['Float']['output'];
337
+ };
338
+ export declare enum ValueAtRiskDuration {
339
+ C1 = "C1",
340
+ C2 = "C2",
341
+ C3 = "C3",
342
+ C4 = "C4",
343
+ C5 = "C5",
344
+ C10 = "C10"
345
+ }
346
+ export type VolatilityChart = {
347
+ __typename?: 'VolatilityChart';
348
+ pips: Scalars['Float']['output'];
349
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
350
+ point: Scalars['String']['output'];
351
+ updatedAt: Scalars['String']['output'];
352
+ };
353
+ export declare enum VolatilityChartTimeSpan {
354
+ /** Valid for: H */
355
+ D5 = "D5",
356
+ /** Valid for: H */
357
+ D10 = "D10",
358
+ /** Valid for: D */
359
+ M1 = "M1",
360
+ /** Valid for: D */
361
+ M3 = "M3",
362
+ /** Valid for: W */
363
+ W5 = "W5",
364
+ /** Valid for: W */
365
+ W10 = "W10"
366
+ }
367
+ export declare enum VolatilityChartTimeUnit {
368
+ D = "D",
369
+ H = "H",
370
+ W = "W"
371
+ }
372
+ export type GetInstrumentsChartQueryVariables = Exact<{
373
+ instruments?: InputMaybe<Array<Scalars['String']['input']> | Scalars['String']['input']>;
374
+ division?: InputMaybe<Division>;
375
+ }>;
376
+ export type GetInstrumentsChartQuery = {
377
+ __typename?: 'Query';
378
+ topicalInstrumentsCharts?: Array<{
379
+ __typename?: 'TopicalInstrumentChart';
380
+ name: string;
381
+ chart?: Array<number> | null;
382
+ }> | null;
383
+ };
384
+ export type ValidateInstrumentsQueryVariables = Exact<{
385
+ instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
386
+ division?: InputMaybe<Division>;
387
+ }>;
388
+ export type ValidateInstrumentsQuery = {
389
+ __typename?: 'Query';
390
+ mapInstrumentNames?: Array<{
391
+ __typename?: 'Instrument';
392
+ name: string;
393
+ displayName: string;
394
+ } | null> | null;
395
+ };
396
+ export declare const GetInstrumentsChartDocument: DocumentNode<GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables>;
397
+ 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 './TickerTapeWidget';
@@ -0,0 +1,4 @@
1
+ import { Translations } from '@oanda/mono-i18n';
2
+ import { defaultTranslations } from './translations';
3
+ export type TranslationKey = keyof typeof defaultTranslations;
4
+ export declare const translations: Translations;
@@ -0,0 +1,4 @@
1
+ export declare const defaultTranslations: {
2
+ data_unavailable: string;
3
+ pagination_entries_range: string;
4
+ };
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,26 @@
1
+ {
2
+ "name": "@oanda/labs-ticker-tape-widget",
3
+ "version": "1.0.1",
4
+ "description": "Labs Ticker Tape 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
+ "@apollo/client": "3.9.9",
16
+ "@oanda/labs-widget-common": "^1.0.145",
17
+ "@oanda/mono-i18n": "10.0.1",
18
+ "graphql": "16.8.1",
19
+ "react-fast-marquee": "1.6.5"
20
+ },
21
+ "devDependencies": {
22
+ "@graphql-codegen/cli": "5.0.0",
23
+ "@graphql-codegen/client-preset": "4.1.0"
24
+ },
25
+ "gitHead": "5cc88e59b1912fd2c750cd083a71af6109532a3c"
26
+ }
@@ -0,0 +1,91 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Marquee from 'react-fast-marquee';
3
+ import classnames from 'classnames';
4
+ import { useQuery } from '@apollo/client';
5
+ import {
6
+ ChartError, DataRecord, Tooltip, useLiveRatesQuery,
7
+ } from '@oanda/labs-widget-common';
8
+ import { MainProps } from './types';
9
+ import {
10
+ ValidateInstrumentsQuery,
11
+ ValidateInstrumentsQueryVariables,
12
+ } from '../gql/types/graphql';
13
+ import { validateInstruments } from '../gql/validateInstruments';
14
+ import { getRecords } from './utils';
15
+ import { InstrumentRateWithChart } from './components/InstrumentRateWithChart';
16
+ import { INSTRUMENT_TOOLTIP_ID } from './constant';
17
+
18
+ const Main = ({
19
+ instruments,
20
+ division,
21
+ size: widgetSize = 'fullWithChart',
22
+ }: MainProps) => {
23
+ const [records, setRecords] = useState<DataRecord[]>([]);
24
+ const { target, setQuery } = useLiveRatesQuery();
25
+ const { loading, data, error } = useQuery<
26
+ ValidateInstrumentsQuery,
27
+ ValidateInstrumentsQueryVariables
28
+ >(validateInstruments, {
29
+ variables: {
30
+ instruments,
31
+ division,
32
+ },
33
+ fetchPolicy: 'network-only',
34
+ });
35
+
36
+ useEffect(() => {
37
+ if (!loading && data) {
38
+ setRecords(getRecords(data)!);
39
+ }
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ }, [loading, data]);
42
+
43
+ const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);
44
+
45
+ useEffect(() => {
46
+ if (instrumentsNames[0]) {
47
+ setQuery({ instruments: instrumentsNames });
48
+ }
49
+ // eslint-disable-next-line react-hooks/exhaustive-deps
50
+ }, [records]);
51
+
52
+ const showError = !!error;
53
+ const isLoading = loading || !data;
54
+
55
+ return (
56
+ <div data-testid="ticker-tape-wrapper">
57
+ <Marquee
58
+ play={!isLoading}
59
+ autoFill
60
+ pauseOnHover
61
+ speed={60}
62
+ >
63
+ {records.map((record) => (
64
+ <div
65
+ key={record.instrument}
66
+ className={classnames('lw-flex lw-border lw-border-r-0 lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
67
+ 'lw-h-[82px]': widgetSize !== 'compact',
68
+ 'lw-h-[54px]': widgetSize === 'compact',
69
+ })}
70
+ >
71
+ <InstrumentRateWithChart
72
+ loading={loading}
73
+ record={record}
74
+ target={target}
75
+ division={division}
76
+ size={widgetSize}
77
+ />
78
+ </div>
79
+ ))}
80
+ </Marquee>
81
+ <Tooltip id={INSTRUMENT_TOOLTIP_ID} />
82
+ {!loading && showError && (
83
+ <div className="lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
84
+ <ChartError />
85
+ </div>
86
+ )}
87
+ </div>
88
+ );
89
+ };
90
+
91
+ export { Main };
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
3
+ import { LocaleProvider } from '@oanda/mono-i18n';
4
+ import {
5
+ ChartError, LiveRatesProvider, ThemeProvider, getLocale,
6
+ } from '@oanda/labs-widget-common';
7
+ import { translations } from '../translations';
8
+ import { Main } from './Main';
9
+ import { Division, TickerTapeConfig } from './types';
10
+
11
+ const TickerTapeWidget = ({
12
+ graphqlUrl,
13
+ liveRatesUrl,
14
+ instruments,
15
+ division,
16
+ locale,
17
+ theme,
18
+ isParamError,
19
+ removePadding,
20
+ size,
21
+ }: TickerTapeConfig) => {
22
+ const client = new ApolloClient({
23
+ uri: graphqlUrl,
24
+ cache: new InMemoryCache(),
25
+ });
26
+
27
+ const divisionCode = division === Division.Opt ? Division.Ogm : division;
28
+ const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
29
+
30
+ return (
31
+ <ThemeProvider removePadding={removePadding} theme={theme}>
32
+ <LocaleProvider locale={getLocale(locale)} translations={translations}>
33
+ <LiveRatesProvider
34
+ url={liveRatesUrl}
35
+ options={{ divisionCode, dataSource }}
36
+ >
37
+ <ApolloProvider client={client}>
38
+ {isParamError ? (
39
+ <div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
40
+ <ChartError />
41
+ </div>
42
+ )
43
+ : (
44
+ <Main
45
+ size={size}
46
+ instruments={instruments}
47
+ division={division}
48
+ />
49
+ )}
50
+ </ApolloProvider>
51
+ </LiveRatesProvider>
52
+ </LocaleProvider>
53
+ </ThemeProvider>
54
+ );
55
+ };
56
+
57
+ export { TickerTapeWidget };
@@ -0,0 +1,43 @@
1
+ import React, { useContext } from 'react';
2
+ import { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';
3
+ import { InstrumentRateWithChartProps } from './types';
4
+ import { getChartColor, getColorIndicator } from './utils';
5
+ import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
6
+ import { LineChartWithData } from '../LineChartWithData';
7
+ import { useRecords } from '../../utils';
8
+
9
+ const InstrumentRateWithChart = ({
10
+ loading,
11
+ record,
12
+ target,
13
+ division,
14
+ size,
15
+ }: InstrumentRateWithChartProps) => {
16
+ const { isDark } = useContext(ThemeContext);
17
+ const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);
18
+
19
+ const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
20
+
21
+ return (
22
+ <>
23
+ <InstrumentRate
24
+ isLoading={loading}
25
+ isError={!!error}
26
+ record={updatedRecord}
27
+ size={size}
28
+ tooltipId={INSTRUMENT_TOOLTIP_ID}
29
+ colorIndicator={indicator}
30
+ />
31
+ {size === 'fullWithChart' && (
32
+ <LineChartWithData
33
+ record={record}
34
+ isLoading={loading}
35
+ division={division}
36
+ color={getChartColor(indicator, isDark)}
37
+ />
38
+ )}
39
+ </>
40
+ );
41
+ };
42
+
43
+ export { InstrumentRateWithChart };
@@ -0,0 +1,2 @@
1
+ export * from './InstrumentRateWithChart';
2
+ export * from './utils';
@@ -0,0 +1,10 @@
1
+ import { DataRecord } from '@oanda/labs-widget-common';
2
+ import { Division } from '../../types';
3
+
4
+ export interface InstrumentRateWithChartProps {
5
+ loading: boolean;
6
+ record: DataRecord;
7
+ target: EventTarget | null;
8
+ division: Division;
9
+ size?: 'compact' | 'full' | 'fullWithChart'
10
+ }