@oanda/labs-spread-cost-calculator-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/SpreadCostCalculatorWidget/Main.js +115 -0
- package/dist/main/SpreadCostCalculatorWidget/Main.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +54 -0
- package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js +46 -0
- package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/constant.js +8 -0
- package/dist/main/SpreadCostCalculatorWidget/constant.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/index.js +28 -0
- package/dist/main/SpreadCostCalculatorWidget/index.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/render.js +51 -0
- package/dist/main/SpreadCostCalculatorWidget/render.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/types.js +6 -0
- package/dist/main/SpreadCostCalculatorWidget/types.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js +24 -0
- package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js +51 -0
- package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -0
- package/dist/main/SpreadCostCalculatorWidget/utils.js +17 -0
- package/dist/main/SpreadCostCalculatorWidget/utils.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 +16 -0
- package/dist/main/gql/types/gql.js.map +1 -0
- package/dist/main/gql/types/graphql.js +223 -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 +11 -0
- package/dist/main/translations/sources/es.json +11 -0
- package/dist/main/translations/sources/th.json +11 -0
- package/dist/main/translations/sources/zh_TW.json +11 -0
- package/dist/main/translations/translations.js +8 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/Main.js +107 -0
- package/dist/module/SpreadCostCalculatorWidget/Main.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +46 -0
- package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js +38 -0
- package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/constant.js +2 -0
- package/dist/module/SpreadCostCalculatorWidget/constant.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/index.js +3 -0
- package/dist/module/SpreadCostCalculatorWidget/index.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/render.js +48 -0
- package/dist/module/SpreadCostCalculatorWidget/render.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/types.js +2 -0
- package/dist/module/SpreadCostCalculatorWidget/types.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js +17 -0
- package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js +44 -0
- package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -0
- package/dist/module/SpreadCostCalculatorWidget/utils.js +10 -0
- package/dist/module/SpreadCostCalculatorWidget/utils.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 +8 -0
- package/dist/module/gql/types/gql.js.map +1 -0
- package/dist/module/gql/types/graphql.js +217 -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 +11 -0
- package/dist/module/translations/sources/es.json +11 -0
- package/dist/module/translations/sources/th.json +11 -0
- package/dist/module/translations/sources/zh_TW.json +11 -0
- package/dist/module/translations/translations.js +2 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/SpreadCostCalculatorWidget/Main.d.ts +4 -0
- package/dist/types/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.d.ts +4 -0
- package/dist/types/SpreadCostCalculatorWidget/ValidationWrapper.d.ts +4 -0
- package/dist/types/SpreadCostCalculatorWidget/constant.d.ts +1 -0
- package/dist/types/SpreadCostCalculatorWidget/index.d.ts +2 -0
- package/dist/types/SpreadCostCalculatorWidget/render.d.ts +1 -0
- package/dist/types/SpreadCostCalculatorWidget/types.d.ts +20 -0
- package/dist/types/SpreadCostCalculatorWidget/useCalculateSpread.d.ts +8 -0
- package/dist/types/SpreadCostCalculatorWidget/useInstrumentChange.d.ts +12 -0
- package/dist/types/SpreadCostCalculatorWidget/utils.d.ts +2 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +37 -0
- package/dist/types/gql/types/graphql.d.ts +389 -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 +1 -0
- package/index.ts +1 -0
- package/lokalise.config.json +18 -0
- package/package.json +26 -0
- package/src/SpreadCostCalculatorWidget/Main.tsx +138 -0
- package/src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx +52 -0
- package/src/SpreadCostCalculatorWidget/ValidationWrapper.tsx +51 -0
- package/src/SpreadCostCalculatorWidget/constant.ts +1 -0
- package/src/SpreadCostCalculatorWidget/index.ts +2 -0
- package/src/SpreadCostCalculatorWidget/render.tsx +60 -0
- package/src/SpreadCostCalculatorWidget/types.ts +27 -0
- package/src/SpreadCostCalculatorWidget/useCalculateSpread.ts +38 -0
- package/src/SpreadCostCalculatorWidget/useInstrumentChange.ts +47 -0
- package/src/SpreadCostCalculatorWidget/utils.ts +12 -0
- package/src/gql/types/fragment-masking.ts +66 -0
- package/src/gql/types/gql.ts +42 -0
- package/src/gql/types/graphql.ts +430 -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 +11 -0
- package/src/translations/sources/es.json +11 -0
- package/src/translations/sources/th.json +11 -0
- package/src/translations/sources/zh_TW.json +11 -0
- package/src/translations/translations.ts +1 -0
- package/test/SpreadCostCalculator.test.tsx +31 -0
- package/test/useCalculateSpread.test.tsx +131 -0
- package/test/useInstrumentChange.test.tsx +54 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1,430 @@
|
|
|
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
|
+
resolveInstrumentsByDivision?: Maybe<Array<Instrument>>;
|
|
176
|
+
sentiment?: Maybe<Array<SentimentInstrument>>;
|
|
177
|
+
sentimentList?: Maybe<Array<SentimentInstrument>>;
|
|
178
|
+
topicalInstruments?: Maybe<Array<TopicalInstrument>>;
|
|
179
|
+
topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
|
|
180
|
+
topicalInstrumentsTotalCount: Scalars['Int']['output'];
|
|
181
|
+
valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
|
|
182
|
+
valueAtRiskChart?: Maybe<ValueAtRiskChart>;
|
|
183
|
+
volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
|
|
184
|
+
volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
export type QueryAssetClassesArgs = {
|
|
189
|
+
division: Division;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
export type QueryCorrelationHeatmapArgs = {
|
|
194
|
+
division: Division;
|
|
195
|
+
instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
|
|
196
|
+
timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
export type QueryCorrelationMatrixArgs = {
|
|
201
|
+
division: Division;
|
|
202
|
+
instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
export type QueryCurrencyPowerBalanceArgs = {
|
|
207
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
export type QueryIsAllowedPartnerArgs = {
|
|
212
|
+
url: Scalars['String']['input'];
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
export type QueryMapInstrumentNamesArgs = {
|
|
217
|
+
division?: InputMaybe<Division>;
|
|
218
|
+
instruments: Array<InputMaybe<Scalars['String']['input']>>;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
export type QueryOrderPositionBooksArgs = {
|
|
223
|
+
bookType: BookType;
|
|
224
|
+
dataSource?: InputMaybe<DataSource>;
|
|
225
|
+
instrument: Scalars['String']['input'];
|
|
226
|
+
recentHours?: InputMaybe<Scalars['Int']['input']>;
|
|
227
|
+
region?: InputMaybe<Region>;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
export type QueryResolveInstrumentsByDivisionArgs = {
|
|
232
|
+
division: Division;
|
|
233
|
+
instruments: Array<InputMaybe<Scalars['String']['input']>>;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
export type QuerySentimentArgs = {
|
|
238
|
+
division?: InputMaybe<Division>;
|
|
239
|
+
name: Scalars['String']['input'];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
export type QuerySentimentListArgs = {
|
|
244
|
+
division?: InputMaybe<Division>;
|
|
245
|
+
sort?: InputMaybe<Sort>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
export type QueryTopicalInstrumentsArgs = {
|
|
250
|
+
assetClass?: InputMaybe<AssetClassName>;
|
|
251
|
+
count?: InputMaybe<Scalars['Int']['input']>;
|
|
252
|
+
division?: InputMaybe<Division>;
|
|
253
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
254
|
+
sort: TopicalSort;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
export type QueryTopicalInstrumentsChartsArgs = {
|
|
259
|
+
division?: InputMaybe<Division>;
|
|
260
|
+
instruments?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
export type QueryTopicalInstrumentsTotalCountArgs = {
|
|
265
|
+
assetClass?: InputMaybe<AssetClassName>;
|
|
266
|
+
division?: InputMaybe<Division>;
|
|
267
|
+
sort: TopicalSort;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
export type QueryValueAtRiskAssetClassesArgs = {
|
|
272
|
+
division?: InputMaybe<Division>;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
export type QueryValueAtRiskChartArgs = {
|
|
277
|
+
bars: ValueAtRiskBars;
|
|
278
|
+
division?: InputMaybe<Division>;
|
|
279
|
+
duration: ValueAtRiskDuration;
|
|
280
|
+
instrument: Scalars['String']['input'];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
export type QueryVolatilityChartArgs = {
|
|
285
|
+
division?: InputMaybe<Division>;
|
|
286
|
+
instrument: Scalars['String']['input'];
|
|
287
|
+
timeSpan: VolatilityChartTimeSpan;
|
|
288
|
+
timeUnit: VolatilityChartTimeUnit;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
export type QueryVolatilityChartAssetClassesArgs = {
|
|
293
|
+
division?: InputMaybe<Division>;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export enum Region {
|
|
297
|
+
Amer = 'AMER',
|
|
298
|
+
Apac = 'APAC',
|
|
299
|
+
Emea = 'EMEA'
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export type Sentiment = {
|
|
303
|
+
__typename?: 'Sentiment';
|
|
304
|
+
longPercent: Scalars['Float']['output'];
|
|
305
|
+
shortPercent: Scalars['Float']['output'];
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export type SentimentInstrument = {
|
|
309
|
+
__typename?: 'SentimentInstrument';
|
|
310
|
+
displayName: Scalars['String']['output'];
|
|
311
|
+
name: Scalars['String']['output'];
|
|
312
|
+
sentiment: Sentiment;
|
|
313
|
+
updatedAt: Scalars['String']['output'];
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export enum Sort {
|
|
317
|
+
Bearish = 'BEARISH',
|
|
318
|
+
Bullish = 'BULLISH'
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export type StrengthRelation = {
|
|
322
|
+
__typename?: 'StrengthRelation';
|
|
323
|
+
currency: CurrencyName;
|
|
324
|
+
percentage: Scalars['Float']['output'];
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export type TimeCorrelation = {
|
|
328
|
+
__typename?: 'TimeCorrelation';
|
|
329
|
+
timeUnit: CorrelationTimeUnit;
|
|
330
|
+
value?: Maybe<Scalars['Float']['output']>;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type TopicalInstrument = {
|
|
334
|
+
__typename?: 'TopicalInstrument';
|
|
335
|
+
assetClass?: Maybe<AssetClassName>;
|
|
336
|
+
displayName: Scalars['String']['output'];
|
|
337
|
+
name: Scalars['String']['output'];
|
|
338
|
+
sentiment: Sentiment;
|
|
339
|
+
updatedAt: Scalars['String']['output'];
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export type TopicalInstrumentChart = {
|
|
343
|
+
__typename?: 'TopicalInstrumentChart';
|
|
344
|
+
chart?: Maybe<Array<Scalars['Float']['output']>>;
|
|
345
|
+
name: Scalars['String']['output'];
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export enum TopicalSort {
|
|
349
|
+
Bearish = 'BEARISH',
|
|
350
|
+
Bullish = 'BULLISH',
|
|
351
|
+
Hot = 'HOT',
|
|
352
|
+
Popular = 'POPULAR',
|
|
353
|
+
Volatile = 'VOLATILE'
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export enum ValueAtRiskBars {
|
|
357
|
+
C100 = 'C100',
|
|
358
|
+
C200 = 'C200',
|
|
359
|
+
C300 = 'C300'
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export type ValueAtRiskChart = {
|
|
363
|
+
__typename?: 'ValueAtRiskChart';
|
|
364
|
+
down: ValueAtRiskChartData;
|
|
365
|
+
up: ValueAtRiskChartData;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export type ValueAtRiskChartData = {
|
|
369
|
+
__typename?: 'ValueAtRiskChartData';
|
|
370
|
+
average: Scalars['Float']['output'];
|
|
371
|
+
max: Scalars['Float']['output'];
|
|
372
|
+
median: Scalars['Float']['output'];
|
|
373
|
+
points?: Maybe<Array<ValueAtRiskChartPoint>>;
|
|
374
|
+
threshold: Scalars['Float']['output'];
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export type ValueAtRiskChartPoint = {
|
|
378
|
+
__typename?: 'ValueAtRiskChartPoint';
|
|
379
|
+
percent: Scalars['Float']['output'];
|
|
380
|
+
pips: Scalars['Float']['output'];
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export enum ValueAtRiskDuration {
|
|
384
|
+
C1 = 'C1',
|
|
385
|
+
C2 = 'C2',
|
|
386
|
+
C3 = 'C3',
|
|
387
|
+
C4 = 'C4',
|
|
388
|
+
C5 = 'C5',
|
|
389
|
+
C10 = 'C10'
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export type VolatilityChart = {
|
|
393
|
+
__typename?: 'VolatilityChart';
|
|
394
|
+
pips: Scalars['Float']['output'];
|
|
395
|
+
/** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
|
|
396
|
+
point: Scalars['String']['output'];
|
|
397
|
+
updatedAt: Scalars['String']['output'];
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export enum VolatilityChartTimeSpan {
|
|
401
|
+
/** Valid for: H */
|
|
402
|
+
D5 = 'D5',
|
|
403
|
+
/** Valid for: H */
|
|
404
|
+
D10 = 'D10',
|
|
405
|
+
/** Valid for: D */
|
|
406
|
+
M1 = 'M1',
|
|
407
|
+
/** Valid for: D */
|
|
408
|
+
M3 = 'M3',
|
|
409
|
+
/** Valid for: W */
|
|
410
|
+
W5 = 'W5',
|
|
411
|
+
/** Valid for: W */
|
|
412
|
+
W10 = 'W10'
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export enum VolatilityChartTimeUnit {
|
|
416
|
+
D = 'D',
|
|
417
|
+
H = 'H',
|
|
418
|
+
W = 'W'
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export type ValidateInstrumentsQueryVariables = Exact<{
|
|
422
|
+
instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
|
|
423
|
+
division?: InputMaybe<Division>;
|
|
424
|
+
}>;
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
export type ValidateInstrumentsQuery = { __typename?: 'Query', mapInstrumentNames?: Array<{ __typename?: 'Instrument', name: string, displayName: string } | null> | null };
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
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,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"absolute_spread_cost": "Absolute Spread Cost",
|
|
3
|
+
"data_unavailable": "Data unavailable",
|
|
4
|
+
"instrument": "Instrument",
|
|
5
|
+
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
|
|
6
|
+
"pips": "Pips",
|
|
7
|
+
"search": "Search",
|
|
8
|
+
"spread": "Spread",
|
|
9
|
+
"units_traded": "Units traded",
|
|
10
|
+
"volume": "Volume"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"absolute_spread_cost": "Coste de spreads absolutos",
|
|
3
|
+
"data_unavailable": "No hay datos disponibles",
|
|
4
|
+
"instrument": "Instrumento",
|
|
5
|
+
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} de {{itemCount}} entradas",
|
|
6
|
+
"pips": "Pips",
|
|
7
|
+
"search": "Buscar",
|
|
8
|
+
"spread": "Spread",
|
|
9
|
+
"units_traded": "Unidades negociadas",
|
|
10
|
+
"volume": "Volumen"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"absolute_spread_cost": "ค่าสเปรดที่แท้จริง",
|
|
3
|
+
"data_unavailable": "ข้อมูลไม่พร้อมใช้งาน",
|
|
4
|
+
"instrument": "ตราสาร",
|
|
5
|
+
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} จาก {{itemCount}} รายการ",
|
|
6
|
+
"pips": "Pips",
|
|
7
|
+
"search": "ค้นหา",
|
|
8
|
+
"spread": "สเปรด",
|
|
9
|
+
"units_traded": "จำนวนหน่วยที่ซื้อขาย",
|
|
10
|
+
"volume": "ปริมาณ"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"absolute_spread_cost": "絕對點差成本",
|
|
3
|
+
"data_unavailable": "沒有數據",
|
|
4
|
+
"instrument": "金融工具",
|
|
5
|
+
"pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
|
|
6
|
+
"pips": "點",
|
|
7
|
+
"search": "搜尋",
|
|
8
|
+
"spread": "點差",
|
|
9
|
+
"units_traded": "交易單位",
|
|
10
|
+
"volume": "交易量"
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultTranslations = {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { render } from '@testing-library/react';
|
|
9
|
+
import { Main } from '../src/SpreadCostCalculatorWidget/Main';
|
|
10
|
+
|
|
11
|
+
describe('Spread Cost Calculator', () => {
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
jest.useFakeTimers();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterAll(() => {
|
|
17
|
+
jest.useRealTimers();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should render spread cost calculator component', async () => {
|
|
21
|
+
// When
|
|
22
|
+
const { findByTestId } = render(
|
|
23
|
+
<Main
|
|
24
|
+
instruments={[{ name: 'EUR_USD', displayName: 'EUR/USD' }]}
|
|
25
|
+
/>,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Then
|
|
29
|
+
expect(await findByTestId('spread-cost-calculator')).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { act, renderHook } from '@testing-library/react';
|
|
6
|
+
import {
|
|
7
|
+
useCalculateSpread,
|
|
8
|
+
UseCalculateSpreadInput,
|
|
9
|
+
} from '../src/SpreadCostCalculatorWidget/useCalculateSpread';
|
|
10
|
+
|
|
11
|
+
describe('spread cost calculator', () => {
|
|
12
|
+
describe('useCalculateSpread', () => {
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
jest.useFakeTimers();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
jest.useRealTimers();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const defaultDelay = 350;
|
|
22
|
+
|
|
23
|
+
const input: UseCalculateSpreadInput = {
|
|
24
|
+
unitsTraded: 10000,
|
|
25
|
+
spread: 1.4,
|
|
26
|
+
pipLocation: -4,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it.each([
|
|
30
|
+
{ ...input, unitsTraded: undefined },
|
|
31
|
+
{ ...input, spread: undefined },
|
|
32
|
+
{ ...input, pipLocation: undefined },
|
|
33
|
+
])(
|
|
34
|
+
'should return undefined, when one of params is undefined (%s)',
|
|
35
|
+
({ unitsTraded, spread, pipLocation }) => {
|
|
36
|
+
// Given
|
|
37
|
+
// When
|
|
38
|
+
const { result } = renderHook(() => useCalculateSpread({
|
|
39
|
+
spread,
|
|
40
|
+
unitsTraded,
|
|
41
|
+
pipLocation,
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
expect(result.current).toBeUndefined();
|
|
45
|
+
|
|
46
|
+
act(() => {
|
|
47
|
+
jest.advanceTimersByTime(defaultDelay);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Then
|
|
51
|
+
expect(result.current).toBeUndefined();
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
it('should return correct calculated values', () => {
|
|
56
|
+
// Given
|
|
57
|
+
// When
|
|
58
|
+
const { result } = renderHook(() => useCalculateSpread({
|
|
59
|
+
...input,
|
|
60
|
+
spread: 2,
|
|
61
|
+
pipLocation: -4,
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
expect(result.current).toBeUndefined();
|
|
65
|
+
|
|
66
|
+
act(() => {
|
|
67
|
+
jest.advanceTimersByTime(defaultDelay);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Then
|
|
71
|
+
expect(result.current).toEqual(1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should return correct calculated values with 0 as pipLocation', () => {
|
|
75
|
+
// Given
|
|
76
|
+
// When
|
|
77
|
+
const { result } = renderHook(() => useCalculateSpread({
|
|
78
|
+
...input,
|
|
79
|
+
spread: 2,
|
|
80
|
+
pipLocation: 0,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
expect(result.current).toBeUndefined();
|
|
84
|
+
|
|
85
|
+
act(() => {
|
|
86
|
+
jest.advanceTimersByTime(defaultDelay);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Then
|
|
90
|
+
expect(result.current).toEqual(10000);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should round up result to 4 decimal places', () => {
|
|
94
|
+
// Given
|
|
95
|
+
// When
|
|
96
|
+
const { result } = renderHook(() => useCalculateSpread({
|
|
97
|
+
...input,
|
|
98
|
+
unitsTraded: 4,
|
|
99
|
+
spread: 1.1,
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
expect(result.current).toBeUndefined();
|
|
103
|
+
|
|
104
|
+
act(() => {
|
|
105
|
+
jest.advanceTimersByTime(defaultDelay);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Then
|
|
109
|
+
expect(result.current).toEqual(0.0003);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should calculate big numbers', () => {
|
|
113
|
+
// Given
|
|
114
|
+
// When
|
|
115
|
+
const { result } = renderHook(() => useCalculateSpread({
|
|
116
|
+
...input,
|
|
117
|
+
unitsTraded: 1122342,
|
|
118
|
+
spread: 123331,
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
expect(result.current).toBeUndefined();
|
|
122
|
+
|
|
123
|
+
act(() => {
|
|
124
|
+
jest.advanceTimersByTime(defaultDelay);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Then
|
|
128
|
+
expect(result.current).toEqual(6920978.0601);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|