@oanda/labs-currency-strength-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/CurrencyStrengthWidget/ChartsWithData.js +50 -0
- package/dist/main/CurrencyStrengthWidget/ChartsWithData.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js +37 -0
- package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/Main.js +22 -0
- package/dist/main/CurrencyStrengthWidget/Main.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/Chart.js +50 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/Chart.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js +22 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js +18 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js +121 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/index.js +17 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/index.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/types.js +6 -0
- package/dist/main/CurrencyStrengthWidget/components/Chart/types.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/index.js +17 -0
- package/dist/main/CurrencyStrengthWidget/index.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/render.js +34 -0
- package/dist/main/CurrencyStrengthWidget/render.js.map +1 -0
- package/dist/main/CurrencyStrengthWidget/types.js +6 -0
- package/dist/main/CurrencyStrengthWidget/types.js.map +1 -0
- package/dist/main/gql/getCurrencyStrength.js +11 -0
- package/dist/main/gql/getCurrencyStrength.js.map +1 -0
- package/dist/main/gql/types/fragment-masking.js +24 -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 +137 -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/index.js +17 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/translations/index.js +19 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +6 -0
- package/dist/main/translations/sources/zh_TW.json +6 -0
- package/dist/main/translations/translations.js +8 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/ChartsWithData.js +41 -0
- package/dist/module/CurrencyStrengthWidget/ChartsWithData.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js +30 -0
- package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/Main.js +15 -0
- package/dist/module/CurrencyStrengthWidget/Main.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/Chart.js +41 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/Chart.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js +16 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js +11 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js +114 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/index.js +2 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/index.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/types.js +2 -0
- package/dist/module/CurrencyStrengthWidget/components/Chart/types.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/index.js +2 -0
- package/dist/module/CurrencyStrengthWidget/index.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/render.js +31 -0
- package/dist/module/CurrencyStrengthWidget/render.js.map +1 -0
- package/dist/module/CurrencyStrengthWidget/types.js +2 -0
- package/dist/module/CurrencyStrengthWidget/types.js.map +1 -0
- package/dist/module/gql/getCurrencyStrength.js +6 -0
- package/dist/module/gql/getCurrencyStrength.js.map +1 -0
- package/dist/module/gql/types/fragment-masking.js +16 -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 +131 -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/index.js +2 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/translations/index.js +12 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +6 -0
- package/dist/module/translations/sources/zh_TW.json +6 -0
- package/dist/module/translations/translations.js +2 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/CurrencyStrengthWidget/ChartsWithData.d.ts +3 -0
- package/dist/types/CurrencyStrengthWidget/CurrencyStrengthWidget.d.ts +4 -0
- package/dist/types/CurrencyStrengthWidget/Main.d.ts +3 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/Chart.d.ts +4 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/constants.d.ts +14 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/formatters.d.ts +2 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/getOption.d.ts +169 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/index.d.ts +1 -0
- package/dist/types/CurrencyStrengthWidget/components/Chart/types.d.ts +22 -0
- package/dist/types/CurrencyStrengthWidget/index.d.ts +1 -0
- package/dist/types/CurrencyStrengthWidget/render.d.ts +1 -0
- package/dist/types/CurrencyStrengthWidget/types.d.ts +11 -0
- package/dist/types/gql/getCurrencyStrength.d.ts +2 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +36 -0
- package/dist/types/gql/types/graphql.d.ts +282 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/index.d.ts +1 -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 +29 -0
- package/src/CurrencyStrengthWidget/ChartsWithData.tsx +53 -0
- package/src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx +32 -0
- package/src/CurrencyStrengthWidget/Main.tsx +18 -0
- package/src/CurrencyStrengthWidget/components/Chart/Chart.tsx +48 -0
- package/src/CurrencyStrengthWidget/components/Chart/constants.tsx +18 -0
- package/src/CurrencyStrengthWidget/components/Chart/formatters.ts +13 -0
- package/src/CurrencyStrengthWidget/components/Chart/getOption.ts +109 -0
- package/src/CurrencyStrengthWidget/components/Chart/index.ts +1 -0
- package/src/CurrencyStrengthWidget/components/Chart/types.ts +25 -0
- package/src/CurrencyStrengthWidget/index.ts +1 -0
- package/src/CurrencyStrengthWidget/render.tsx +34 -0
- package/src/CurrencyStrengthWidget/types.ts +13 -0
- package/src/gql/getCurrencyStrength.ts +15 -0
- package/src/gql/types/fragment-masking.ts +66 -0
- package/src/gql/types/gql.ts +42 -0
- package/src/gql/types/graphql.ts +290 -0
- package/src/gql/types/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/translations/index.ts +13 -0
- package/src/translations/sources/en.json +6 -0
- package/src/translations/sources/zh_TW.json +6 -0
- package/src/translations/translations.ts +3 -0
- package/test/Main.test.tsx +28 -0
- package/test/chartOptions.test.ts +18 -0
- package/test/mocks/currencyStrengthMock.ts +270 -0
- package/test/mocks/index.ts +2 -0
- package/test/mocks/responsesMocks.ts +19 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as types from './graphql';
|
|
2
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
/**
|
|
4
|
+
* Map of all GraphQL operations in the project.
|
|
5
|
+
*
|
|
6
|
+
* This map has several performance disadvantages:
|
|
7
|
+
* 1. It is not tree-shakeable, so it will include all operations in the project.
|
|
8
|
+
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
|
|
9
|
+
* 3. It does not support dead code elimination, so it will add unused operations.
|
|
10
|
+
*
|
|
11
|
+
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
12
|
+
*/
|
|
13
|
+
declare const documents: {
|
|
14
|
+
"\n query GetCurrencyStrength {\n currencyStrength {\n currency\n strengthRelation {\n currency\n percentage\n }\n }\n }\n": DocumentNode<types.GetCurrencyStrengthQuery, types.Exact<{
|
|
15
|
+
[key: string]: never;
|
|
16
|
+
}>>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The query argument is unknown!
|
|
28
|
+
* Please regenerate the types.
|
|
29
|
+
*/
|
|
30
|
+
export declare function graphql(source: string): unknown;
|
|
31
|
+
/**
|
|
32
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
33
|
+
*/
|
|
34
|
+
export declare function graphql(source: "\n query GetCurrencyStrength {\n currencyStrength {\n currency\n strengthRelation {\n currency\n percentage\n }\n }\n }\n"): (typeof documents)["\n query GetCurrencyStrength {\n currencyStrength {\n currency\n strengthRelation {\n currency\n percentage\n }\n }\n }\n"];
|
|
35
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
export type Maybe<T> = T | null;
|
|
3
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
4
|
+
export type Exact<T extends {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
};
|
|
9
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
10
|
+
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
11
|
+
};
|
|
12
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
13
|
+
[SubKey in K]: Maybe<T[SubKey]>;
|
|
14
|
+
};
|
|
15
|
+
export type MakeEmpty<T extends {
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}, K extends keyof T> = {
|
|
18
|
+
[_ in K]?: never;
|
|
19
|
+
};
|
|
20
|
+
export type Incremental<T> = T | {
|
|
21
|
+
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
|
|
22
|
+
};
|
|
23
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
24
|
+
export type Scalars = {
|
|
25
|
+
ID: {
|
|
26
|
+
input: string;
|
|
27
|
+
output: string;
|
|
28
|
+
};
|
|
29
|
+
String: {
|
|
30
|
+
input: string;
|
|
31
|
+
output: string;
|
|
32
|
+
};
|
|
33
|
+
Boolean: {
|
|
34
|
+
input: boolean;
|
|
35
|
+
output: boolean;
|
|
36
|
+
};
|
|
37
|
+
Int: {
|
|
38
|
+
input: number;
|
|
39
|
+
output: number;
|
|
40
|
+
};
|
|
41
|
+
Float: {
|
|
42
|
+
input: number;
|
|
43
|
+
output: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type AssetClass = {
|
|
47
|
+
__typename?: 'AssetClass';
|
|
48
|
+
instruments?: Maybe<Array<Maybe<Instrument>>>;
|
|
49
|
+
name?: Maybe<Scalars['String']['output']>;
|
|
50
|
+
};
|
|
51
|
+
export declare enum BookType {
|
|
52
|
+
Order = "ORDER",
|
|
53
|
+
Position = "POSITION"
|
|
54
|
+
}
|
|
55
|
+
export declare enum CurrencyName {
|
|
56
|
+
Aud = "AUD",
|
|
57
|
+
Cad = "CAD",
|
|
58
|
+
Chf = "CHF",
|
|
59
|
+
Eur = "EUR",
|
|
60
|
+
Gbp = "GBP",
|
|
61
|
+
Jpy = "JPY",
|
|
62
|
+
Nzd = "NZD",
|
|
63
|
+
Usd = "USD"
|
|
64
|
+
}
|
|
65
|
+
export type CurrencyPower = {
|
|
66
|
+
__typename?: 'CurrencyPower';
|
|
67
|
+
/** UTC Timestamp */
|
|
68
|
+
point: Scalars['String']['output'];
|
|
69
|
+
price: Scalars['Float']['output'];
|
|
70
|
+
};
|
|
71
|
+
export type CurrencyPowerBalance = {
|
|
72
|
+
__typename?: 'CurrencyPowerBalance';
|
|
73
|
+
currency: CurrencyName;
|
|
74
|
+
power: Array<CurrencyPower>;
|
|
75
|
+
};
|
|
76
|
+
export declare enum CurrencyPowerBalanceTimeUnit {
|
|
77
|
+
CurrentDay = "CURRENT_DAY",
|
|
78
|
+
H4 = "H4",
|
|
79
|
+
H8 = "H8",
|
|
80
|
+
H24 = "H24",
|
|
81
|
+
M1 = "M1",
|
|
82
|
+
M3 = "M3",
|
|
83
|
+
PreviousDay = "PREVIOUS_DAY",
|
|
84
|
+
W1 = "W1"
|
|
85
|
+
}
|
|
86
|
+
export type CurrencyStrength = {
|
|
87
|
+
__typename?: 'CurrencyStrength';
|
|
88
|
+
currency: CurrencyName;
|
|
89
|
+
strengthRelation?: Maybe<Array<StrengthRelation>>;
|
|
90
|
+
};
|
|
91
|
+
export declare enum DataSource {
|
|
92
|
+
Ny4 = "NY4",
|
|
93
|
+
Ty3 = "TY3"
|
|
94
|
+
}
|
|
95
|
+
export declare enum Division {
|
|
96
|
+
Oap = "OAP",
|
|
97
|
+
Oau = "OAU",
|
|
98
|
+
Oc = "OC",
|
|
99
|
+
Ocan = "OCAN",
|
|
100
|
+
Oel = "OEL",
|
|
101
|
+
Ogm = "OGM",
|
|
102
|
+
Oj = "OJ",
|
|
103
|
+
Otms = "OTMS"
|
|
104
|
+
}
|
|
105
|
+
export type Instrument = {
|
|
106
|
+
__typename?: 'Instrument';
|
|
107
|
+
displayName?: Maybe<Scalars['String']['output']>;
|
|
108
|
+
name?: Maybe<Scalars['String']['output']>;
|
|
109
|
+
};
|
|
110
|
+
export type OrderPositionBucket = {
|
|
111
|
+
__typename?: 'OrderPositionBucket';
|
|
112
|
+
longCountPercent: Scalars['Float']['output'];
|
|
113
|
+
price: Scalars['Float']['output'];
|
|
114
|
+
shortCountPercent: Scalars['Float']['output'];
|
|
115
|
+
};
|
|
116
|
+
export type OrderPositionData = {
|
|
117
|
+
__typename?: 'OrderPositionData';
|
|
118
|
+
bucketWidth: Scalars['Float']['output'];
|
|
119
|
+
buckets: Array<Maybe<OrderPositionBucket>>;
|
|
120
|
+
dataSource?: Maybe<Scalars['String']['output']>;
|
|
121
|
+
instrument: Scalars['String']['output'];
|
|
122
|
+
price?: Maybe<Scalars['Float']['output']>;
|
|
123
|
+
region?: Maybe<Scalars['String']['output']>;
|
|
124
|
+
time: Scalars['String']['output'];
|
|
125
|
+
unixTime: Scalars['Int']['output'];
|
|
126
|
+
};
|
|
127
|
+
export type Query = {
|
|
128
|
+
__typename?: 'Query';
|
|
129
|
+
assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
|
|
130
|
+
currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
|
|
131
|
+
currencyStrength?: Maybe<Array<CurrencyStrength>>;
|
|
132
|
+
orderPositionBooks: Array<Maybe<OrderPositionData>>;
|
|
133
|
+
sentiment?: Maybe<Array<SentimentInstrument>>;
|
|
134
|
+
sentimentList?: Maybe<Array<SentimentInstrument>>;
|
|
135
|
+
topicalInstruments?: Maybe<Array<TopicalInstrument>>;
|
|
136
|
+
topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
|
|
137
|
+
topicalInstrumentsTotalCount: Scalars['Int']['output'];
|
|
138
|
+
volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
|
|
139
|
+
volatilityChartAssetClasses?: Maybe<Array<VolatilityChartAssetClass>>;
|
|
140
|
+
};
|
|
141
|
+
export type QueryAssetClassesArgs = {
|
|
142
|
+
division: Division;
|
|
143
|
+
};
|
|
144
|
+
export type QueryCurrencyPowerBalanceArgs = {
|
|
145
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
146
|
+
};
|
|
147
|
+
export type QueryOrderPositionBooksArgs = {
|
|
148
|
+
bookType: BookType;
|
|
149
|
+
dataSource?: InputMaybe<DataSource>;
|
|
150
|
+
instrument: Scalars['String']['input'];
|
|
151
|
+
recentHours?: InputMaybe<Scalars['Int']['input']>;
|
|
152
|
+
region?: InputMaybe<Region>;
|
|
153
|
+
};
|
|
154
|
+
export type QuerySentimentArgs = {
|
|
155
|
+
division?: InputMaybe<Division>;
|
|
156
|
+
name: Scalars['String']['input'];
|
|
157
|
+
};
|
|
158
|
+
export type QuerySentimentListArgs = {
|
|
159
|
+
division?: InputMaybe<Division>;
|
|
160
|
+
sort?: InputMaybe<Sort>;
|
|
161
|
+
};
|
|
162
|
+
export type QueryTopicalInstrumentsArgs = {
|
|
163
|
+
count?: InputMaybe<Scalars['Int']['input']>;
|
|
164
|
+
division?: InputMaybe<Division>;
|
|
165
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
166
|
+
sort: TopicalSort;
|
|
167
|
+
};
|
|
168
|
+
export type QueryTopicalInstrumentsChartsArgs = {
|
|
169
|
+
division?: InputMaybe<Division>;
|
|
170
|
+
instruments?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
171
|
+
};
|
|
172
|
+
export type QueryTopicalInstrumentsTotalCountArgs = {
|
|
173
|
+
division?: InputMaybe<Division>;
|
|
174
|
+
sort: TopicalSort;
|
|
175
|
+
};
|
|
176
|
+
export type QueryVolatilityChartArgs = {
|
|
177
|
+
division?: InputMaybe<Division>;
|
|
178
|
+
instrument: Scalars['String']['input'];
|
|
179
|
+
timeSpan: VolatilityChartTimeSpan;
|
|
180
|
+
timeUnit: VolatilityChartTimeUnit;
|
|
181
|
+
};
|
|
182
|
+
export type QueryVolatilityChartAssetClassesArgs = {
|
|
183
|
+
division?: InputMaybe<Division>;
|
|
184
|
+
};
|
|
185
|
+
export declare enum Region {
|
|
186
|
+
Amer = "AMER",
|
|
187
|
+
Apac = "APAC",
|
|
188
|
+
Emea = "EMEA"
|
|
189
|
+
}
|
|
190
|
+
export type Sentiment = {
|
|
191
|
+
__typename?: 'Sentiment';
|
|
192
|
+
longPercent: Scalars['Float']['output'];
|
|
193
|
+
shortPercent: Scalars['Float']['output'];
|
|
194
|
+
};
|
|
195
|
+
export type SentimentInstrument = {
|
|
196
|
+
__typename?: 'SentimentInstrument';
|
|
197
|
+
displayName: Scalars['String']['output'];
|
|
198
|
+
name: Scalars['String']['output'];
|
|
199
|
+
sentiment: Sentiment;
|
|
200
|
+
updatedAt: Scalars['String']['output'];
|
|
201
|
+
};
|
|
202
|
+
export declare enum Sort {
|
|
203
|
+
Bearish = "BEARISH",
|
|
204
|
+
Bullish = "BULLISH"
|
|
205
|
+
}
|
|
206
|
+
export type StrengthRelation = {
|
|
207
|
+
__typename?: 'StrengthRelation';
|
|
208
|
+
currency: CurrencyName;
|
|
209
|
+
percentage: Scalars['Float']['output'];
|
|
210
|
+
};
|
|
211
|
+
export type TopicalInstrument = {
|
|
212
|
+
__typename?: 'TopicalInstrument';
|
|
213
|
+
displayName: Scalars['String']['output'];
|
|
214
|
+
name: Scalars['String']['output'];
|
|
215
|
+
sentiment: Sentiment;
|
|
216
|
+
updatedAt: Scalars['String']['output'];
|
|
217
|
+
};
|
|
218
|
+
export type TopicalInstrumentChart = {
|
|
219
|
+
__typename?: 'TopicalInstrumentChart';
|
|
220
|
+
chart?: Maybe<Array<Scalars['Float']['output']>>;
|
|
221
|
+
name: Scalars['String']['output'];
|
|
222
|
+
};
|
|
223
|
+
export declare enum TopicalSort {
|
|
224
|
+
Bearish = "BEARISH",
|
|
225
|
+
Bullish = "BULLISH",
|
|
226
|
+
Hot = "HOT",
|
|
227
|
+
Popular = "POPULAR",
|
|
228
|
+
Volatile = "VOLATILE"
|
|
229
|
+
}
|
|
230
|
+
export type VolatilityChart = {
|
|
231
|
+
__typename?: 'VolatilityChart';
|
|
232
|
+
pips: Scalars['Float']['output'];
|
|
233
|
+
/** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
|
|
234
|
+
point: Scalars['String']['output'];
|
|
235
|
+
};
|
|
236
|
+
export type VolatilityChartAssetClass = {
|
|
237
|
+
__typename?: 'VolatilityChartAssetClass';
|
|
238
|
+
instruments: Array<VolatilityChartInstrument>;
|
|
239
|
+
name: Scalars['String']['output'];
|
|
240
|
+
};
|
|
241
|
+
export type VolatilityChartInstrument = {
|
|
242
|
+
__typename?: 'VolatilityChartInstrument';
|
|
243
|
+
displayName: Scalars['String']['output'];
|
|
244
|
+
name: Scalars['String']['output'];
|
|
245
|
+
};
|
|
246
|
+
export declare enum VolatilityChartTimeSpan {
|
|
247
|
+
/** Valid for: H */
|
|
248
|
+
D5 = "D5",
|
|
249
|
+
/** Valid for: H */
|
|
250
|
+
D10 = "D10",
|
|
251
|
+
/** Valid for: D */
|
|
252
|
+
M1 = "M1",
|
|
253
|
+
/** Valid for: D */
|
|
254
|
+
M3 = "M3",
|
|
255
|
+
/** Valid for: W */
|
|
256
|
+
W5 = "W5",
|
|
257
|
+
/** Valid for: W */
|
|
258
|
+
W10 = "W10"
|
|
259
|
+
}
|
|
260
|
+
export declare enum VolatilityChartTimeUnit {
|
|
261
|
+
D = "D",
|
|
262
|
+
H = "H",
|
|
263
|
+
W = "W"
|
|
264
|
+
}
|
|
265
|
+
export type GetCurrencyStrengthQueryVariables = Exact<{
|
|
266
|
+
[key: string]: never;
|
|
267
|
+
}>;
|
|
268
|
+
export type GetCurrencyStrengthQuery = {
|
|
269
|
+
__typename?: 'Query';
|
|
270
|
+
currencyStrength?: Array<{
|
|
271
|
+
__typename?: 'CurrencyStrength';
|
|
272
|
+
currency: CurrencyName;
|
|
273
|
+
strengthRelation?: Array<{
|
|
274
|
+
__typename?: 'StrengthRelation';
|
|
275
|
+
currency: CurrencyName;
|
|
276
|
+
percentage: number;
|
|
277
|
+
}> | null;
|
|
278
|
+
}> | null;
|
|
279
|
+
};
|
|
280
|
+
export declare const GetCurrencyStrengthDocument: DocumentNode<GetCurrencyStrengthQuery, Exact<{
|
|
281
|
+
[key: string]: never;
|
|
282
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CurrencyStrengthWidget/CurrencyStrengthWidget';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultTranslations: {};
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectId": "19607517615e88022ba782.45168463",
|
|
3
|
+
"outputDir": "src/translations/sources",
|
|
4
|
+
"esModuleTranslations": "src/translations/translations.ts",
|
|
5
|
+
"messagesFormat": "esModule",
|
|
6
|
+
"esModuleConstName": "defaultTranslations",
|
|
7
|
+
"includeEmptyTranslations": true,
|
|
8
|
+
"downloadOptions": {
|
|
9
|
+
"format": "json",
|
|
10
|
+
"add_newline_eof": true,
|
|
11
|
+
"placeholder_format": "i18n",
|
|
12
|
+
"indentation": "2sp",
|
|
13
|
+
"plural_format": "i18next",
|
|
14
|
+
"export_empty_as": "skip",
|
|
15
|
+
"include_tags": ["common_widgets", "currency_strength_widget"],
|
|
16
|
+
"filter_langs": ["en", "zh_TW"]
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oanda/labs-currency-strength-widget",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Labs Currency Strength Widget",
|
|
5
|
+
"main": "dist/main/index.js",
|
|
6
|
+
"module": "dist/module/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"codegen": "graphql-codegen --config codegen.ts"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "OANDA",
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@apollo/client": "3.7.17",
|
|
16
|
+
"@oanda/labs-widget-common": "^1.0.83",
|
|
17
|
+
"@oanda/mono-i18n": "9.0.0",
|
|
18
|
+
"classnames": "2.3.2",
|
|
19
|
+
"echarts": "5.4.3",
|
|
20
|
+
"echarts-for-react": "3.0.2",
|
|
21
|
+
"graphql": "16.7.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@graphql-codegen/cli": "5.0.0",
|
|
25
|
+
"@graphql-codegen/client-preset": "4.1.0",
|
|
26
|
+
"@graphql-codegen/typescript": "4.0.1"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "05f38586b5d7b8c372f34bc1b039acd1c998b0f2"
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { useQuery } from '@apollo/client';
|
|
3
|
+
import {
|
|
4
|
+
ChartError, Spinner, SpinnerSize,
|
|
5
|
+
ThemeContext,
|
|
6
|
+
} from '@oanda/labs-widget-common';
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
import { getCurrencyStrength } from '../gql/getCurrencyStrength';
|
|
9
|
+
import { GetCurrencyStrengthQuery } from '../gql/types/graphql';
|
|
10
|
+
import { Chart } from './components/Chart';
|
|
11
|
+
|
|
12
|
+
const ChartWithData = () => {
|
|
13
|
+
const { isDesktop } = useContext(ThemeContext);
|
|
14
|
+
const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {
|
|
15
|
+
fetchPolicy: 'cache-and-network',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;
|
|
19
|
+
const showError = data?.currencyStrength?.length === 0 || error;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
{loading
|
|
24
|
+
&& (
|
|
25
|
+
<div className="lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
26
|
+
<Spinner size={SpinnerSize.lg} />
|
|
27
|
+
</div>
|
|
28
|
+
)}
|
|
29
|
+
{!loading && showChart && (
|
|
30
|
+
<div
|
|
31
|
+
data-testid="currency-strength-chart-wrapper"
|
|
32
|
+
className={classnames('lw-grid lw-place-content-center lw-gap-7', {
|
|
33
|
+
'lw-grid-cols-3 ': isDesktop,
|
|
34
|
+
'lw-grid-cols-1': !isDesktop,
|
|
35
|
+
})}
|
|
36
|
+
>
|
|
37
|
+
{data.currencyStrength?.map((item) => (
|
|
38
|
+
<div className="lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center">
|
|
39
|
+
<Chart currency={item.currency} values={item.strengthRelation!} />
|
|
40
|
+
</div>
|
|
41
|
+
))}
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
{!loading && showError && (
|
|
45
|
+
<div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
46
|
+
<ChartError />
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { ChartWithData };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
3
|
+
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
4
|
+
import { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';
|
|
5
|
+
import { VolatilityChartConfig } from './types';
|
|
6
|
+
import { translations } from '../translations';
|
|
7
|
+
import { Main } from './Main';
|
|
8
|
+
|
|
9
|
+
const CurrencyStrengthWidget = ({
|
|
10
|
+
graphqlUrl, locale, theme, isParamError,
|
|
11
|
+
}: VolatilityChartConfig) => {
|
|
12
|
+
const client = new ApolloClient({
|
|
13
|
+
uri: graphqlUrl,
|
|
14
|
+
cache: new InMemoryCache(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ThemeProvider theme={theme}>
|
|
19
|
+
<LocaleProvider locale={getLocale(locale)} translations={translations}>
|
|
20
|
+
<ApolloProvider client={client}>
|
|
21
|
+
{isParamError ? (
|
|
22
|
+
<div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
23
|
+
<ChartError />
|
|
24
|
+
</div>
|
|
25
|
+
) : <Main />}
|
|
26
|
+
</ApolloProvider>
|
|
27
|
+
</LocaleProvider>
|
|
28
|
+
</ThemeProvider>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { CurrencyStrengthWidget };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
3
|
+
import { ChartWithData } from './ChartsWithData';
|
|
4
|
+
|
|
5
|
+
const Main = () => {
|
|
6
|
+
const { lang } = useLocale();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div data-testid="currency-strength-wrapper">
|
|
10
|
+
<div className="lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold">
|
|
11
|
+
<span>{`${lang('daily')} (${lang('5_minutes')})`}</span>
|
|
12
|
+
</div>
|
|
13
|
+
<ChartWithData />
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Main };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
3
|
+
import * as echarts from 'echarts/core';
|
|
4
|
+
import { BarChart } from 'echarts/charts';
|
|
5
|
+
import { CanvasRenderer } from 'echarts/renderers';
|
|
6
|
+
import {
|
|
7
|
+
GridSimpleComponent, GraphicComponent, TooltipComponent, TitleComponent,
|
|
8
|
+
} from 'echarts/components';
|
|
9
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
10
|
+
import { Theme, ThemeContext, getChartTheme } from '@oanda/labs-widget-common';
|
|
11
|
+
import {
|
|
12
|
+
CHART_HEIGHT,
|
|
13
|
+
} from './constants';
|
|
14
|
+
import { getOption } from './getOption';
|
|
15
|
+
import { ChartProps } from './types';
|
|
16
|
+
|
|
17
|
+
echarts.use([
|
|
18
|
+
GridSimpleComponent,
|
|
19
|
+
GraphicComponent,
|
|
20
|
+
TooltipComponent,
|
|
21
|
+
TitleComponent,
|
|
22
|
+
BarChart,
|
|
23
|
+
CanvasRenderer,
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
|
|
27
|
+
echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
28
|
+
|
|
29
|
+
const Chart = ({ values, currency }: ChartProps) => {
|
|
30
|
+
const { lang } = useLocale();
|
|
31
|
+
const { isDark } = useContext(ThemeContext);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ReactEChartsCore
|
|
35
|
+
echarts={echarts}
|
|
36
|
+
theme={isDark ? 'dark_theme' : 'light_theme'}
|
|
37
|
+
style={{
|
|
38
|
+
height: `${CHART_HEIGHT}px`,
|
|
39
|
+
width: '100%',
|
|
40
|
+
}}
|
|
41
|
+
option={getOption({
|
|
42
|
+
values, currency, lang, isDark,
|
|
43
|
+
})}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { Chart };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
export const X_LABEL_SIZE = 24;
|
|
4
|
+
export const Y_LABEL_SIZE = 30;
|
|
5
|
+
export const CHART_WIDTH = 9999;
|
|
6
|
+
export const CHART_HEIGHT = 135;
|
|
7
|
+
|
|
8
|
+
export const darkBarColors = {
|
|
9
|
+
positive: colorPalette.bottleGreenLight,
|
|
10
|
+
negative: colorPalette.orange,
|
|
11
|
+
zero: colorPalette.disabledGray,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const lightBarColors = {
|
|
15
|
+
positive: colorPalette.bottleGreenLight,
|
|
16
|
+
negative: colorPalette.raspberryDark,
|
|
17
|
+
zero: colorPalette.disabledGray,
|
|
18
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TooltipFormatterParams } from './types';
|
|
2
|
+
|
|
3
|
+
export const tooltipFormatter = ({
|
|
4
|
+
marker,
|
|
5
|
+
name,
|
|
6
|
+
value,
|
|
7
|
+
currency,
|
|
8
|
+
lang,
|
|
9
|
+
}: TooltipFormatterParams) => `
|
|
10
|
+
<div>
|
|
11
|
+
<div style="margin-bottom:5px;">${currency} ${lang('vs')} ${name}</div>
|
|
12
|
+
<div style="display:flex;align-items:center;">${marker} ${value}%</div>
|
|
13
|
+
</div>`;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getGridLines } from '@oanda/labs-widget-common';
|
|
2
|
+
import {
|
|
3
|
+
CHART_HEIGHT,
|
|
4
|
+
CHART_WIDTH,
|
|
5
|
+
X_LABEL_SIZE,
|
|
6
|
+
Y_LABEL_SIZE,
|
|
7
|
+
darkBarColors,
|
|
8
|
+
lightBarColors,
|
|
9
|
+
} from './constants';
|
|
10
|
+
import { GetOptionProps } from './types';
|
|
11
|
+
import { tooltipFormatter } from './formatters';
|
|
12
|
+
|
|
13
|
+
export const getOption = ({
|
|
14
|
+
values, currency, isDark, lang,
|
|
15
|
+
}: GetOptionProps) => {
|
|
16
|
+
const currencies = values.map((item) => item.currency);
|
|
17
|
+
const percentages = values.map((item) => item.percentage);
|
|
18
|
+
const barColors = isDark ? darkBarColors : lightBarColors;
|
|
19
|
+
|
|
20
|
+
const gridLines = getGridLines({
|
|
21
|
+
isDark,
|
|
22
|
+
chartWidth: CHART_WIDTH,
|
|
23
|
+
chartHeight: CHART_HEIGHT,
|
|
24
|
+
xLabelsSize: -2,
|
|
25
|
+
yLabelSize: -3,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
animation: false,
|
|
30
|
+
title: {
|
|
31
|
+
left: 'center',
|
|
32
|
+
text: `${currency} vs`,
|
|
33
|
+
textStyle: {
|
|
34
|
+
fontSize: 12,
|
|
35
|
+
lineHeight: 20,
|
|
36
|
+
fontWeight: 400,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
grid: [
|
|
40
|
+
{
|
|
41
|
+
name: 'main-grid',
|
|
42
|
+
top: '30px',
|
|
43
|
+
right: '0px',
|
|
44
|
+
left: `${Y_LABEL_SIZE}px`,
|
|
45
|
+
bottom: `${X_LABEL_SIZE}px`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
graphic: [
|
|
49
|
+
...gridLines,
|
|
50
|
+
],
|
|
51
|
+
tooltip: {
|
|
52
|
+
trigger: 'axis',
|
|
53
|
+
formatter: (
|
|
54
|
+
[{ marker, name, value }]
|
|
55
|
+
: { marker: string, name: string, value: number }[],
|
|
56
|
+
) => tooltipFormatter({
|
|
57
|
+
lang,
|
|
58
|
+
currency,
|
|
59
|
+
marker,
|
|
60
|
+
name,
|
|
61
|
+
value,
|
|
62
|
+
}),
|
|
63
|
+
axisPointer: {
|
|
64
|
+
axis: 'x',
|
|
65
|
+
},
|
|
66
|
+
extraCssText: 'z-index: 1',
|
|
67
|
+
},
|
|
68
|
+
xAxis: {
|
|
69
|
+
type: 'category',
|
|
70
|
+
data: currencies,
|
|
71
|
+
axisTick: { show: false },
|
|
72
|
+
axisLine: { show: false },
|
|
73
|
+
splitLine: { show: false },
|
|
74
|
+
axisLabel: {
|
|
75
|
+
fontSize: 10,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
yAxis: {
|
|
79
|
+
type: 'value',
|
|
80
|
+
position: 'left',
|
|
81
|
+
min: Math.floor(Math.min(...percentages)),
|
|
82
|
+
max: Math.ceil(Math.max(...percentages)),
|
|
83
|
+
interval: 1,
|
|
84
|
+
axisLine: { show: false },
|
|
85
|
+
axisTick: { show: false },
|
|
86
|
+
axisLabel: {
|
|
87
|
+
formatter: '{value}%',
|
|
88
|
+
fontSize: 10,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
series: [
|
|
92
|
+
{
|
|
93
|
+
data: percentages,
|
|
94
|
+
type: 'bar',
|
|
95
|
+
itemStyle: {
|
|
96
|
+
color: ({ data } : { data: number }) => {
|
|
97
|
+
if (data > 0) {
|
|
98
|
+
return barColors.positive;
|
|
99
|
+
}
|
|
100
|
+
if (data < 0) {
|
|
101
|
+
return barColors.negative;
|
|
102
|
+
}
|
|
103
|
+
return barColors.zero;
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Chart';
|