@oanda/labs-currency-power-balance-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 (176) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +46 -0
  4. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -0
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +28 -0
  6. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -0
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js +12 -0
  8. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -0
  9. package/dist/main/CurrencyPowerBalanceWidget/Tool.js +28 -0
  10. package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +1 -0
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +45 -0
  12. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -0
  13. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/index.js +17 -0
  14. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/index.js.map +1 -0
  15. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +31 -0
  16. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -0
  17. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +59 -0
  18. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -0
  19. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +103 -0
  20. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -0
  21. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +36 -0
  22. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -0
  23. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/index.js +28 -0
  24. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/index.js.map +1 -0
  25. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js +6 -0
  26. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -0
  27. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js +6 -0
  28. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -0
  29. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +53 -0
  30. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -0
  31. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +46 -0
  32. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -0
  33. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +17 -0
  34. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +1 -0
  35. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +6 -0
  36. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -0
  37. package/dist/main/CurrencyPowerBalanceWidget/config.js +39 -0
  38. package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -0
  39. package/dist/main/CurrencyPowerBalanceWidget/constants.js +8 -0
  40. package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -0
  41. package/dist/main/CurrencyPowerBalanceWidget/index.js +17 -0
  42. package/dist/main/CurrencyPowerBalanceWidget/index.js.map +1 -0
  43. package/dist/main/CurrencyPowerBalanceWidget/render.js +28 -0
  44. package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -0
  45. package/dist/main/CurrencyPowerBalanceWidget/types.js +6 -0
  46. package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -0
  47. package/dist/main/gql/getCurrencyPowerBalance.js +11 -0
  48. package/dist/main/gql/getCurrencyPowerBalance.js.map +1 -0
  49. package/dist/main/gql/types/fragment-masking.js +24 -0
  50. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  51. package/dist/main/gql/types/gql.js +17 -0
  52. package/dist/main/gql/types/gql.js.map +1 -0
  53. package/dist/main/gql/types/graphql.js +171 -0
  54. package/dist/main/gql/types/graphql.js.map +1 -0
  55. package/dist/main/gql/types/index.js +28 -0
  56. package/dist/main/gql/types/index.js.map +1 -0
  57. package/dist/main/index.js +17 -0
  58. package/dist/main/index.js.map +1 -0
  59. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +39 -0
  60. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -0
  61. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +21 -0
  62. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -0
  63. package/dist/module/CurrencyPowerBalanceWidget/Main.js +5 -0
  64. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -0
  65. package/dist/module/CurrencyPowerBalanceWidget/Tool.js +20 -0
  66. package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +1 -0
  67. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +36 -0
  68. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -0
  69. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/index.js +2 -0
  70. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/index.js.map +1 -0
  71. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +26 -0
  72. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -0
  73. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +52 -0
  74. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -0
  75. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +97 -0
  76. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -0
  77. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +30 -0
  78. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -0
  79. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/index.js +3 -0
  80. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/index.js.map +1 -0
  81. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js +2 -0
  82. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -0
  83. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js +2 -0
  84. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -0
  85. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +46 -0
  86. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -0
  87. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +39 -0
  88. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -0
  89. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +2 -0
  90. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +1 -0
  91. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +2 -0
  92. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -0
  93. package/dist/module/CurrencyPowerBalanceWidget/config.js +34 -0
  94. package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -0
  95. package/dist/module/CurrencyPowerBalanceWidget/constants.js +2 -0
  96. package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -0
  97. package/dist/module/CurrencyPowerBalanceWidget/index.js +2 -0
  98. package/dist/module/CurrencyPowerBalanceWidget/index.js.map +1 -0
  99. package/dist/module/CurrencyPowerBalanceWidget/render.js +25 -0
  100. package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -0
  101. package/dist/module/CurrencyPowerBalanceWidget/types.js +2 -0
  102. package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -0
  103. package/dist/module/gql/getCurrencyPowerBalance.js +5 -0
  104. package/dist/module/gql/getCurrencyPowerBalance.js.map +1 -0
  105. package/dist/module/gql/types/fragment-masking.js +16 -0
  106. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  107. package/dist/module/gql/types/gql.js +9 -0
  108. package/dist/module/gql/types/gql.js.map +1 -0
  109. package/dist/module/gql/types/graphql.js +165 -0
  110. package/dist/module/gql/types/graphql.js.map +1 -0
  111. package/dist/module/gql/types/index.js +3 -0
  112. package/dist/module/gql/types/index.js.map +1 -0
  113. package/dist/module/index.js +2 -0
  114. package/dist/module/index.js.map +1 -0
  115. package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +4 -0
  116. package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +4 -0
  117. package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +3 -0
  118. package/dist/types/CurrencyPowerBalanceWidget/Tool.d.ts +3 -0
  119. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +4 -0
  120. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/index.d.ts +1 -0
  121. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +24 -0
  122. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +5 -0
  123. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +74 -0
  124. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.d.ts +110 -0
  125. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/index.d.ts +2 -0
  126. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/types.d.ts +5 -0
  127. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +5 -0
  128. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +4 -0
  129. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +4 -0
  130. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.d.ts +1 -0
  131. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +12 -0
  132. package/dist/types/CurrencyPowerBalanceWidget/config.d.ts +11 -0
  133. package/dist/types/CurrencyPowerBalanceWidget/constants.d.ts +1 -0
  134. package/dist/types/CurrencyPowerBalanceWidget/index.d.ts +1 -0
  135. package/dist/types/CurrencyPowerBalanceWidget/render.d.ts +1 -0
  136. package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +12 -0
  137. package/dist/types/gql/getCurrencyPowerBalance.d.ts +1 -0
  138. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  139. package/dist/types/gql/types/gql.d.ts +36 -0
  140. package/dist/types/gql/types/graphql.d.ts +274 -0
  141. package/dist/types/gql/types/index.d.ts +2 -0
  142. package/dist/types/index.d.ts +1 -0
  143. package/index.ts +1 -0
  144. package/package.json +27 -0
  145. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +48 -0
  146. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +24 -0
  147. package/src/CurrencyPowerBalanceWidget/Main.tsx +10 -0
  148. package/src/CurrencyPowerBalanceWidget/Tool.tsx +27 -0
  149. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +45 -0
  150. package/src/CurrencyPowerBalanceWidget/components/Chart/index.ts +1 -0
  151. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx +41 -0
  152. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +46 -0
  153. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +82 -0
  154. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +45 -0
  155. package/src/CurrencyPowerBalanceWidget/components/Chart/options/index.ts +2 -0
  156. package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +5 -0
  157. package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +6 -0
  158. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +24 -0
  159. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +58 -0
  160. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.ts +1 -0
  161. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +14 -0
  162. package/src/CurrencyPowerBalanceWidget/config.ts +30 -0
  163. package/src/CurrencyPowerBalanceWidget/constants.ts +1 -0
  164. package/src/CurrencyPowerBalanceWidget/index.ts +1 -0
  165. package/src/CurrencyPowerBalanceWidget/render.tsx +36 -0
  166. package/src/CurrencyPowerBalanceWidget/types.ts +15 -0
  167. package/src/gql/getCurrencyPowerBalance.ts +13 -0
  168. package/src/gql/types/fragment-masking.ts +66 -0
  169. package/src/gql/types/gql.ts +42 -0
  170. package/src/gql/types/graphql.ts +283 -0
  171. package/src/gql/types/index.ts +2 -0
  172. package/src/index.ts +1 -0
  173. package/test/Main.test.tsx +29 -0
  174. package/test/chartFormatters.test.ts +59 -0
  175. package/test/responsesMocks.ts +223 -0
  176. package/tsconfig.types.json +12 -0
