@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.
Files changed (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js +50 -0
  4. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js.map +1 -0
  5. package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js +37 -0
  6. package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -0
  7. package/dist/main/CurrencyStrengthWidget/Main.js +22 -0
  8. package/dist/main/CurrencyStrengthWidget/Main.js.map +1 -0
  9. package/dist/main/CurrencyStrengthWidget/components/Chart/Chart.js +50 -0
  10. package/dist/main/CurrencyStrengthWidget/components/Chart/Chart.js.map +1 -0
  11. package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js +22 -0
  12. package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -0
  13. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js +18 -0
  14. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -0
  15. package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js +121 -0
  16. package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -0
  17. package/dist/main/CurrencyStrengthWidget/components/Chart/index.js +17 -0
  18. package/dist/main/CurrencyStrengthWidget/components/Chart/index.js.map +1 -0
  19. package/dist/main/CurrencyStrengthWidget/components/Chart/types.js +6 -0
  20. package/dist/main/CurrencyStrengthWidget/components/Chart/types.js.map +1 -0
  21. package/dist/main/CurrencyStrengthWidget/index.js +17 -0
  22. package/dist/main/CurrencyStrengthWidget/index.js.map +1 -0
  23. package/dist/main/CurrencyStrengthWidget/render.js +34 -0
  24. package/dist/main/CurrencyStrengthWidget/render.js.map +1 -0
  25. package/dist/main/CurrencyStrengthWidget/types.js +6 -0
  26. package/dist/main/CurrencyStrengthWidget/types.js.map +1 -0
  27. package/dist/main/gql/getCurrencyStrength.js +11 -0
  28. package/dist/main/gql/getCurrencyStrength.js.map +1 -0
  29. package/dist/main/gql/types/fragment-masking.js +24 -0
  30. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  31. package/dist/main/gql/types/gql.js +17 -0
  32. package/dist/main/gql/types/gql.js.map +1 -0
  33. package/dist/main/gql/types/graphql.js +137 -0
  34. package/dist/main/gql/types/graphql.js.map +1 -0
  35. package/dist/main/gql/types/index.js +28 -0
  36. package/dist/main/gql/types/index.js.map +1 -0
  37. package/dist/main/index.js +17 -0
  38. package/dist/main/index.js.map +1 -0
  39. package/dist/main/translations/index.js +19 -0
  40. package/dist/main/translations/index.js.map +1 -0
  41. package/dist/main/translations/sources/en.json +6 -0
  42. package/dist/main/translations/sources/zh_TW.json +6 -0
  43. package/dist/main/translations/translations.js +8 -0
  44. package/dist/main/translations/translations.js.map +1 -0
  45. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js +41 -0
  46. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js.map +1 -0
  47. package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js +30 -0
  48. package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -0
  49. package/dist/module/CurrencyStrengthWidget/Main.js +15 -0
  50. package/dist/module/CurrencyStrengthWidget/Main.js.map +1 -0
  51. package/dist/module/CurrencyStrengthWidget/components/Chart/Chart.js +41 -0
  52. package/dist/module/CurrencyStrengthWidget/components/Chart/Chart.js.map +1 -0
  53. package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js +16 -0
  54. package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -0
  55. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js +11 -0
  56. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -0
  57. package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js +114 -0
  58. package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -0
  59. package/dist/module/CurrencyStrengthWidget/components/Chart/index.js +2 -0
  60. package/dist/module/CurrencyStrengthWidget/components/Chart/index.js.map +1 -0
  61. package/dist/module/CurrencyStrengthWidget/components/Chart/types.js +2 -0
  62. package/dist/module/CurrencyStrengthWidget/components/Chart/types.js.map +1 -0
  63. package/dist/module/CurrencyStrengthWidget/index.js +2 -0
  64. package/dist/module/CurrencyStrengthWidget/index.js.map +1 -0
  65. package/dist/module/CurrencyStrengthWidget/render.js +31 -0
  66. package/dist/module/CurrencyStrengthWidget/render.js.map +1 -0
  67. package/dist/module/CurrencyStrengthWidget/types.js +2 -0
  68. package/dist/module/CurrencyStrengthWidget/types.js.map +1 -0
  69. package/dist/module/gql/getCurrencyStrength.js +6 -0
  70. package/dist/module/gql/getCurrencyStrength.js.map +1 -0
  71. package/dist/module/gql/types/fragment-masking.js +16 -0
  72. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  73. package/dist/module/gql/types/gql.js +9 -0
  74. package/dist/module/gql/types/gql.js.map +1 -0
  75. package/dist/module/gql/types/graphql.js +131 -0
  76. package/dist/module/gql/types/graphql.js.map +1 -0
  77. package/dist/module/gql/types/index.js +3 -0
  78. package/dist/module/gql/types/index.js.map +1 -0
  79. package/dist/module/index.js +2 -0
  80. package/dist/module/index.js.map +1 -0
  81. package/dist/module/translations/index.js +12 -0
  82. package/dist/module/translations/index.js.map +1 -0
  83. package/dist/module/translations/sources/en.json +6 -0
  84. package/dist/module/translations/sources/zh_TW.json +6 -0
  85. package/dist/module/translations/translations.js +2 -0
  86. package/dist/module/translations/translations.js.map +1 -0
  87. package/dist/types/CurrencyStrengthWidget/ChartsWithData.d.ts +3 -0
  88. package/dist/types/CurrencyStrengthWidget/CurrencyStrengthWidget.d.ts +4 -0
  89. package/dist/types/CurrencyStrengthWidget/Main.d.ts +3 -0
  90. package/dist/types/CurrencyStrengthWidget/components/Chart/Chart.d.ts +4 -0
  91. package/dist/types/CurrencyStrengthWidget/components/Chart/constants.d.ts +14 -0
  92. package/dist/types/CurrencyStrengthWidget/components/Chart/formatters.d.ts +2 -0
  93. package/dist/types/CurrencyStrengthWidget/components/Chart/getOption.d.ts +169 -0
  94. package/dist/types/CurrencyStrengthWidget/components/Chart/index.d.ts +1 -0
  95. package/dist/types/CurrencyStrengthWidget/components/Chart/types.d.ts +22 -0
  96. package/dist/types/CurrencyStrengthWidget/index.d.ts +1 -0
  97. package/dist/types/CurrencyStrengthWidget/render.d.ts +1 -0
  98. package/dist/types/CurrencyStrengthWidget/types.d.ts +11 -0
  99. package/dist/types/gql/getCurrencyStrength.d.ts +2 -0
  100. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  101. package/dist/types/gql/types/gql.d.ts +36 -0
  102. package/dist/types/gql/types/graphql.d.ts +282 -0
  103. package/dist/types/gql/types/index.d.ts +2 -0
  104. package/dist/types/index.d.ts +1 -0
  105. package/dist/types/translations/index.d.ts +4 -0
  106. package/dist/types/translations/translations.d.ts +1 -0
  107. package/index.ts +1 -0
  108. package/lokalise.config.json +18 -0
  109. package/package.json +29 -0
  110. package/src/CurrencyStrengthWidget/ChartsWithData.tsx +53 -0
  111. package/src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx +32 -0
  112. package/src/CurrencyStrengthWidget/Main.tsx +18 -0
  113. package/src/CurrencyStrengthWidget/components/Chart/Chart.tsx +48 -0
  114. package/src/CurrencyStrengthWidget/components/Chart/constants.tsx +18 -0
  115. package/src/CurrencyStrengthWidget/components/Chart/formatters.ts +13 -0
  116. package/src/CurrencyStrengthWidget/components/Chart/getOption.ts +109 -0
  117. package/src/CurrencyStrengthWidget/components/Chart/index.ts +1 -0
  118. package/src/CurrencyStrengthWidget/components/Chart/types.ts +25 -0
  119. package/src/CurrencyStrengthWidget/index.ts +1 -0
  120. package/src/CurrencyStrengthWidget/render.tsx +34 -0
  121. package/src/CurrencyStrengthWidget/types.ts +13 -0
  122. package/src/gql/getCurrencyStrength.ts +15 -0
  123. package/src/gql/types/fragment-masking.ts +66 -0
  124. package/src/gql/types/gql.ts +42 -0
  125. package/src/gql/types/graphql.ts +290 -0
  126. package/src/gql/types/index.ts +2 -0
  127. package/src/index.ts +1 -0
  128. package/src/translations/index.ts +13 -0
  129. package/src/translations/sources/en.json +6 -0
  130. package/src/translations/sources/zh_TW.json +6 -0
  131. package/src/translations/translations.ts +3 -0
  132. package/test/Main.test.tsx +28 -0
  133. package/test/chartOptions.test.ts +18 -0
  134. package/test/mocks/currencyStrengthMock.ts +270 -0
  135. package/test/mocks/index.ts +2 -0
  136. package/test/mocks/responsesMocks.ts +19 -0
  137. package/tsconfig.types.json +12 -0
@@ -0,0 +1,25 @@
1
+ import { CurrencyName } from '../../../gql/types/graphql';
2
+
3
+ export interface CPBChartDataValues {
4
+ currency: CurrencyName;
5
+ percentage: number;
6
+ }
7
+ export interface ChartProps {
8
+ values: CPBChartDataValues[];
9
+ currency: CurrencyName;
10
+ }
11
+
12
+ export interface TooltipFormatterParams {
13
+ marker: string;
14
+ name: string;
15
+ value: number;
16
+ currency: CurrencyName;
17
+ lang: (label: string) => string;
18
+ }
19
+
20
+ export type GetOptionProps = {
21
+ values: CPBChartDataValues[],
22
+ currency: CurrencyName,
23
+ lang: (label: string) => string,
24
+ isDark: boolean;
25
+ };
@@ -0,0 +1 @@
1
+ export * from './CurrencyStrengthWidget';
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { render } from 'react-dom';
3
+ import { Theme, validateToolParams } from '@oanda/labs-widget-common';
4
+ import { CurrencyStrengthWidget } from './CurrencyStrengthWidget';
5
+
6
+ const {
7
+ graphqlUrl,
8
+ } = window.widgetsConfig || {};
9
+
10
+ const volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
11
+
12
+ volatilityChartParamsElements.forEach((element) => {
13
+ const params = element.getAttribute('data-currency-strength-params');
14
+ const mode = element.getAttribute('data-mode');
15
+ const { locale } = JSON.parse(params as string);
16
+
17
+ const isParamError = validateToolParams({ locale, graphqlUrl }, [
18
+ {
19
+ name: 'locale',
20
+ valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',
21
+ }, {
22
+ name: 'graphqlUrl',
23
+ }]);
24
+
25
+ render(
26
+ <CurrencyStrengthWidget
27
+ graphqlUrl={graphqlUrl}
28
+ locale={locale}
29
+ theme={mode as Theme}
30
+ isParamError={isParamError}
31
+ />,
32
+ element,
33
+ );
34
+ });
@@ -0,0 +1,13 @@
1
+ import { Locale } from '@oanda/mono-i18n';
2
+ import { Theme } from '@oanda/labs-widget-common';
3
+
4
+ export interface VolatilityChartConfig {
5
+ graphqlUrl: string;
6
+ locale: Locale;
7
+ theme?: Theme;
8
+ isParamError?: boolean;
9
+ }
10
+
11
+ export interface VolatilityChartWrapperConfig extends VolatilityChartConfig {
12
+ renderElementId: string;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ const getCurrencyStrength = gql`
4
+ query GetCurrencyStrength {
5
+ currencyStrength {
6
+ currency
7
+ strengthRelation {
8
+ currency
9
+ percentage
10
+ }
11
+ }
12
+ }
13
+ `;
14
+
15
+ export { getCurrencyStrength };
@@ -0,0 +1,66 @@
1
+ import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { FragmentDefinitionNode } from 'graphql';
3
+ import { Incremental } from './graphql';
4
+
5
+
6
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
7
+ infer TType,
8
+ any
9
+ >
10
+ ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
11
+ ? TKey extends string
12
+ ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
13
+ : never
14
+ : never
15
+ : never;
16
+
17
+ // return non-nullable if `fragmentType` is non-nullable
18
+ export function useFragment<TType>(
19
+ _documentNode: DocumentTypeDecoration<TType, any>,
20
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
21
+ ): TType;
22
+ // return nullable if `fragmentType` is nullable
23
+ export function useFragment<TType>(
24
+ _documentNode: DocumentTypeDecoration<TType, any>,
25
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
26
+ ): TType | null | undefined;
27
+ // return array of non-nullable if `fragmentType` is array of non-nullable
28
+ export function useFragment<TType>(
29
+ _documentNode: DocumentTypeDecoration<TType, any>,
30
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
31
+ ): ReadonlyArray<TType>;
32
+ // return array of nullable if `fragmentType` is array of nullable
33
+ export function useFragment<TType>(
34
+ _documentNode: DocumentTypeDecoration<TType, any>,
35
+ fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
36
+ ): ReadonlyArray<TType> | null | undefined;
37
+ export function useFragment<TType>(
38
+ _documentNode: DocumentTypeDecoration<TType, any>,
39
+ fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
40
+ ): TType | ReadonlyArray<TType> | null | undefined {
41
+ return fragmentType as any;
42
+ }
43
+
44
+
45
+ export function makeFragmentData<
46
+ F extends DocumentTypeDecoration<any, any>,
47
+ FT extends ResultOf<F>
48
+ >(data: FT, _fragment: F): FragmentType<F> {
49
+ return data as FragmentType<F>;
50
+ }
51
+ export function isFragmentReady<TQuery, TFrag>(
52
+ queryNode: DocumentTypeDecoration<TQuery, any>,
53
+ fragmentNode: TypedDocumentNode<TFrag>,
54
+ data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
55
+ ): data is FragmentType<typeof fragmentNode> {
56
+ const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
57
+ ?.deferredFields;
58
+
59
+ if (!deferredFields) return true;
60
+
61
+ const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
62
+ const fragName = fragDef?.name?.value;
63
+
64
+ const fields = (fragName && deferredFields[fragName]) || [];
65
+ return fields.length > 0 && fields.every(field => data && field in data);
66
+ }
@@ -0,0 +1,42 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql';
3
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ */
15
+ const documents = {
16
+ "\n query GetCurrencyStrength {\n currencyStrength {\n currency\n strengthRelation {\n currency\n percentage\n }\n }\n }\n": types.GetCurrencyStrengthDocument,
17
+ };
18
+
19
+ /**
20
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
21
+ *
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
26
+ * ```
27
+ *
28
+ * The query argument is unknown!
29
+ * Please regenerate the types.
30
+ */
31
+ export function graphql(source: string): unknown;
32
+
33
+ /**
34
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
35
+ */
36
+ export 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"];
37
+
38
+ export function graphql(source: string) {
39
+ return (documents as any)[source] ?? {};
40
+ }
41
+
42
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;
@@ -0,0 +1,290 @@
1
+ /* eslint-disable */
2
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
+ export type Maybe<T> = T | null;
4
+ export type InputMaybe<T> = Maybe<T>;
5
+ export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
6
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
7
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
8
+ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
9
+ export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
10
+ /** All built-in and custom scalars, mapped to their actual values */
11
+ export type Scalars = {
12
+ ID: { input: string; output: string; }
13
+ String: { input: string; output: string; }
14
+ Boolean: { input: boolean; output: boolean; }
15
+ Int: { input: number; output: number; }
16
+ Float: { input: number; output: number; }
17
+ };
18
+
19
+ export type AssetClass = {
20
+ __typename?: 'AssetClass';
21
+ instruments?: Maybe<Array<Maybe<Instrument>>>;
22
+ name?: Maybe<Scalars['String']['output']>;
23
+ };
24
+
25
+ export enum BookType {
26
+ Order = 'ORDER',
27
+ Position = 'POSITION'
28
+ }
29
+
30
+ export enum CurrencyName {
31
+ Aud = 'AUD',
32
+ Cad = 'CAD',
33
+ Chf = 'CHF',
34
+ Eur = 'EUR',
35
+ Gbp = 'GBP',
36
+ Jpy = 'JPY',
37
+ Nzd = 'NZD',
38
+ Usd = 'USD'
39
+ }
40
+
41
+ export type CurrencyPower = {
42
+ __typename?: 'CurrencyPower';
43
+ /** UTC Timestamp */
44
+ point: Scalars['String']['output'];
45
+ price: Scalars['Float']['output'];
46
+ };
47
+
48
+ export type CurrencyPowerBalance = {
49
+ __typename?: 'CurrencyPowerBalance';
50
+ currency: CurrencyName;
51
+ power: Array<CurrencyPower>;
52
+ };
53
+
54
+ export enum CurrencyPowerBalanceTimeUnit {
55
+ CurrentDay = 'CURRENT_DAY',
56
+ H4 = 'H4',
57
+ H8 = 'H8',
58
+ H24 = 'H24',
59
+ M1 = 'M1',
60
+ M3 = 'M3',
61
+ PreviousDay = 'PREVIOUS_DAY',
62
+ W1 = 'W1'
63
+ }
64
+
65
+ export type CurrencyStrength = {
66
+ __typename?: 'CurrencyStrength';
67
+ currency: CurrencyName;
68
+ strengthRelation?: Maybe<Array<StrengthRelation>>;
69
+ };
70
+
71
+ export enum DataSource {
72
+ Ny4 = 'NY4',
73
+ Ty3 = 'TY3'
74
+ }
75
+
76
+ export enum Division {
77
+ Oap = 'OAP',
78
+ Oau = 'OAU',
79
+ Oc = 'OC',
80
+ Ocan = 'OCAN',
81
+ Oel = 'OEL',
82
+ Ogm = 'OGM',
83
+ Oj = 'OJ',
84
+ Otms = 'OTMS'
85
+ }
86
+
87
+ export type Instrument = {
88
+ __typename?: 'Instrument';
89
+ displayName?: Maybe<Scalars['String']['output']>;
90
+ name?: Maybe<Scalars['String']['output']>;
91
+ };
92
+
93
+ export type OrderPositionBucket = {
94
+ __typename?: 'OrderPositionBucket';
95
+ longCountPercent: Scalars['Float']['output'];
96
+ price: Scalars['Float']['output'];
97
+ shortCountPercent: Scalars['Float']['output'];
98
+ };
99
+
100
+ export type OrderPositionData = {
101
+ __typename?: 'OrderPositionData';
102
+ bucketWidth: Scalars['Float']['output'];
103
+ buckets: Array<Maybe<OrderPositionBucket>>;
104
+ dataSource?: Maybe<Scalars['String']['output']>;
105
+ instrument: Scalars['String']['output'];
106
+ price?: Maybe<Scalars['Float']['output']>;
107
+ region?: Maybe<Scalars['String']['output']>;
108
+ time: Scalars['String']['output'];
109
+ unixTime: Scalars['Int']['output'];
110
+ };
111
+
112
+ export type Query = {
113
+ __typename?: 'Query';
114
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
115
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
116
+ currencyStrength?: Maybe<Array<CurrencyStrength>>;
117
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
118
+ sentiment?: Maybe<Array<SentimentInstrument>>;
119
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
120
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
121
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
122
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
123
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
124
+ volatilityChartAssetClasses?: Maybe<Array<VolatilityChartAssetClass>>;
125
+ };
126
+
127
+
128
+ export type QueryAssetClassesArgs = {
129
+ division: Division;
130
+ };
131
+
132
+
133
+ export type QueryCurrencyPowerBalanceArgs = {
134
+ timeUnit: CurrencyPowerBalanceTimeUnit;
135
+ };
136
+
137
+
138
+ export type QueryOrderPositionBooksArgs = {
139
+ bookType: BookType;
140
+ dataSource?: InputMaybe<DataSource>;
141
+ instrument: Scalars['String']['input'];
142
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
143
+ region?: InputMaybe<Region>;
144
+ };
145
+
146
+
147
+ export type QuerySentimentArgs = {
148
+ division?: InputMaybe<Division>;
149
+ name: Scalars['String']['input'];
150
+ };
151
+
152
+
153
+ export type QuerySentimentListArgs = {
154
+ division?: InputMaybe<Division>;
155
+ sort?: InputMaybe<Sort>;
156
+ };
157
+
158
+
159
+ export type QueryTopicalInstrumentsArgs = {
160
+ count?: InputMaybe<Scalars['Int']['input']>;
161
+ division?: InputMaybe<Division>;
162
+ offset?: InputMaybe<Scalars['Int']['input']>;
163
+ sort: TopicalSort;
164
+ };
165
+
166
+
167
+ export type QueryTopicalInstrumentsChartsArgs = {
168
+ division?: InputMaybe<Division>;
169
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
170
+ };
171
+
172
+
173
+ export type QueryTopicalInstrumentsTotalCountArgs = {
174
+ division?: InputMaybe<Division>;
175
+ sort: TopicalSort;
176
+ };
177
+
178
+
179
+ export type QueryVolatilityChartArgs = {
180
+ division?: InputMaybe<Division>;
181
+ instrument: Scalars['String']['input'];
182
+ timeSpan: VolatilityChartTimeSpan;
183
+ timeUnit: VolatilityChartTimeUnit;
184
+ };
185
+
186
+
187
+ export type QueryVolatilityChartAssetClassesArgs = {
188
+ division?: InputMaybe<Division>;
189
+ };
190
+
191
+ export enum Region {
192
+ Amer = 'AMER',
193
+ Apac = 'APAC',
194
+ Emea = 'EMEA'
195
+ }
196
+
197
+ export type Sentiment = {
198
+ __typename?: 'Sentiment';
199
+ longPercent: Scalars['Float']['output'];
200
+ shortPercent: Scalars['Float']['output'];
201
+ };
202
+
203
+ export type SentimentInstrument = {
204
+ __typename?: 'SentimentInstrument';
205
+ displayName: Scalars['String']['output'];
206
+ name: Scalars['String']['output'];
207
+ sentiment: Sentiment;
208
+ updatedAt: Scalars['String']['output'];
209
+ };
210
+
211
+ export enum Sort {
212
+ Bearish = 'BEARISH',
213
+ Bullish = 'BULLISH'
214
+ }
215
+
216
+ export type StrengthRelation = {
217
+ __typename?: 'StrengthRelation';
218
+ currency: CurrencyName;
219
+ percentage: Scalars['Float']['output'];
220
+ };
221
+
222
+ export type TopicalInstrument = {
223
+ __typename?: 'TopicalInstrument';
224
+ displayName: Scalars['String']['output'];
225
+ name: Scalars['String']['output'];
226
+ sentiment: Sentiment;
227
+ updatedAt: Scalars['String']['output'];
228
+ };
229
+
230
+ export type TopicalInstrumentChart = {
231
+ __typename?: 'TopicalInstrumentChart';
232
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
233
+ name: Scalars['String']['output'];
234
+ };
235
+
236
+ export enum TopicalSort {
237
+ Bearish = 'BEARISH',
238
+ Bullish = 'BULLISH',
239
+ Hot = 'HOT',
240
+ Popular = 'POPULAR',
241
+ Volatile = 'VOLATILE'
242
+ }
243
+
244
+ export type VolatilityChart = {
245
+ __typename?: 'VolatilityChart';
246
+ pips: Scalars['Float']['output'];
247
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
248
+ point: Scalars['String']['output'];
249
+ };
250
+
251
+ export type VolatilityChartAssetClass = {
252
+ __typename?: 'VolatilityChartAssetClass';
253
+ instruments: Array<VolatilityChartInstrument>;
254
+ name: Scalars['String']['output'];
255
+ };
256
+
257
+ export type VolatilityChartInstrument = {
258
+ __typename?: 'VolatilityChartInstrument';
259
+ displayName: Scalars['String']['output'];
260
+ name: Scalars['String']['output'];
261
+ };
262
+
263
+ export enum VolatilityChartTimeSpan {
264
+ /** Valid for: H */
265
+ D5 = 'D5',
266
+ /** Valid for: H */
267
+ D10 = 'D10',
268
+ /** Valid for: D */
269
+ M1 = 'M1',
270
+ /** Valid for: D */
271
+ M3 = 'M3',
272
+ /** Valid for: W */
273
+ W5 = 'W5',
274
+ /** Valid for: W */
275
+ W10 = 'W10'
276
+ }
277
+
278
+ export enum VolatilityChartTimeUnit {
279
+ D = 'D',
280
+ H = 'H',
281
+ W = 'W'
282
+ }
283
+
284
+ export type GetCurrencyStrengthQueryVariables = Exact<{ [key: string]: never; }>;
285
+
286
+
287
+ export type GetCurrencyStrengthQuery = { __typename?: 'Query', currencyStrength?: Array<{ __typename?: 'CurrencyStrength', currency: CurrencyName, strengthRelation?: Array<{ __typename?: 'StrengthRelation', currency: CurrencyName, percentage: number }> | null }> | null };
288
+
289
+
290
+ export const GetCurrencyStrengthDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCurrencyStrength"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currencyStrength"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"strengthRelation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currency"}},{"kind":"Field","name":{"kind":"Name","value":"percentage"}}]}}]}}]}}]} as unknown as DocumentNode<GetCurrencyStrengthQuery, GetCurrencyStrengthQueryVariables>;
@@ -0,0 +1,2 @@
1
+ export * from "./fragment-masking";
2
+ export * from "./gql";
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './CurrencyStrengthWidget/CurrencyStrengthWidget';
@@ -0,0 +1,13 @@
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
+
6
+ import { defaultTranslations } from './translations';
7
+
8
+ export type TranslationKey = keyof typeof defaultTranslations;
9
+
10
+ export const translations: Translations = {
11
+ [Locale.en]: { translation: en },
12
+ [Locale.zhTW]: { translation: zhTW },
13
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "data_unavailable": "Data unavailable",
3
+ "vs": "vs",
4
+ "5_minutes": "5 minutes",
5
+ "daily": "Daily"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "data_unavailable": "沒有數據",
3
+ "vs": "",
4
+ "5_minutes": "",
5
+ "daily": ""
6
+ }
@@ -0,0 +1,3 @@
1
+ export const defaultTranslations = {
2
+
3
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import React from 'react';
5
+ import { render } from '@testing-library/react';
6
+ import { MockedProvider } from '@apollo/client/testing';
7
+ import { Main } from '../src/CurrencyStrengthWidget/Main';
8
+ import { mock } from './mocks/responsesMocks';
9
+
10
+ jest.mock('usehooks-ts', () => ({
11
+ useElementSize: jest.fn().mockImplementation(() => [null, {
12
+ width: 100,
13
+ }]),
14
+ }));
15
+
16
+ describe('Main component', () => {
17
+ it('should render tool view', async () => {
18
+ const { findByTestId, getByTestId } = render(
19
+ <MockedProvider mocks={mock}>
20
+ <Main />
21
+ </MockedProvider>,
22
+ );
23
+
24
+ expect(getByTestId('currency-strength-wrapper')).toBeInTheDocument();
25
+ expect(getByTestId('spinner')).toBeInTheDocument();
26
+ expect(await findByTestId('currency-strength-chart-wrapper')).toBeInTheDocument();
27
+ });
28
+ });
@@ -0,0 +1,18 @@
1
+ import { tooltipFormatter } from '../src/CurrencyStrengthWidget/components/Chart/formatters';
2
+ import { CurrencyName } from '../src/gql/types/graphql';
3
+
4
+ describe('tooltipFormatter', () => {
5
+ it('should display correct label on daily data', () => {
6
+ expect(tooltipFormatter({
7
+ marker: '<div>Marker</div>',
8
+ name: CurrencyName.Cad,
9
+ value: 0.81,
10
+ currency: CurrencyName.Aud,
11
+ lang: (label) => label,
12
+ })).toEqual(`
13
+ <div>
14
+ <div style="margin-bottom:5px;">AUD vs CAD</div>
15
+ <div style="display:flex;align-items:center;"><div>Marker</div> 0.81%</div>
16
+ </div>`);
17
+ });
18
+ });