tradingview-mcp 26.0.0__tar.gz → 26.3.0__tar.gz
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.
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/.gitignore +1 -3
- tradingview_mcp-26.3.0/PKG-INFO +148 -0
- tradingview_mcp-26.3.0/README.md +112 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/pyproject.toml +1 -1
- tradingview_mcp-26.3.0/src/tradingview_mcp/constants.py +196 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/extracted/ai_quick_reference.json +130 -131
- tradingview_mcp-26.3.0/src/tradingview_mcp/data/extracted/common_fields.json +7362 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/data/extracted/fields_by_market.json +43574 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/data/extracted/stock_screener_presets.json +1871 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/docs_data.py +552 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/resources.py +63 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/server.py +249 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/tools/__init__.py +0 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/tools/reference.py +70 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/tools/screener.py +87 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/tools/search.py +326 -0
- tradingview_mcp-26.3.0/src/tradingview_mcp/tools/technical.py +113 -0
- tradingview_mcp-26.0.0/PKG-INFO +0 -333
- tradingview_mcp-26.0.0/README.md +0 -297
- tradingview_mcp-26.0.0/src/tradingview_mcp/constants.py +0 -427
- tradingview_mcp-26.0.0/src/tradingview_mcp/data/extracted/common_fields.json +0 -3627
- tradingview_mcp-26.0.0/src/tradingview_mcp/data/extracted/fields_by_market.json +0 -23299
- tradingview_mcp-26.0.0/src/tradingview_mcp/docs_data.py +0 -297
- tradingview_mcp-26.0.0/src/tradingview_mcp/server.py +0 -2149
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/LICENSE +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/__init__.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/column.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/__init__.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/column_display_names.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/extracted/__init__.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/extracted/screener_code_examples.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/markets.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/bond.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/bonds.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/cfd.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/coin.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/crypto.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/economics2.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/forex.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/futures.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/ireland.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/options.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/metainfo/stocks.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/screeners/main_screeners.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/screeners/markets.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/screeners/stocks.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/data/screeners/stocks_failed.json +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/models.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/query.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/scanner.py +0 -0
- {tradingview_mcp-26.0.0 → tradingview_mcp-26.3.0}/src/tradingview_mcp/utils.py +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tradingview-mcp
|
|
3
|
+
Version: 26.3.0
|
|
4
|
+
Summary: A comprehensive MCP server for TradingView market screening with integrated screener functionality
|
|
5
|
+
Project-URL: Homepage, https://github.com/k73a/tradingview-mcp
|
|
6
|
+
Project-URL: Documentation, https://github.com/k73a/tradingview-mcp#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/k73a/tradingview-mcp
|
|
8
|
+
Project-URL: Issues, https://github.com/k73a/tradingview-mcp/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/k73a/tradingview-mcp/blob/main/CHANGELOG.md
|
|
10
|
+
Author: TradingView MCP Team
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: crypto,mcp,model-context-protocol,screener,stocks,technical-analysis,trading,tradingview
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: httpx>=0.24.0
|
|
26
|
+
Requires-Dist: mcp>=1.0.0
|
|
27
|
+
Requires-Dist: pandas>=2.0.0
|
|
28
|
+
Requires-Dist: requests>=2.28.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pyright>=1.1.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# TradingView MCP Server
|
|
38
|
+
|
|
39
|
+
[](https://badge.fury.io/py/tradingview-mcp)
|
|
40
|
+
[](https://pypi.org/project/tradingview-mcp/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
MCP server for TradingView market screening. Supports stocks, crypto, forex, futures, bonds across 76+ markets.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"tradingview": {
|
|
50
|
+
"command": "uvx",
|
|
51
|
+
"args": ["tradingview-mcp"]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Smart Features
|
|
58
|
+
|
|
59
|
+
- **Auto-Market Detection**: If you search for `EURUSD` or `BTCUSDT`, the server automatically checks Forex and Crypto markets if not found in stocks.
|
|
60
|
+
- **Strict Exchange Support**: Use `EXCHANGE:SYMBOL` format (e.g., `BINANCE:BTCUSDT`, `FX:EURUSD`) to target specific markets.
|
|
61
|
+
- **Smart Filters**: You can use human-readable names in filters (e.g., `"Relative Strength Index (14)"` instead of `"RSI"`).
|
|
62
|
+
|
|
63
|
+
## Main Tools
|
|
64
|
+
|
|
65
|
+
| Tool | Description |
|
|
66
|
+
|------|-------------|
|
|
67
|
+
| `screen_market` | Custom market screening with filters |
|
|
68
|
+
| `get_top_gainers` | Top gaining assets |
|
|
69
|
+
| `get_top_losers` | Top losing assets |
|
|
70
|
+
| `get_most_active` | Most traded by volume |
|
|
71
|
+
| `search_symbols` | Search by company name |
|
|
72
|
+
| `get_symbol_info` | Detailed symbol info |
|
|
73
|
+
| `advanced_query` | Complex queries with AND/OR logic |
|
|
74
|
+
|
|
75
|
+
### Technical Analysis
|
|
76
|
+
|
|
77
|
+
| Tool | Description |
|
|
78
|
+
|------|-------------|
|
|
79
|
+
| `get_technical_analysis` | Full technical analysis |
|
|
80
|
+
| `scan_rsi_extremes` | RSI overbought/oversold |
|
|
81
|
+
| `scan_macd_crossover` | MACD crossover detection |
|
|
82
|
+
| `scan_bollinger_bands` | Bollinger Band squeeze |
|
|
83
|
+
| `scan_volume_breakout` | Volume breakout detection |
|
|
84
|
+
|
|
85
|
+
### Reference Tools
|
|
86
|
+
|
|
87
|
+
| Tool | Description |
|
|
88
|
+
|------|-------------|
|
|
89
|
+
| `ai_get_reference` | Quick reference for markets/columns/filters |
|
|
90
|
+
| `search_available_fields` | Search for fields by name |
|
|
91
|
+
| `get_field_info` | Get field display name and type |
|
|
92
|
+
| `list_fields_for_market` | List fields for a market |
|
|
93
|
+
| `get_screener_preset` | Get predefined screener presets |
|
|
94
|
+
|
|
95
|
+
## Reference Resources
|
|
96
|
+
|
|
97
|
+
These resources provide raw lists of available markets and fields for reference.
|
|
98
|
+
|
|
99
|
+
| Resource | Description |
|
|
100
|
+
|----------|-------------|
|
|
101
|
+
| `markets://list` | All available markets |
|
|
102
|
+
| `columns://list` | Available columns/fields |
|
|
103
|
+
| `docs://ai-reference` | AI quick reference |
|
|
104
|
+
| `docs://fields` | Field display names |
|
|
105
|
+
|
|
106
|
+
## Markets
|
|
107
|
+
|
|
108
|
+
- **Stocks**: america, uk, germany, japan, china, etc. (68 countries)
|
|
109
|
+
- **Crypto**: crypto (pairs), coin (individual coins)
|
|
110
|
+
- **Others**: forex, futures, bonds, cfd, options
|
|
111
|
+
|
|
112
|
+
## Installation
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Using uvx (recommended)
|
|
116
|
+
uvx tradingview-mcp
|
|
117
|
+
|
|
118
|
+
# Using pip
|
|
119
|
+
pip install tradingview-mcp
|
|
120
|
+
|
|
121
|
+
# From source
|
|
122
|
+
git clone https://github.com/k73a/tradingview-mcp.git
|
|
123
|
+
cd tradingview-mcp
|
|
124
|
+
uv sync
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Running
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Stdio (default)
|
|
131
|
+
tradingview-mcp
|
|
132
|
+
|
|
133
|
+
# HTTP
|
|
134
|
+
tradingview-mcp streamable-http --host 127.0.0.1 --port 8000
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uv sync --all-extras
|
|
141
|
+
uv run pytest tests/ -v
|
|
142
|
+
uv run ruff format .
|
|
143
|
+
uv run ruff check . --fix
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT License
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# TradingView MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/tradingview-mcp)
|
|
4
|
+
[](https://pypi.org/project/tradingview-mcp/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
MCP server for TradingView market screening. Supports stocks, crypto, forex, futures, bonds across 76+ markets.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"mcpServers": {
|
|
13
|
+
"tradingview": {
|
|
14
|
+
"command": "uvx",
|
|
15
|
+
"args": ["tradingview-mcp"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Smart Features
|
|
22
|
+
|
|
23
|
+
- **Auto-Market Detection**: If you search for `EURUSD` or `BTCUSDT`, the server automatically checks Forex and Crypto markets if not found in stocks.
|
|
24
|
+
- **Strict Exchange Support**: Use `EXCHANGE:SYMBOL` format (e.g., `BINANCE:BTCUSDT`, `FX:EURUSD`) to target specific markets.
|
|
25
|
+
- **Smart Filters**: You can use human-readable names in filters (e.g., `"Relative Strength Index (14)"` instead of `"RSI"`).
|
|
26
|
+
|
|
27
|
+
## Main Tools
|
|
28
|
+
|
|
29
|
+
| Tool | Description |
|
|
30
|
+
|------|-------------|
|
|
31
|
+
| `screen_market` | Custom market screening with filters |
|
|
32
|
+
| `get_top_gainers` | Top gaining assets |
|
|
33
|
+
| `get_top_losers` | Top losing assets |
|
|
34
|
+
| `get_most_active` | Most traded by volume |
|
|
35
|
+
| `search_symbols` | Search by company name |
|
|
36
|
+
| `get_symbol_info` | Detailed symbol info |
|
|
37
|
+
| `advanced_query` | Complex queries with AND/OR logic |
|
|
38
|
+
|
|
39
|
+
### Technical Analysis
|
|
40
|
+
|
|
41
|
+
| Tool | Description |
|
|
42
|
+
|------|-------------|
|
|
43
|
+
| `get_technical_analysis` | Full technical analysis |
|
|
44
|
+
| `scan_rsi_extremes` | RSI overbought/oversold |
|
|
45
|
+
| `scan_macd_crossover` | MACD crossover detection |
|
|
46
|
+
| `scan_bollinger_bands` | Bollinger Band squeeze |
|
|
47
|
+
| `scan_volume_breakout` | Volume breakout detection |
|
|
48
|
+
|
|
49
|
+
### Reference Tools
|
|
50
|
+
|
|
51
|
+
| Tool | Description |
|
|
52
|
+
|------|-------------|
|
|
53
|
+
| `ai_get_reference` | Quick reference for markets/columns/filters |
|
|
54
|
+
| `search_available_fields` | Search for fields by name |
|
|
55
|
+
| `get_field_info` | Get field display name and type |
|
|
56
|
+
| `list_fields_for_market` | List fields for a market |
|
|
57
|
+
| `get_screener_preset` | Get predefined screener presets |
|
|
58
|
+
|
|
59
|
+
## Reference Resources
|
|
60
|
+
|
|
61
|
+
These resources provide raw lists of available markets and fields for reference.
|
|
62
|
+
|
|
63
|
+
| Resource | Description |
|
|
64
|
+
|----------|-------------|
|
|
65
|
+
| `markets://list` | All available markets |
|
|
66
|
+
| `columns://list` | Available columns/fields |
|
|
67
|
+
| `docs://ai-reference` | AI quick reference |
|
|
68
|
+
| `docs://fields` | Field display names |
|
|
69
|
+
|
|
70
|
+
## Markets
|
|
71
|
+
|
|
72
|
+
- **Stocks**: america, uk, germany, japan, china, etc. (68 countries)
|
|
73
|
+
- **Crypto**: crypto (pairs), coin (individual coins)
|
|
74
|
+
- **Others**: forex, futures, bonds, cfd, options
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Using uvx (recommended)
|
|
80
|
+
uvx tradingview-mcp
|
|
81
|
+
|
|
82
|
+
# Using pip
|
|
83
|
+
pip install tradingview-mcp
|
|
84
|
+
|
|
85
|
+
# From source
|
|
86
|
+
git clone https://github.com/k73a/tradingview-mcp.git
|
|
87
|
+
cd tradingview-mcp
|
|
88
|
+
uv sync
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Running
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Stdio (default)
|
|
95
|
+
tradingview-mcp
|
|
96
|
+
|
|
97
|
+
# HTTP
|
|
98
|
+
tradingview-mcp streamable-http --host 127.0.0.1 --port 8000
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
uv sync --all-extras
|
|
105
|
+
uv run pytest tests/ -v
|
|
106
|
+
uv run ruff format .
|
|
107
|
+
uv run ruff check . --fix
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT License
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Constants for TradingView Screener integration.
|
|
3
|
+
|
|
4
|
+
Contains API URLs, headers, supported markets, and column definitions.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
# API Configuration
|
|
12
|
+
URL = "https://scanner.tradingview.com/{market}/scan"
|
|
13
|
+
|
|
14
|
+
HEADERS = {
|
|
15
|
+
"authority": "scanner.tradingview.com",
|
|
16
|
+
"sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="98", "Google Chrome";v="98"',
|
|
17
|
+
"accept": "text/plain, */*; q=0.01",
|
|
18
|
+
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
19
|
+
"sec-ch-ua-mobile": "?0",
|
|
20
|
+
"user-agent": (
|
|
21
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
22
|
+
"(KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
|
|
23
|
+
),
|
|
24
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
25
|
+
"origin": "https://www.tradingview.com",
|
|
26
|
+
"sec-fetch-site": "same-site",
|
|
27
|
+
"sec-fetch-mode": "cors",
|
|
28
|
+
"sec-fetch-dest": "empty",
|
|
29
|
+
"referer": "https://www.tradingview.com/",
|
|
30
|
+
"accept-language": "en-US,en;q=0.9",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
DEFAULT_RANGE = [0, 50]
|
|
34
|
+
|
|
35
|
+
# =============================================================================
|
|
36
|
+
# Load Data from JSON (Dynamic)
|
|
37
|
+
# =============================================================================
|
|
38
|
+
|
|
39
|
+
_DATA_DIR = Path(__file__).parent / "data"
|
|
40
|
+
|
|
41
|
+
def _load_markets() -> set[str]:
|
|
42
|
+
"""Load supported markets from JSON."""
|
|
43
|
+
try:
|
|
44
|
+
with open(_DATA_DIR / "markets.json", "r", encoding="utf-8") as f:
|
|
45
|
+
data = json.load(f)
|
|
46
|
+
return set(data.get("countries", []) + data.get("other", []))
|
|
47
|
+
except Exception:
|
|
48
|
+
# Fallback if file not found (dev/test env)
|
|
49
|
+
return {"america", "crypto", "forex"}
|
|
50
|
+
|
|
51
|
+
def _load_columns() -> dict[str, str]:
|
|
52
|
+
"""
|
|
53
|
+
Load column definitions from JSON.
|
|
54
|
+
Returns: Dict[Display Name, Field Name] (Reverse of JSON)
|
|
55
|
+
"""
|
|
56
|
+
try:
|
|
57
|
+
with open(_DATA_DIR / "column_display_names.json", "r", encoding="utf-8") as f:
|
|
58
|
+
data = json.load(f)
|
|
59
|
+
fields = data.get("fields", {})
|
|
60
|
+
# Reverse mapping: Display Name -> Field Name
|
|
61
|
+
# e.g. "Relative Strength Index (14)" -> "RSI"
|
|
62
|
+
return {v: k for k, v in fields.items()}
|
|
63
|
+
except Exception:
|
|
64
|
+
return {}
|
|
65
|
+
|
|
66
|
+
# Public Constants
|
|
67
|
+
MARKETS = _load_markets()
|
|
68
|
+
COLUMNS = _load_columns()
|
|
69
|
+
|
|
70
|
+
# Exchange to Screener Mapping (Expanded)
|
|
71
|
+
EXCHANGE_SCREENER = {
|
|
72
|
+
# Crypto
|
|
73
|
+
"all": "crypto",
|
|
74
|
+
"binance": "crypto",
|
|
75
|
+
"coinbase": "crypto",
|
|
76
|
+
"kraken": "crypto",
|
|
77
|
+
"kucoin": "crypto",
|
|
78
|
+
"bitfinex": "crypto",
|
|
79
|
+
"bitstamp": "crypto",
|
|
80
|
+
"okx": "crypto",
|
|
81
|
+
"bybit": "crypto",
|
|
82
|
+
"gateio": "crypto",
|
|
83
|
+
"huobi": "crypto",
|
|
84
|
+
"gemini": "crypto",
|
|
85
|
+
"poloniex": "crypto",
|
|
86
|
+
"bittrex": "crypto",
|
|
87
|
+
"bitmex": "crypto",
|
|
88
|
+
"deribit": "crypto",
|
|
89
|
+
"mexc": "crypto",
|
|
90
|
+
"bingx": "crypto",
|
|
91
|
+
"phemex": "crypto",
|
|
92
|
+
"bitget": "crypto",
|
|
93
|
+
# Forex
|
|
94
|
+
"fx": "forex",
|
|
95
|
+
"fx_idc": "forex",
|
|
96
|
+
"oanda": "forex",
|
|
97
|
+
"forex": "forex",
|
|
98
|
+
"ice": "forex", # Often forex/futures
|
|
99
|
+
"saxo": "forex",
|
|
100
|
+
"cityindex": "forex",
|
|
101
|
+
# Futures
|
|
102
|
+
"cme": "futures",
|
|
103
|
+
"cbot": "futures",
|
|
104
|
+
"comex": "futures",
|
|
105
|
+
"nymex": "futures",
|
|
106
|
+
"eurex": "futures",
|
|
107
|
+
# US Stocks
|
|
108
|
+
"nasdaq": "america",
|
|
109
|
+
"nyse": "america",
|
|
110
|
+
"amex": "america",
|
|
111
|
+
"arca": "america",
|
|
112
|
+
"otc": "america",
|
|
113
|
+
# Global Stocks
|
|
114
|
+
"lse": "uk", # London
|
|
115
|
+
"tsx": "canada", # Toronto
|
|
116
|
+
"asx": "australia",
|
|
117
|
+
"sse": "china", # Shanghai
|
|
118
|
+
"szse": "china", # Shenzhen
|
|
119
|
+
"hkex": "hongkong",
|
|
120
|
+
"hk": "hongkong",
|
|
121
|
+
"tse": "japan", # Tokyo
|
|
122
|
+
"tyo": "japan",
|
|
123
|
+
"ebs": "switzerland", # Swiss SIX
|
|
124
|
+
"six": "switzerland",
|
|
125
|
+
"xetra": "germany",
|
|
126
|
+
"fwb": "germany",
|
|
127
|
+
"euronext": "france", # Generic Euronext
|
|
128
|
+
"nse": "india",
|
|
129
|
+
"bse": "india",
|
|
130
|
+
"krx": "korea",
|
|
131
|
+
"kosdaq": "korea",
|
|
132
|
+
"b3": "brazil",
|
|
133
|
+
"moex": "russia",
|
|
134
|
+
"sgx": "singapore",
|
|
135
|
+
"twse": "taiwan",
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Allowed Timeframes
|
|
139
|
+
ALLOWED_TIMEFRAMES = {"1m", "5m", "15m", "30m", "1h", "2h", "4h", "1D", "1W", "1M"}
|
|
140
|
+
|
|
141
|
+
# Timeframe to TradingView Resolution
|
|
142
|
+
TIMEFRAME_MAP = {
|
|
143
|
+
"1m": "1",
|
|
144
|
+
"5m": "5",
|
|
145
|
+
"15m": "15",
|
|
146
|
+
"30m": "30",
|
|
147
|
+
"1h": "60",
|
|
148
|
+
"2h": "120",
|
|
149
|
+
"4h": "240",
|
|
150
|
+
"1D": "1D",
|
|
151
|
+
"1W": "1W",
|
|
152
|
+
"1M": "1M",
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Default columns for different query types
|
|
156
|
+
# Always include 'description' for full name (e.g., "Apple Inc." instead of just "AAPL")
|
|
157
|
+
DEFAULT_COLUMNS = ["name", "description", "close", "change", "volume", "market_cap_basic"]
|
|
158
|
+
|
|
159
|
+
PREMARKET_COLUMNS = ["name", "description", "close", "volume", "premarket_change", "premarket_change_abs", "premarket_volume"]
|
|
160
|
+
|
|
161
|
+
POSTMARKET_COLUMNS = ["name", "description", "close", "volume", "postmarket_change", "postmarket_change_abs", "postmarket_volume"]
|
|
162
|
+
|
|
163
|
+
CRYPTO_COLUMNS = ["name", "description", "close", "change", "volume", "market_cap_basic", "24h_vol|5"]
|
|
164
|
+
|
|
165
|
+
TECHNICAL_COLUMNS = [
|
|
166
|
+
"name",
|
|
167
|
+
"description",
|
|
168
|
+
"close",
|
|
169
|
+
"volume",
|
|
170
|
+
"change",
|
|
171
|
+
"RSI",
|
|
172
|
+
"MACD.macd",
|
|
173
|
+
"MACD.signal",
|
|
174
|
+
"BB.upper",
|
|
175
|
+
"BB.lower",
|
|
176
|
+
"SMA20",
|
|
177
|
+
"EMA50",
|
|
178
|
+
"EMA200",
|
|
179
|
+
"ADX",
|
|
180
|
+
"Stoch.K",
|
|
181
|
+
"Stoch.D",
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
def get_column_name(name: str) -> str:
|
|
185
|
+
"""Get the API column name from a human-readable name or return as-is."""
|
|
186
|
+
# Try exact match first
|
|
187
|
+
if name in COLUMNS:
|
|
188
|
+
return COLUMNS[name]
|
|
189
|
+
|
|
190
|
+
# Try case-insensitive keys
|
|
191
|
+
name_lower = name.lower()
|
|
192
|
+
for k, v in COLUMNS.items():
|
|
193
|
+
if k.lower() == name_lower:
|
|
194
|
+
return v
|
|
195
|
+
|
|
196
|
+
return name
|