@oanda/labs-instrument-live-rate-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.
- package/CHANGELOG.md +8 -0
- package/codegen.ts +15 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +56 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js +77 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +83 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +28 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +25 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +44 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js +17 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js +6 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js +17 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/constant.js +8 -0
- package/dist/main/InstrumentLiveRateWidget/constant.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/render.js +51 -0
- package/dist/main/InstrumentLiveRateWidget/render.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/types.js +20 -0
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/utils.js +43 -0
- package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -0
- package/dist/main/gql/getInstrumentsChart.js +16 -0
- package/dist/main/gql/getInstrumentsChart.js.map +1 -0
- package/dist/main/gql/types/fragment-masking.js +23 -0
- package/dist/main/gql/types/fragment-masking.js.map +1 -0
- package/dist/main/gql/types/gql.js +17 -0
- package/dist/main/gql/types/gql.js.map +1 -0
- package/dist/main/gql/types/graphql.js +326 -0
- package/dist/main/gql/types/graphql.js.map +1 -0
- package/dist/main/gql/types/index.js +28 -0
- package/dist/main/gql/types/index.js.map +1 -0
- package/dist/main/gql/validateInstruments.js +16 -0
- package/dist/main/gql/validateInstruments.js.map +1 -0
- package/dist/main/index.js +28 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/translations/index.js +27 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +4 -0
- package/dist/main/translations/sources/es.json +4 -0
- package/dist/main/translations/sources/th.json +4 -0
- package/dist/main/translations/sources/zh_TW.json +4 -0
- package/dist/main/translations/translations.js +11 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +49 -0
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/Main.js +69 -0
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +74 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +18 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +37 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/constant.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/constant.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/render.js +48 -0
- package/dist/module/InstrumentLiveRateWidget/render.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/types.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/utils.js +36 -0
- package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -0
- package/dist/module/gql/getInstrumentsChart.js +10 -0
- package/dist/module/gql/getInstrumentsChart.js.map +1 -0
- package/dist/module/gql/types/fragment-masking.js +15 -0
- package/dist/module/gql/types/fragment-masking.js.map +1 -0
- package/dist/module/gql/types/gql.js +9 -0
- package/dist/module/gql/types/gql.js.map +1 -0
- package/dist/module/gql/types/graphql.js +320 -0
- package/dist/module/gql/types/graphql.js.map +1 -0
- package/dist/module/gql/types/index.js +3 -0
- package/dist/module/gql/types/index.js.map +1 -0
- package/dist/module/gql/validateInstruments.js +10 -0
- package/dist/module/gql/validateInstruments.js.map +1 -0
- package/dist/module/index.js +3 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/translations/index.js +20 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +4 -0
- package/dist/module/translations/sources/es.json +4 -0
- package/dist/module/translations/sources/th.json +4 -0
- package/dist/module/translations/sources/zh_TW.json +4 -0
- package/dist/module/translations/translations.js +5 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/InstrumentLiveRateWidget/InstrumentLiveRateWidget.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/Main.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.d.ts +3 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +11 -0
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/constant.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/render.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +43 -0
- package/dist/types/InstrumentLiveRateWidget/utils.d.ts +12 -0
- package/dist/types/gql/getInstrumentsChart.d.ts +1 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +45 -0
- package/dist/types/gql/types/graphql.d.ts +397 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/gql/validateInstruments.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/translations/index.d.ts +4 -0
- package/dist/types/translations/translations.d.ts +4 -0
- package/index.ts +1 -0
- package/lokalise.config.json +18 -0
- package/package.json +25 -0
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +57 -0
- package/src/InstrumentLiveRateWidget/Main.tsx +82 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +92 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +2 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.ts +25 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +48 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +12 -0
- package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/constant.ts +5 -0
- package/src/InstrumentLiveRateWidget/render.tsx +48 -0
- package/src/InstrumentLiveRateWidget/types.tsx +50 -0
- package/src/InstrumentLiveRateWidget/utils.ts +49 -0
- package/src/gql/getInstrumentsChart.ts +10 -0
- package/src/gql/types/fragment-masking.ts +66 -0
- package/src/gql/types/gql.ts +47 -0
- package/src/gql/types/graphql.ts +432 -0
- package/src/gql/types/index.ts +2 -0
- package/src/gql/validateInstruments.ts +10 -0
- package/src/index.ts +2 -0
- package/src/translations/index.ts +17 -0
- package/src/translations/sources/en.json +4 -0
- package/src/translations/sources/es.json +4 -0
- package/src/translations/sources/th.json +4 -0
- package/src/translations/sources/zh_TW.json +4 -0
- package/src/translations/translations.ts +4 -0
- package/test/LineChartWithData.test.tsx +164 -0
- package/test/Main.test.tsx +27 -0
- package/test/components/InstrumentRateWithData.test.tsx +62 -0
- package/test/components/utils.test.ts +13 -0
- package/test/mocks.ts +52 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1,432 @@
|
|
|
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: Array<Instrument>;
|
|
22
|
+
name: Scalars['String']['output'];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export enum AssetClassName {
|
|
26
|
+
Commodities = 'COMMODITIES',
|
|
27
|
+
Cryptocurrency = 'CRYPTOCURRENCY',
|
|
28
|
+
Currency = 'CURRENCY',
|
|
29
|
+
EquityShares = 'EQUITY_SHARES',
|
|
30
|
+
Indices = 'INDICES',
|
|
31
|
+
Rates = 'RATES'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export enum BookType {
|
|
35
|
+
Order = 'ORDER',
|
|
36
|
+
Position = 'POSITION'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type CorrelationHeatmap = {
|
|
40
|
+
__typename?: 'CorrelationHeatmap';
|
|
41
|
+
baseInstrument: Instrument;
|
|
42
|
+
heatmap: Array<Heatmap>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type CorrelationMatrix = {
|
|
46
|
+
__typename?: 'CorrelationMatrix';
|
|
47
|
+
baseTimeUnit: CorrelationTimeUnit;
|
|
48
|
+
matrix: Array<Matrix>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export enum CorrelationTimeUnit {
|
|
52
|
+
H1 = 'H1',
|
|
53
|
+
H4 = 'H4',
|
|
54
|
+
H24 = 'H24',
|
|
55
|
+
M1 = 'M1',
|
|
56
|
+
M3 = 'M3',
|
|
57
|
+
M6 = 'M6',
|
|
58
|
+
W1 = 'W1',
|
|
59
|
+
Y1 = 'Y1'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export enum CurrencyName {
|
|
63
|
+
Aud = 'AUD',
|
|
64
|
+
Cad = 'CAD',
|
|
65
|
+
Chf = 'CHF',
|
|
66
|
+
Eur = 'EUR',
|
|
67
|
+
Gbp = 'GBP',
|
|
68
|
+
Jpy = 'JPY',
|
|
69
|
+
Nzd = 'NZD',
|
|
70
|
+
Usd = 'USD'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type CurrencyPower = {
|
|
74
|
+
__typename?: 'CurrencyPower';
|
|
75
|
+
/** UTC Timestamp */
|
|
76
|
+
point: Scalars['String']['output'];
|
|
77
|
+
price: Scalars['Float']['output'];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type CurrencyPowerBalance = {
|
|
81
|
+
__typename?: 'CurrencyPowerBalance';
|
|
82
|
+
currency: CurrencyName;
|
|
83
|
+
power: Array<CurrencyPower>;
|
|
84
|
+
updatedAt: Scalars['String']['output'];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export enum CurrencyPowerBalanceTimeUnit {
|
|
88
|
+
CurrentDay = 'CURRENT_DAY',
|
|
89
|
+
H4 = 'H4',
|
|
90
|
+
H8 = 'H8',
|
|
91
|
+
H24 = 'H24',
|
|
92
|
+
M1 = 'M1',
|
|
93
|
+
M3 = 'M3',
|
|
94
|
+
PreviousDay = 'PREVIOUS_DAY',
|
|
95
|
+
W1 = 'W1'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type CurrencyStrength = {
|
|
99
|
+
__typename?: 'CurrencyStrength';
|
|
100
|
+
currency: CurrencyName;
|
|
101
|
+
strengthRelation?: Maybe<Array<StrengthRelation>>;
|
|
102
|
+
updatedAt: Scalars['String']['output'];
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export enum DataSource {
|
|
106
|
+
Ny4 = 'NY4',
|
|
107
|
+
Ty3 = 'TY3'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export enum Division {
|
|
111
|
+
Oap = 'OAP',
|
|
112
|
+
Oau = 'OAU',
|
|
113
|
+
Oc = 'OC',
|
|
114
|
+
Ocan = 'OCAN',
|
|
115
|
+
Oel = 'OEL',
|
|
116
|
+
Ogm = 'OGM',
|
|
117
|
+
Oj = 'OJ',
|
|
118
|
+
Opt = 'OPT',
|
|
119
|
+
Otms = 'OTMS'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type Heatmap = {
|
|
123
|
+
__typename?: 'Heatmap';
|
|
124
|
+
instrument: Instrument;
|
|
125
|
+
timeCorrelation: Array<TimeCorrelation>;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type Instrument = {
|
|
129
|
+
__typename?: 'Instrument';
|
|
130
|
+
displayName: Scalars['String']['output'];
|
|
131
|
+
name: Scalars['String']['output'];
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type InstrumentCorrelation = {
|
|
135
|
+
__typename?: 'InstrumentCorrelation';
|
|
136
|
+
instrument: Instrument;
|
|
137
|
+
value?: Maybe<Scalars['Float']['output']>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type Matrix = {
|
|
141
|
+
__typename?: 'Matrix';
|
|
142
|
+
instrument: Instrument;
|
|
143
|
+
instrumentCorrelation: Array<InstrumentCorrelation>;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type OrderPositionBucket = {
|
|
147
|
+
__typename?: 'OrderPositionBucket';
|
|
148
|
+
longCountPercent: Scalars['Float']['output'];
|
|
149
|
+
price: Scalars['Float']['output'];
|
|
150
|
+
shortCountPercent: Scalars['Float']['output'];
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type OrderPositionData = {
|
|
154
|
+
__typename?: 'OrderPositionData';
|
|
155
|
+
bucketWidth: Scalars['Float']['output'];
|
|
156
|
+
buckets: Array<Maybe<OrderPositionBucket>>;
|
|
157
|
+
dataSource?: Maybe<Scalars['String']['output']>;
|
|
158
|
+
instrument: Scalars['String']['output'];
|
|
159
|
+
price?: Maybe<Scalars['Float']['output']>;
|
|
160
|
+
region?: Maybe<Scalars['String']['output']>;
|
|
161
|
+
time: Scalars['String']['output'];
|
|
162
|
+
unixTime: Scalars['Int']['output'];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type Query = {
|
|
166
|
+
__typename?: 'Query';
|
|
167
|
+
assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
|
|
168
|
+
correlationHeatmap: CorrelationHeatmap;
|
|
169
|
+
correlationMatrix: CorrelationMatrix;
|
|
170
|
+
currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
|
|
171
|
+
currencyStrength?: Maybe<Array<CurrencyStrength>>;
|
|
172
|
+
isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
|
|
173
|
+
mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
|
|
174
|
+
orderPositionBooks: Array<Maybe<OrderPositionData>>;
|
|
175
|
+
sentiment?: Maybe<Array<SentimentInstrument>>;
|
|
176
|
+
sentimentList?: Maybe<Array<SentimentInstrument>>;
|
|
177
|
+
topicalInstruments?: Maybe<Array<TopicalInstrument>>;
|
|
178
|
+
topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
|
|
179
|
+
topicalInstrumentsTotalCount: Scalars['Int']['output'];
|
|
180
|
+
valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
|
|
181
|
+
valueAtRiskChart?: Maybe<ValueAtRiskChart>;
|
|
182
|
+
volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
|
|
183
|
+
volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
export type QueryAssetClassesArgs = {
|
|
188
|
+
division: Division;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
export type QueryCorrelationHeatmapArgs = {
|
|
193
|
+
division: Division;
|
|
194
|
+
instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
|
|
195
|
+
timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
export type QueryCorrelationMatrixArgs = {
|
|
200
|
+
division: Division;
|
|
201
|
+
instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
export type QueryCurrencyPowerBalanceArgs = {
|
|
206
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
export type QueryIsAllowedPartnerArgs = {
|
|
211
|
+
url: Scalars['String']['input'];
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
export type QueryMapInstrumentNamesArgs = {
|
|
216
|
+
division?: InputMaybe<Division>;
|
|
217
|
+
instruments: Array<InputMaybe<Scalars['String']['input']>>;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
export type QueryOrderPositionBooksArgs = {
|
|
222
|
+
bookType: BookType;
|
|
223
|
+
dataSource?: InputMaybe<DataSource>;
|
|
224
|
+
instrument: Scalars['String']['input'];
|
|
225
|
+
recentHours?: InputMaybe<Scalars['Int']['input']>;
|
|
226
|
+
region?: InputMaybe<Region>;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
export type QuerySentimentArgs = {
|
|
231
|
+
division?: InputMaybe<Division>;
|
|
232
|
+
name: Scalars['String']['input'];
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
export type QuerySentimentListArgs = {
|
|
237
|
+
division?: InputMaybe<Division>;
|
|
238
|
+
sort?: InputMaybe<Sort>;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
export type QueryTopicalInstrumentsArgs = {
|
|
243
|
+
assetClass?: InputMaybe<AssetClassName>;
|
|
244
|
+
count?: InputMaybe<Scalars['Int']['input']>;
|
|
245
|
+
division?: InputMaybe<Division>;
|
|
246
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
247
|
+
sort: TopicalSort;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
export type QueryTopicalInstrumentsChartsArgs = {
|
|
252
|
+
division?: InputMaybe<Division>;
|
|
253
|
+
instruments?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
export type QueryTopicalInstrumentsTotalCountArgs = {
|
|
258
|
+
assetClass?: InputMaybe<AssetClassName>;
|
|
259
|
+
division?: InputMaybe<Division>;
|
|
260
|
+
sort: TopicalSort;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
export type QueryValueAtRiskAssetClassesArgs = {
|
|
265
|
+
division?: InputMaybe<Division>;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
export type QueryValueAtRiskChartArgs = {
|
|
270
|
+
bars: ValueAtRiskBars;
|
|
271
|
+
division?: InputMaybe<Division>;
|
|
272
|
+
duration: ValueAtRiskDuration;
|
|
273
|
+
instrument: Scalars['String']['input'];
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
export type QueryVolatilityChartArgs = {
|
|
278
|
+
division?: InputMaybe<Division>;
|
|
279
|
+
instrument: Scalars['String']['input'];
|
|
280
|
+
timeSpan: VolatilityChartTimeSpan;
|
|
281
|
+
timeUnit: VolatilityChartTimeUnit;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
export type QueryVolatilityChartAssetClassesArgs = {
|
|
286
|
+
division?: InputMaybe<Division>;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export enum Region {
|
|
290
|
+
Amer = 'AMER',
|
|
291
|
+
Apac = 'APAC',
|
|
292
|
+
Emea = 'EMEA'
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type Sentiment = {
|
|
296
|
+
__typename?: 'Sentiment';
|
|
297
|
+
longPercent: Scalars['Float']['output'];
|
|
298
|
+
shortPercent: Scalars['Float']['output'];
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export type SentimentInstrument = {
|
|
302
|
+
__typename?: 'SentimentInstrument';
|
|
303
|
+
displayName: Scalars['String']['output'];
|
|
304
|
+
name: Scalars['String']['output'];
|
|
305
|
+
sentiment: Sentiment;
|
|
306
|
+
updatedAt: Scalars['String']['output'];
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export enum Sort {
|
|
310
|
+
Bearish = 'BEARISH',
|
|
311
|
+
Bullish = 'BULLISH'
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export type StrengthRelation = {
|
|
315
|
+
__typename?: 'StrengthRelation';
|
|
316
|
+
currency: CurrencyName;
|
|
317
|
+
percentage: Scalars['Float']['output'];
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
export type TimeCorrelation = {
|
|
321
|
+
__typename?: 'TimeCorrelation';
|
|
322
|
+
timeUnit: CorrelationTimeUnit;
|
|
323
|
+
value?: Maybe<Scalars['Float']['output']>;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export type TopicalInstrument = {
|
|
327
|
+
__typename?: 'TopicalInstrument';
|
|
328
|
+
assetClass?: Maybe<AssetClassName>;
|
|
329
|
+
displayName: Scalars['String']['output'];
|
|
330
|
+
name: Scalars['String']['output'];
|
|
331
|
+
sentiment: Sentiment;
|
|
332
|
+
updatedAt: Scalars['String']['output'];
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type TopicalInstrumentChart = {
|
|
336
|
+
__typename?: 'TopicalInstrumentChart';
|
|
337
|
+
chart?: Maybe<Array<Scalars['Float']['output']>>;
|
|
338
|
+
name: Scalars['String']['output'];
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export enum TopicalSort {
|
|
342
|
+
Bearish = 'BEARISH',
|
|
343
|
+
Bullish = 'BULLISH',
|
|
344
|
+
Hot = 'HOT',
|
|
345
|
+
Popular = 'POPULAR',
|
|
346
|
+
Volatile = 'VOLATILE'
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export enum ValueAtRiskBars {
|
|
350
|
+
C100 = 'C100',
|
|
351
|
+
C200 = 'C200',
|
|
352
|
+
C300 = 'C300'
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export type ValueAtRiskChart = {
|
|
356
|
+
__typename?: 'ValueAtRiskChart';
|
|
357
|
+
down: ValueAtRiskChartData;
|
|
358
|
+
up: ValueAtRiskChartData;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export type ValueAtRiskChartData = {
|
|
362
|
+
__typename?: 'ValueAtRiskChartData';
|
|
363
|
+
average: Scalars['Float']['output'];
|
|
364
|
+
max: Scalars['Float']['output'];
|
|
365
|
+
median: Scalars['Float']['output'];
|
|
366
|
+
points?: Maybe<Array<ValueAtRiskChartPoint>>;
|
|
367
|
+
threshold: Scalars['Float']['output'];
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export type ValueAtRiskChartPoint = {
|
|
371
|
+
__typename?: 'ValueAtRiskChartPoint';
|
|
372
|
+
percent: Scalars['Float']['output'];
|
|
373
|
+
pips: Scalars['Float']['output'];
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export enum ValueAtRiskDuration {
|
|
377
|
+
C1 = 'C1',
|
|
378
|
+
C2 = 'C2',
|
|
379
|
+
C3 = 'C3',
|
|
380
|
+
C4 = 'C4',
|
|
381
|
+
C5 = 'C5',
|
|
382
|
+
C10 = 'C10'
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export type VolatilityChart = {
|
|
386
|
+
__typename?: 'VolatilityChart';
|
|
387
|
+
pips: Scalars['Float']['output'];
|
|
388
|
+
/** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
|
|
389
|
+
point: Scalars['String']['output'];
|
|
390
|
+
updatedAt: Scalars['String']['output'];
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export enum VolatilityChartTimeSpan {
|
|
394
|
+
/** Valid for: H */
|
|
395
|
+
D5 = 'D5',
|
|
396
|
+
/** Valid for: H */
|
|
397
|
+
D10 = 'D10',
|
|
398
|
+
/** Valid for: D */
|
|
399
|
+
M1 = 'M1',
|
|
400
|
+
/** Valid for: D */
|
|
401
|
+
M3 = 'M3',
|
|
402
|
+
/** Valid for: W */
|
|
403
|
+
W5 = 'W5',
|
|
404
|
+
/** Valid for: W */
|
|
405
|
+
W10 = 'W10'
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export enum VolatilityChartTimeUnit {
|
|
409
|
+
D = 'D',
|
|
410
|
+
H = 'H',
|
|
411
|
+
W = 'W'
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export type GetInstrumentsChartQueryVariables = Exact<{
|
|
415
|
+
instruments?: InputMaybe<Array<Scalars['String']['input']> | Scalars['String']['input']>;
|
|
416
|
+
division?: InputMaybe<Division>;
|
|
417
|
+
}>;
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
export type GetInstrumentsChartQuery = { __typename?: 'Query', topicalInstrumentsCharts?: Array<{ __typename?: 'TopicalInstrumentChart', name: string, chart?: Array<number> | null }> | null };
|
|
421
|
+
|
|
422
|
+
export type ValidateInstrumentsQueryVariables = Exact<{
|
|
423
|
+
instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
|
|
424
|
+
division?: InputMaybe<Division>;
|
|
425
|
+
}>;
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
export type ValidateInstrumentsQuery = { __typename?: 'Query', mapInstrumentNames?: Array<{ __typename?: 'Instrument', name: string, displayName: string } | null> | null };
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
export const GetInstrumentsChartDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetInstrumentsChart"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"division"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"topicalInstrumentsCharts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"instruments"},"value":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}}},{"kind":"Argument","name":{"kind":"Name","value":"division"},"value":{"kind":"Variable","name":{"kind":"Name","value":"division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"chart"}}]}}]}}]} as unknown as DocumentNode<GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables>;
|
|
432
|
+
export const ValidateInstrumentsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"validateInstruments"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"division"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"mapInstrumentNames"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"instruments"},"value":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}}},{"kind":"Argument","name":{"kind":"Name","value":"division"},"value":{"kind":"Variable","name":{"kind":"Name","value":"division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}}]}}]}}]} as unknown as DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const validateInstruments = gql`
|
|
4
|
+
query validateInstruments($instruments: [String]!, $division: Division) {
|
|
5
|
+
mapInstrumentNames(instruments: $instruments, division: $division) {
|
|
6
|
+
name
|
|
7
|
+
displayName
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Locale, Translations } from '@oanda/mono-i18n';
|
|
2
|
+
|
|
3
|
+
import en from './sources/en.json';
|
|
4
|
+
import zhTW from './sources/zh_TW.json';
|
|
5
|
+
import es from './sources/es.json';
|
|
6
|
+
import th from './sources/th.json';
|
|
7
|
+
|
|
8
|
+
import { defaultTranslations } from './translations';
|
|
9
|
+
|
|
10
|
+
export type TranslationKey = keyof typeof defaultTranslations;
|
|
11
|
+
|
|
12
|
+
export const translations: Translations = {
|
|
13
|
+
[Locale.en]: { translation: en },
|
|
14
|
+
[Locale.zhTW]: { translation: zhTW },
|
|
15
|
+
[Locale.es]: { translation: es },
|
|
16
|
+
[Locale.th]: { translation: th },
|
|
17
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { lightTheme } from '@oanda/labs-widget-common';
|
|
8
|
+
import { LineChartWithData } from '../src/InstrumentLiveRateWidget/components/LineChartWithData';
|
|
9
|
+
import { getInstrumentsChart } from '../src/gql/getInstrumentsChart';
|
|
10
|
+
import { Division } from '../src/gql/types/graphql';
|
|
11
|
+
|
|
12
|
+
const chartPointsMocks = [
|
|
13
|
+
{
|
|
14
|
+
request: {
|
|
15
|
+
query: getInstrumentsChart,
|
|
16
|
+
variables: {
|
|
17
|
+
instruments: ['EUR_USD'],
|
|
18
|
+
division: 'OC',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
result: {
|
|
22
|
+
data: {
|
|
23
|
+
topicalInstrumentsCharts: [
|
|
24
|
+
{
|
|
25
|
+
name: 'EUR_USD',
|
|
26
|
+
displayName: 'EUR_USD',
|
|
27
|
+
chart: [
|
|
28
|
+
1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
|
|
29
|
+
1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
|
|
30
|
+
1.05556,
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const chartsPointsBelowTenMocks = [
|
|
40
|
+
{
|
|
41
|
+
request: {
|
|
42
|
+
query: getInstrumentsChart,
|
|
43
|
+
variables: {
|
|
44
|
+
instruments: ['CAD_JPY'],
|
|
45
|
+
division: 'OC',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
result: {
|
|
49
|
+
data: {
|
|
50
|
+
topicalInstrumentsCharts: [
|
|
51
|
+
{
|
|
52
|
+
name: 'CAD_JPY',
|
|
53
|
+
displayName: 'CAD_JPY',
|
|
54
|
+
chart: [0.8601, 0.85996, 0.85962, 0.86022, 0.8592],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
describe('LineChartWithData component', () => {
|
|
63
|
+
const record = {
|
|
64
|
+
instrument: 'EUR_USD',
|
|
65
|
+
displayName: 'EUR_USD',
|
|
66
|
+
buy: 1.04508,
|
|
67
|
+
sell: 1.04523,
|
|
68
|
+
spread: 1.2,
|
|
69
|
+
dailyPercentChange: '+3,23%',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
it('should render line chart', async () => {
|
|
73
|
+
const { findByTestId } = render(
|
|
74
|
+
<MockedProvider mocks={chartPointsMocks}>
|
|
75
|
+
<LineChartWithData
|
|
76
|
+
isLoading={false}
|
|
77
|
+
division={Division.Oc}
|
|
78
|
+
record={record}
|
|
79
|
+
color={lightTheme.textOk}
|
|
80
|
+
/>
|
|
81
|
+
</MockedProvider>,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(await findByTestId('line-chart')).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
it('should render line chart in green', async () => {
|
|
87
|
+
const { findByTestId, container } = render(
|
|
88
|
+
<MockedProvider mocks={chartPointsMocks}>
|
|
89
|
+
<LineChartWithData
|
|
90
|
+
isLoading={false}
|
|
91
|
+
division={Division.Oc}
|
|
92
|
+
record={record}
|
|
93
|
+
color={lightTheme.textOk}
|
|
94
|
+
/>
|
|
95
|
+
</MockedProvider>,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(await findByTestId('line-chart')).toBeInTheDocument();
|
|
99
|
+
|
|
100
|
+
expect(container.querySelector('path')).toHaveAttribute(
|
|
101
|
+
'stroke',
|
|
102
|
+
'#00884E',
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
it('should render line chart in red', async () => {
|
|
106
|
+
record.dailyPercentChange = '-1.56%';
|
|
107
|
+
|
|
108
|
+
const { findByTestId, container } = render(
|
|
109
|
+
<MockedProvider mocks={chartPointsMocks}>
|
|
110
|
+
<LineChartWithData
|
|
111
|
+
isLoading={false}
|
|
112
|
+
division={Division.Oc}
|
|
113
|
+
record={record}
|
|
114
|
+
color={lightTheme.textDanger}
|
|
115
|
+
/>
|
|
116
|
+
</MockedProvider>,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(await findByTestId('line-chart')).toBeInTheDocument();
|
|
120
|
+
|
|
121
|
+
expect(container.querySelector('path')).toHaveAttribute(
|
|
122
|
+
'stroke',
|
|
123
|
+
'#E41F37',
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
it('should render line chart in grey', async () => {
|
|
127
|
+
record.dailyPercentChange = '0%';
|
|
128
|
+
|
|
129
|
+
const { findByTestId, container } = render(
|
|
130
|
+
<MockedProvider mocks={chartPointsMocks}>
|
|
131
|
+
<LineChartWithData
|
|
132
|
+
isLoading={false}
|
|
133
|
+
division={Division.Oc}
|
|
134
|
+
record={record}
|
|
135
|
+
color={lightTheme.textDisabled}
|
|
136
|
+
/>
|
|
137
|
+
</MockedProvider>,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(await findByTestId('line-chart')).toBeInTheDocument();
|
|
141
|
+
|
|
142
|
+
expect(container.querySelector('path')).toHaveAttribute(
|
|
143
|
+
'stroke',
|
|
144
|
+
'#7B8085',
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
it('should render empty value when number of points is below 10', async () => {
|
|
148
|
+
record.instrument = 'CAD_JPY';
|
|
149
|
+
|
|
150
|
+
const { queryByTestId, findByTestId } = render(
|
|
151
|
+
<MockedProvider mocks={chartsPointsBelowTenMocks}>
|
|
152
|
+
<LineChartWithData
|
|
153
|
+
isLoading={false}
|
|
154
|
+
division={Division.Oc}
|
|
155
|
+
record={record}
|
|
156
|
+
color={lightTheme.textOk}
|
|
157
|
+
/>
|
|
158
|
+
</MockedProvider>,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
expect(await queryByTestId('line-chart')).not.toBeInTheDocument();
|
|
162
|
+
expect(await findByTestId('line-chart-empty-value')).toBeInTheDocument();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { ThemeContext, Size } from '@oanda/labs-widget-common';
|
|
8
|
+
import { Main } from '../src/InstrumentLiveRateWidget/Main';
|
|
9
|
+
import { Division } from '../src/gql/types/graphql';
|
|
10
|
+
import { widgetMocks } from './mocks';
|
|
11
|
+
|
|
12
|
+
describe('Main component', () => {
|
|
13
|
+
it('should render table component', async () => {
|
|
14
|
+
const { findByTestId } = render(
|
|
15
|
+
<MockedProvider mocks={widgetMocks}>
|
|
16
|
+
<ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
|
|
17
|
+
<Main
|
|
18
|
+
division={Division.Oc}
|
|
19
|
+
instrument="EUR_USD"
|
|
20
|
+
/>
|
|
21
|
+
</ThemeContext.Provider>
|
|
22
|
+
</MockedProvider>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(await findByTestId('instrument-live-rate-wrapper')).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
});
|