@@ -0,0 +1,283 @@
1
+ /* eslint-disable */
2
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
+ export type Maybe<T> = T | null;
4
+ export type InputMaybe<T> = Maybe<T>;
5
+ export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
6
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
7
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
8
+ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
9
+ export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
10
+ /** All built-in and custom scalars, mapped to their actual values */
11
+ export type Scalars = {
12
+ ID: { input: string; output: string; }
13
+ String: { input: string; output: string; }
14
+ Boolean: { input: boolean; output: boolean; }
15
+ Int: { input: number; output: number; }
16
+ Float: { input: number; output: number; }
17
+ };
18
+
19
+ export type AssetClass = {
20
+ __typename?: 'AssetClass';
21
+ instruments?: Maybe<Array<Maybe<Instrument>>>;
22
+ name?: Maybe<Scalars['String']['output']>;
23
+ };
24
+
25
+ export enum BookType {
26
+ Order = 'ORDER',
27
+ Position = 'POSITION'
28
+ }
29
+
30
+ export enum CurrencyName {
31
+ Aud = 'AUD',
32
+ Cad = 'CAD',
33
+ Chf = 'CHF',
34
+ Eur = 'EUR',
35
+ Gbp = 'GBP',
36
+ Jpy = 'JPY',
37
+ Nzd = 'NZD',
38
+ Usd = 'USD'
39
+ }
40
+
41
+ export type CurrencyPower = {
42
+ __typename?: 'CurrencyPower';
43
+ /** UTC Timestamp */
44
+ point: Scalars['String']['output'];
45
+ price: Scalars['Float']['output'];
46
+ };
47
+
48
+ export type CurrencyPowerBalance = {
49
+ __typename?: 'CurrencyPowerBalance';
50
+ currency: CurrencyName;
51
+ power: Array<CurrencyPower>;
52
+ };
53
+
54
+ export enum CurrencyPowerBalanceTimeUnit {
55
+ CurrentDay = 'CURRENT_DAY',
56
+ H4 = 'H4',
57
+ H8 = 'H8',
58
+ H24 = 'H24',
59
+ M1 = 'M1',
60
+ M3 = 'M3',
61
+ PreviousDay = 'PREVIOUS_DAY',
62
+ W1 = 'W1'
63
+ }
64
+
65
+ export enum DataSource {
66
+ Ny4 = 'NY4',
67
+ Ty3 = 'TY3'
68
+ }
69
+
70
+ export enum Division {
71
+ Oap = 'OAP',
72
+ Oau = 'OAU',
73
+ Oc = 'OC',
74
+ Ocan = 'OCAN',
75
+ Oel = 'OEL',
76
+ Ogm = 'OGM',
77
+ Oj = 'OJ',
78
+ Otms = 'OTMS'
79
+ }
80
+
81
+ export type Instrument = {
82
+ __typename?: 'Instrument';
83
+ displayName?: Maybe<Scalars['String']['output']>;
84
+ name?: Maybe<Scalars['String']['output']>;
85
+ };
86
+
87
+ export type OrderPositionBucket = {
88
+ __typename?: 'OrderPositionBucket';
89
+ longCountPercent: Scalars['Float']['output'];
90
+ price: Scalars['Float']['output'];
91
+ shortCountPercent: Scalars['Float']['output'];
92
+ };
93
+
94
+ export type OrderPositionData = {
95
+ __typename?: 'OrderPositionData';
96
+ bucketWidth: Scalars['Float']['output'];
97
+ buckets: Array<Maybe<OrderPositionBucket>>;
98
+ dataSource?: Maybe<Scalars['String']['output']>;
99
+ instrument: Scalars['String']['output'];
100
+ price: Scalars['Float']['output'];
101
+ region?: Maybe<Scalars['String']['output']>;
102
+ time: Scalars['String']['output'];
103
+ unixTime: Scalars['Int']['output'];
104
+ };
105
+
106
+ export type Query = {
107
+ __typename?: 'Query';
108
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
109
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
110
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
111
+ sentiment?: Maybe<Array<SentimentInstrument>>;
112
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
113
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
114
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
115
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
116
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
117
+ volatilityChartAssetClasses?: Maybe<Array<VolatilityChartAssetClass>>;
118
+ };
119
+
120
+
121
+ export type QueryAssetClassesArgs = {
122
+ division: Division;
123
+ };
124
+
125
+
126
+ export type QueryCurrencyPowerBalanceArgs = {
127
+ timeUnit: CurrencyPowerBalanceTimeUnit;
128
+ };
129
+
130
+
131
+ export type QueryOrderPositionBooksArgs = {
132
+ bookType: BookType;
133
+ dataSource?: InputMaybe<DataSource>;
134
+ instrument: Scalars['String']['input'];
135
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
136
+ region?: InputMaybe<Region>;
137
+ };
138
+
139
+
140
+ export type QuerySentimentArgs = {
141
+ division?: InputMaybe<Division>;
142
+ name: Scalars['String']['input'];
143
+ };
144
+
145
+
146
+ export type QuerySentimentListArgs = {
147
+ division?: InputMaybe<Division>;
148
+ sort?: InputMaybe<Sort>;
149
+ };
150
+
151
+
152
+ export type QueryTopicalInstrumentsArgs = {
153
+ count?: InputMaybe<Scalars['Int']['input']>;
154
+ division?: InputMaybe<Division>;
155
+ offset?: InputMaybe<Scalars['Int']['input']>;
156
+ sort: TopicalSort;
157
+ };
158
+
159
+
160
+ export type QueryTopicalInstrumentsChartsArgs = {
161
+ division?: InputMaybe<Division>;
162
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
163
+ };
164
+
165
+
166
+ export type QueryTopicalInstrumentsTotalCountArgs = {
167
+ division?: InputMaybe<Division>;
168
+ sort: TopicalSort;
169
+ };
170
+
171
+
172
+ export type QueryVolatilityChartArgs = {
173
+ division?: InputMaybe<Division>;
174
+ instrument: Scalars['String']['input'];
175
+ timeSpan: VolatilityChartTimeSpan;
176
+ timeUnit: VolatilityChartTimeUnit;
177
+ };
178
+
179
+
180
+ export type QueryVolatilityChartAssetClassesArgs = {
181
+ division?: InputMaybe<Division>;
182
+ };
183
+
184
+ export enum Region {
185
+ Amer = 'AMER',
186
+ Apac = 'APAC',
187
+ Emea = 'EMEA'
188
+ }
189
+
190
+ export type Sentiment = {
191
+ __typename?: 'Sentiment';
192
+ longPercent: Scalars['Float']['output'];
193
+ shortPercent: Scalars['Float']['output'];
194
+ };
195
+
196
+ export type SentimentInstrument = {
197
+ __typename?: 'SentimentInstrument';
198
+ displayName: Scalars['String']['output'];
199
+ name: Scalars['String']['output'];
200
+ sentiment: Sentiment;
201
+ };
202
+
203
+ export enum Sort {
204
+ Bearish = 'BEARISH',
205
+ Bullish = 'BULLISH'
206
+ }
207
+
208
+ export type TopicalInstrument = {
209
+ __typename?: 'TopicalInstrument';
210
+ displayName: Scalars['String']['output'];
211
+ name: Scalars['String']['output'];
212
+ sentiment: TopicalInstrumentSentiment;
213
+ updatedAt: Scalars['String']['output'];
214
+ };
215
+
216
+ export type TopicalInstrumentChart = {
217
+ __typename?: 'TopicalInstrumentChart';
218
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
219
+ name: Scalars['String']['output'];
220
+ };
221
+
222
+ export type TopicalInstrumentSentiment = {
223
+ __typename?: 'TopicalInstrumentSentiment';
224
+ longPercent: Scalars['Float']['output'];
225
+ shortPercent: Scalars['Float']['output'];
226
+ };
227
+
228
+ export enum TopicalSort {
229
+ Bearish = 'BEARISH',
230
+ Bullish = 'BULLISH',
231
+ Hot = 'HOT',
232
+ Popular = 'POPULAR',
233
+ Volatile = 'VOLATILE'
234
+ }
235
+
236
+ export type VolatilityChart = {
237
+ __typename?: 'VolatilityChart';
238
+ pips: Scalars['Float']['output'];
239
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
240
+ point: Scalars['String']['output'];
241
+ };
242
+
243
+ export type VolatilityChartAssetClass = {
244
+ __typename?: 'VolatilityChartAssetClass';
245
+ instruments: Array<VolatilityChartInstrument>;
246
+ name: Scalars['String']['output'];
247
+ };
248
+
249
+ export type VolatilityChartInstrument = {
250
+ __typename?: 'VolatilityChartInstrument';
251
+ displayName: Scalars['String']['output'];
252
+ name: Scalars['String']['output'];
253
+ };
254
+
255
+ export enum VolatilityChartTimeSpan {
256
+ D5 = 'D5',
257
+ /** Valid for: H */
258
+ D10 = 'D10',
259
+ /** Valid for: H */
260
+ M1 = 'M1',
261
+ /** Valid for: D */
262
+ M3 = 'M3',
263
+ /** Valid for: D */
264
+ W5 = 'W5',
265
+ /** Valid for: W */
266
+ W10 = 'W10'
267
+ }
268
+
269
+ export enum VolatilityChartTimeUnit {
270
+ D = 'D',
271
+ H = 'H',
272
+ W = 'W'
273
+ }
274
+
275
+ export type GetCurrencyPowerBalanceQueryVariables = Exact<{
276
+ timeUnit: CurrencyPowerBalanceTimeUnit;
277
+ }>;
278
+
279
+
280
+ export type GetCurrencyPowerBalanceQuery = { __typename?: 'Query', currencyPowerBalance?: Array<{ __typename?: 'CurrencyPowerBalance', currency: CurrencyName, power: Array<{ __typename?: 'CurrencyPower', point: string, price: number }> }> | null };
281
+
282
+
283
+ export const GetCurrencyPowerBalanceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCurrencyPowerBalance"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"timeUnit"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CurrencyPowerBalanceTimeUnit"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currencyPowerBalance"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"timeUnit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"timeUnit"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"power"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"point"}},{"kind":"Field","name":{"kind":"Name","value":"price"}}]}}]}}]}}]} as unknown as DocumentNode<GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables>;
@@ -0,0 +1,2 @@
1
+ export * from "./fragment-masking";
2
+ export * from "./gql";
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './CurrencyPowerBalanceWidget';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import React from 'react';
5
+ import { render } from '@testing-library/react';
6
+ import { MockedProvider } from '@apollo/client/testing';
7
+ import { Main } from '../src/CurrencyPowerBalanceWidget/Main';
8
+ import { mockResponse } from './responsesMocks';
9
+
10
+ jest.mock('usehooks-ts', () => ({
11
+ useMediaQuery: jest.fn(),
12
+ useOnClickOutside: jest.fn(),
13
+ useElementSize: jest.fn().mockImplementation(() => [null, {
14
+ width: 100,
15
+ }]),
16
+ }));
17
+
18
+ describe('Main component', () => {
19
+ it('should render tool view', async () => {
20
+ const { findByTestId, getByTestId } = render(
21
+ <MockedProvider mocks={mockResponse}>
22
+ <Main />
23
+ </MockedProvider>,
24
+ );
25
+
26
+ expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
27
+ expect(getByTestId('time-unit-select')).toBeInTheDocument();
28
+ });
29
+ });
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import { xAxisLabelFormatter, tooltipFormatter } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
6
+ import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
7
+
8
+ describe('tooltipFormatter', () => {
9
+ it('should sort & format tooltip content', () => {
10
+ const values = [{
11
+ marker: '<span>Marker 1</span>',
12
+ seriesName: 'Name 1',
13
+ value: ['2023-10-27T14:00:00Z', '-30.91'],
14
+ }, {
15
+ marker: '<span>Marker 2</span>',
16
+ seriesName: 'Name 2',
17
+ value: ['2023-10-27T14:00:00Z', '-20.23'],
18
+ }];
19
+
20
+ const element = document.createElement('div');
21
+ element.innerHTML = tooltipFormatter(values);
22
+
23
+ expect(element.querySelector('p')).toContainHTML('<p style="margin-bottom:5px;">10/27/2023, 14:00 UTC</p>');
24
+ expect(element.querySelectorAll('span')[0]).toContainHTML('<span>Marker 2</span>');
25
+ expect(element.querySelectorAll('span')[2]).toContainHTML('<span>-20.23</span>');
26
+ expect(element.querySelectorAll('span')[3]).toContainHTML('<span>Marker 1</span>');
27
+ expect(element.querySelectorAll('span')[5]).toContainHTML('<span>-30.91</span>');
28
+ });
29
+ });
30
+
31
+ describe('xAxisLabelFormatter', () => {
32
+ it('should format x axis label to date for 1 week time unit', () => {
33
+ expect(xAxisLabelFormatter('2023-10-22T10:00:00Z', CurrencyPowerBalanceTimeUnit.W1)).toEqual('10/22');
34
+ });
35
+ it('should format x axis label to date for 1 month time unit', () => {
36
+ expect(xAxisLabelFormatter('2023-10-20T10:00:00Z', CurrencyPowerBalanceTimeUnit.M1)).toEqual('10/20');
37
+ });
38
+ it('should format x axis label to date for 3 months time unit', () => {
39
+ expect(xAxisLabelFormatter('2023-10-10T10:00:00Z', CurrencyPowerBalanceTimeUnit.M3)).toEqual('10/10');
40
+ });
41
+ it('should format x axis label to date for midnight', () => {
42
+ expect(xAxisLabelFormatter('2023-09-20T00:00:00Z', CurrencyPowerBalanceTimeUnit.CurrentDay)).toEqual('9/20');
43
+ });
44
+ it('should format x axis label to time for current day', () => {
45
+ expect(xAxisLabelFormatter('2023-09-20T01:00:00Z', CurrencyPowerBalanceTimeUnit.CurrentDay)).toEqual('01:00');
46
+ });
47
+ it('should format x axis label to time for previous day', () => {
48
+ expect(xAxisLabelFormatter('2023-12-18T05:00:00Z', CurrencyPowerBalanceTimeUnit.PreviousDay)).toEqual('05:00');
49
+ });
50
+ it('should format x axis label to time for 24 hours', () => {
51
+ expect(xAxisLabelFormatter('2023-06-01T12:20:00Z', CurrencyPowerBalanceTimeUnit.H24)).toEqual('12:20');
52
+ });
53
+ it('should format x axis label to time for 8 hours', () => {
54
+ expect(xAxisLabelFormatter('2023-08-23T14:00:00Z', CurrencyPowerBalanceTimeUnit.H8)).toEqual('14:00');
55
+ });
56
+ it('should format x axis label to time for 4 hours', () => {
57
+ expect(xAxisLabelFormatter('2024-01-05T05:45:00Z', CurrencyPowerBalanceTimeUnit.H4)).toEqual('05:45');
58
+ });
59
+ });
@@ -0,0 +1,223 @@
1
+ import { getCurrencyPowerBalance } from '../src/gql/getCurrencyPowerBalance';
2
+
3
+ const mockResponse = [{
4
+ request: {
5
+ query: getCurrencyPowerBalance,
6
+ variables: {
7
+ timeUnit: 'CURRENT_DAY',
8
+ },
9
+ },
10
+ result: {
11
+ data: {
12
+ currencyPowerBalance: [
13
+ {
14
+ currency: 'NZD',
15
+ power: [
16
+ {
17
+ point: '2023-10-26T22:00:00Z',
18
+ price: 3.86,
19
+ },
20
+ {
21
+ point: '2023-10-27T02:00:00Z',
22
+ price: 3.04,
23
+ },
24
+ {
25
+ point: '2023-10-27T06:00:00Z',
26
+ price: 3.84,
27
+ },
28
+ {
29
+ point: '2023-10-27T10:00:00Z',
30
+ price: 4.65,
31
+ },
32
+ {
33
+ point: '2023-10-27T14:00:00Z',
34
+ price: 2.43,
35
+ },
36
+ {
37
+ point: '2023-10-27T18:00:00Z',
38
+ price: 1.65,
39
+ },
40
+ ],
41
+ },
42
+ {
43
+ currency: 'CHF',
44
+ power: [
45
+ {
46
+ point: '2023-10-26T22:00:00Z',
47
+ price: -5.62,
48
+ },
49
+ {
50
+ point: '2023-10-27T02:00:00Z',
51
+ price: -5.57,
52
+ },
53
+ {
54
+ point: '2023-10-27T06:00:00Z',
55
+ price: -7.7,
56
+ },
57
+ {
58
+ point: '2023-10-27T10:00:00Z',
59
+ price: -8.75,
60
+ },
61
+ {
62
+ point: '2023-10-27T14:00:00Z',
63
+ price: -10.33,
64
+ },
65
+ {
66
+ point: '2023-10-27T18:00:00Z',
67
+ price: -9.15,
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ currency: 'AUD',
73
+ power: [
74
+ {
75
+ point: '2023-10-26T22:00:00Z',
76
+ price: 3.8,
77
+ },
78
+ {
79
+ point: '2023-10-27T02:00:00Z',
80
+ price: 3.08,
81
+ },
82
+ {
83
+ point: '2023-10-27T06:00:00Z',
84
+ price: 3.37,
85
+ },
86
+ {
87
+ point: '2023-10-27T10:00:00Z',
88
+ price: 3.51,
89
+ },
90
+ {
91
+ point: '2023-10-27T14:00:00Z',
92
+ price: 3.91,
93
+ },
94
+ {
95
+ point: '2023-10-27T18:00:00Z',
96
+ price: 4.31,
97
+ },
98
+ ],
99
+ },
100
+ {
101
+ currency: 'CAD',
102
+ power: [
103
+ {
104
+ point: '2023-10-26T22:00:00Z',
105
+ price: -6.41,
106
+ },
107
+ {
108
+ point: '2023-10-27T02:00:00Z',
109
+ price: -5.54,
110
+ },
111
+ {
112
+ point: '2023-10-27T06:00:00Z',
113
+ price: -4.95,
114
+ },
115
+ {
116
+ point: '2023-10-27T10:00:00Z',
117
+ price: -6.56,
118
+ },
119
+ {
120
+ point: '2023-10-27T14:00:00Z',
121
+ price: -9.63,
122
+ },
123
+ {
124
+ point: '2023-10-27T18:00:00Z',
125
+ price: -9.75,
126
+ },
127
+ ],
128
+ },
129
+ {
130
+ currency: 'EUR',
131
+ power: [
132
+ {
133
+ point: '2023-10-26T22:00:00Z',
134
+ price: -0.01,
135
+ },
136
+ {
137
+ point: '2023-10-27T02:00:00Z',
138
+ price: 0.27,
139
+ },
140
+ {
141
+ point: '2023-10-27T06:00:00Z',
142
+ price: -0.01,
143
+ },
144
+ {
145
+ point: '2023-10-27T10:00:00Z',
146
+ price: -0.52,
147
+ },
148
+ {
149
+ point: '2023-10-27T14:00:00Z',
150
+ price: 2.81,
151
+ },
152
+ {
153
+ point: '2023-10-27T18:00:00Z',
154
+ price: 1.4,
155
+ },
156
+ ],
157
+ },
158
+ {
159
+ currency: 'JPY',
160
+ power: [
161
+ {
162
+ point: '2023-10-26T22:00:00Z',
163
+ price: -0.24,
164
+ },
165
+ {
166
+ point: '2023-10-27T02:00:00Z',
167
+ price: 0.58,
168
+ },
169
+ {
170
+ point: '2023-10-27T06:00:00Z',
171
+ price: 1.59,
172
+ },
173
+ {
174
+ point: '2023-10-27T10:00:00Z',
175
+ price: 3.29,
176
+ },
177
+ {
178
+ point: '2023-10-27T14:00:00Z',
179
+ price: 5.54,
180
+ },
181
+ {
182
+ point: '2023-10-27T18:00:00Z',
183
+ price: 6.27,
184
+ },
185
+ ],
186
+ },
187
+ {
188
+ currency: 'USD',
189
+ power: [
190
+ {
191
+ point: '2023-10-26T22:00:00Z',
192
+ price: 3.8,
193
+ },
194
+ {
195
+ point: '2023-10-27T02:00:00Z',
196
+ price: 3.08,
197
+ },
198
+ {
199
+ point: '2023-10-27T06:00:00Z',
200
+ price: 3.37,
201
+ },
202
+ {
203
+ point: '2023-10-27T10:00:00Z',
204
+ price: 3.51,
205
+ },
206
+ {
207
+ point: '2023-10-27T14:00:00Z',
208
+ price: 3.91,
209
+ },
210
+ {
211
+ point: '2023-10-27T18:00:00Z',
212
+ price: 4.31,
213
+ },
214
+ ],
215
+ },
216
+ ],
217
+ },
218
+ },
219
+ }];
220
+
221
+ export {
222
+ mockResponse,
223
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.types.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "declarationDir": "./dist/types"
7
+ },
8
+ "include": [
9
+ "./src/**/*",
10
+ "../../types/**/*"
11
+ ]
12
+ }