@tradecanvas/commons 0.1.1 → 0.1.3
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/LICENSE +21 -0
- package/README.md +67 -0
- package/package.json +13 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TradeCanvas Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @tradecanvas/commons
|
|
2
|
+
|
|
3
|
+
Shared types, utilities, constants, themes, i18n, and market presets for the [@tradecanvas/chart](https://www.npmjs.com/package/@tradecanvas/chart) library.
|
|
4
|
+
|
|
5
|
+
**[Live Demo](https://bonguynvan.github.io/tradecanvas/)** | **[GitHub](https://github.com/bonguynvan/tradecanvas)** | **[Documentation](https://bonguynvan.github.io/tradecanvas/#getting-started)**
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
You don't need to install this package directly. It's included as a dependency of `@tradecanvas/chart`.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @tradecanvas/chart
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What's Inside
|
|
16
|
+
|
|
17
|
+
### Types
|
|
18
|
+
|
|
19
|
+
All TypeScript interfaces and types used across the library:
|
|
20
|
+
|
|
21
|
+
- `OHLCBar`, `DataSeries`, `TimeFrame` -- data format
|
|
22
|
+
- `ChartOptions`, `ChartType`, `FeaturesConfig` -- chart configuration
|
|
23
|
+
- `Theme`, `ThemeName` -- theming
|
|
24
|
+
- `IndicatorPlugin`, `IndicatorDescriptor`, `IndicatorConfig` -- indicators
|
|
25
|
+
- `DrawingToolType`, `DrawingState`, `DrawingStyle` -- drawing tools
|
|
26
|
+
- `TradingPosition`, `TradingOrder`, `TradingConfig` -- trading overlay
|
|
27
|
+
- `DataAdapter`, `StreamConfig`, `ConnectionState` -- real-time streaming
|
|
28
|
+
- `ChartEventType`, `ChartEvent` -- events
|
|
29
|
+
- `MarketConfig`, `TradingSession` -- market configuration
|
|
30
|
+
|
|
31
|
+
### Themes
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { DARK_THEME, LIGHT_THEME } from '@tradecanvas/commons'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
19 customizable properties: `background`, `text`, `candleUp`, `candleDown`, `grid`, `crosshair`, `volumeUp`, `volumeDown`, and more.
|
|
38
|
+
|
|
39
|
+
### Constants
|
|
40
|
+
|
|
41
|
+
- Default chart options and feature flags
|
|
42
|
+
- Market presets: `MARKET_HOSE`, `MARKET_HNX`, `MARKET_UPCOM`, `MARKET_CRYPTO`, `MARKET_NYSE`
|
|
43
|
+
- Vietnamese stock market color schemes
|
|
44
|
+
|
|
45
|
+
### Utilities
|
|
46
|
+
|
|
47
|
+
- `computePriceRange()` -- compute visible price range from OHLC data
|
|
48
|
+
- `timeframeToMs()` -- convert timeframe string to milliseconds
|
|
49
|
+
- `formatNumber()`, `formatVND()`, `formatVolumeLoc()` -- number formatting
|
|
50
|
+
- Color, math, precision, and data manipulation helpers
|
|
51
|
+
|
|
52
|
+
### i18n
|
|
53
|
+
|
|
54
|
+
Built-in locales: English (`en`), Vietnamese (`vi`). Extensible via `registerLocale()`.
|
|
55
|
+
|
|
56
|
+
## Direct Usage
|
|
57
|
+
|
|
58
|
+
If you need just the types or utilities without the full chart:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import type { OHLCBar, TimeFrame, ChartType } from '@tradecanvas/commons'
|
|
62
|
+
import { DARK_THEME, computePriceRange, timeframeToMs } from '@tradecanvas/commons'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
[MIT](https://github.com/bonguynvan/tradecanvas/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradecanvas/commons",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared types and utilities for @tradecanvas/chart",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"keywords": [
|
|
16
|
+
"keywords": [
|
|
17
|
+
"trading",
|
|
18
|
+
"chart",
|
|
19
|
+
"canvas",
|
|
20
|
+
"types"
|
|
21
|
+
],
|
|
17
22
|
"main": "./dist/index.cjs",
|
|
18
23
|
"module": "./dist/index.js",
|
|
19
24
|
"types": "./dist/index.d.ts",
|
|
@@ -24,11 +29,13 @@
|
|
|
24
29
|
"require": "./dist/index.cjs"
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
|
-
"files": [
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
28
36
|
"scripts": {
|
|
29
37
|
"build": "vite build",
|
|
30
38
|
"dev": "vite build --watch",
|
|
31
|
-
"clean": "rm -rf dist"
|
|
32
|
-
"prepublishOnly": "pnpm build"
|
|
39
|
+
"clean": "rm -rf dist"
|
|
33
40
|
}
|
|
34
|
-
}
|
|
41
|
+
}
|