Tencent Finance CLI
A Python CLI for fetching stock data from Tencent Finance API.
Features
- ✅ No API key required - 无需申请 API Key
- ✅ Works in mainland China - 针对中国大陆网络环境优化,直接访问腾讯财经 API
- ✅ Fast & Stable - 比 Yahoo Finance API 更稳定,不受限流影响
- ✅ Multi-market support - 支持美股、A股、港股
Installation
chmod +x /path/to/skills/tencent-finance/tfin
ln -sf /path/to/skills/tencent-finance/tfin /usr/local/bin/tfin # Optional: global access
Commands
Price (quick check)
tfin AAPL # Quick price
tfin price AAPL # Same as above
Quote (detailed)
tfin quote MSFT
Compare
tfin compare AAPL,MSFT,GOOGL
tfin compare TSLA,NVDA
Search
tfin search "tesla"
tfin search "bitcoin"
Help
tfin help
tfin --help
Symbol Format
- US stocks: AAPL, MSFT, GOOGL, TSLA, NVDA
- China A-Shares: sh000001 (上证指数), sz399001 (深证成指), sh600519 (茅台)
- Hong Kong: hk00700 (腾讯), hk09988 (阿里), hk03690 (美团)
- Crypto: BTC-USD, ETH-USD
Examples
# Quick price check
tfin AAPL
tfin TSLA
# Detailed quote
tfin quote NVDA
# Compare tech giants
tfin compare AAPL,MSFT,GOOGL,META,AMZN
# Search
tfin search "apple"
tfin search "bitcoin"
# China stocks
tfin sh000001 # 上证指数
tfin quote hk00700 # 腾讯控股
Data Source
This tool uses Tencent Finance API (腾讯财经 API).
Why Tencent API?
- 在中国大陆网络环境下可直接访问,无需代理
- 比 Yahoo Finance API 更稳定,不受限流影响
- 数据覆盖美股、A股、港股等多个市场
Data includes:
- Current price (实时价格)
- Price change (absolute & percentage) (涨跌额/涨跌幅)
- Open, High, Low prices (开盘/最高/最低价)
- Previous close (昨收)
- Volume (成交量)
- Market cap (市值)
- P/E ratio (市盈率)
- P/B ratio (市净率)
Supported Markets
| Market |
Example |
Status |
| US Stocks |
AAPL, TSLA, NVDA |
✅ Supported |
| China A-Shares |
sh000001, sz399001 |
✅ Supported |
| Hong Kong |
hk00700, hk09988 |
✅ Supported |
| Crypto |
BTC-USD, ETH-USD |
✅ Supported |
| India NSE/BSE |
RELIANCE.NS, TCS.BO |
❌ Not supported |
Comparison with Yahoo Finance
| Feature |
Yahoo Finance (yfinance) |
Tencent Finance (tfin) |
| Mainland China Access |
Often blocked/restricted |
✅ Direct access |
| Rate Limiting |
Frequent |
✅ Stable |
| US Stocks |
✅ Supported |
✅ Supported |
| China A-Shares |
Limited |
✅ Full support |
| Hong Kong Stocks |
Supported |
✅ Supported |
| Indian Stocks |
✅ Supported |
❌ Not supported |
| Options/Dividends |
Supported |
❌ Not supported |
Requirements
- Python 3.7+
- requests
- rich
pip3 install requests rich
Troubleshooting
"No data found"
- Verify the symbol format
- Try with prefix:
usAAPL instead of AAPL
- Some international markets may not be supported
Connection errors
- Check internet connection
- Tencent API is optimized for mainland China and generally very stable
License
MIT License
Author
Created by Menrfa
1---2name: tencent-finance3description: Get stock prices, quotes, and compare stocks using Tencent Finance API. No API key required. Supports US stocks, China A-Shares, Hong Kong stocks. Optimized for use in mainland China.4---5
6# Tencent Finance CLI
7
8A Python CLI for fetching stock data from Tencent Finance API.
9
10## Features
11
12- ✅ **No API key required** - 无需申请 API Key
13- ✅ **Works in mainland China** - 针对中国大陆网络环境优化,直接访问腾讯财经 API
14- ✅ **Fast & Stable** - 比 Yahoo Finance API 更稳定,不受限流影响
15- ✅ **Multi-market support** - 支持美股、A股、港股
16
17## Installation
18
19```bash
20chmod +x /path/to/skills/tencent-finance/tfin
21ln -sf /path/to/skills/tencent-finance/tfin /usr/local/bin/tfin # Optional: global access
22```
23
24## Commands
25
26### Price (quick check)
27```bash
28tfin AAPL # Quick price
29tfin price AAPL # Same as above
30```
31
32### Quote (detailed)
33```bash
34tfin quote MSFT
35```
36
37### Compare
38```bash
39tfin compare AAPL,MSFT,GOOGL
40tfin compare TSLA,NVDA
41```
42
43### Search
44```bash
45tfin search "tesla"
46tfin search "bitcoin"
47```
48
49### Help
50```bash
51tfin help
52tfin --help
53```
54
55## Symbol Format
56
57- **US stocks:** AAPL, MSFT, GOOGL, TSLA, NVDA
58- **China A-Shares:** sh000001 (上证指数), sz399001 (深证成指), sh600519 (茅台)
59- **Hong Kong:** hk00700 (腾讯), hk09988 (阿里), hk03690 (美团)
60- **Crypto:** BTC-USD, ETH-USD
61
62## Examples
63
64```bash
65# Quick price check
66tfin AAPL
67tfin TSLA
68
69# Detailed quote
70tfin quote NVDA
71
72# Compare tech giants
73tfin compare AAPL,MSFT,GOOGL,META,AMZN
74
75# Search
76tfin search "apple"
77tfin search "bitcoin"
78
79# China stocks
80tfin sh000001 # 上证指数
81tfin quote hk00700 # 腾讯控股
82```
83
84## Data Source
85
86This tool uses **Tencent Finance API** (腾讯财经 API).
87
88**Why Tencent API?**
89- 在中国大陆网络环境下可直接访问,无需代理
90- 比 Yahoo Finance API 更稳定,不受限流影响
91- 数据覆盖美股、A股、港股等多个市场
92
93Data includes:
94- Current price (实时价格)
95- Price change (absolute & percentage) (涨跌额/涨跌幅)
96- Open, High, Low prices (开盘/最高/最低价)
97- Previous close (昨收)
98- Volume (成交量)
99- Market cap (市值)
100- P/E ratio (市盈率)
101- P/B ratio (市净率)
102
103## Supported Markets
104
105| Market | Example | Status |
106|--------|---------|--------|
107| US Stocks | AAPL, TSLA, NVDA | ✅ Supported |
108| China A-Shares | sh000001, sz399001 | ✅ Supported |
109| Hong Kong | hk00700, hk09988 | ✅ Supported |
110| Crypto | BTC-USD, ETH-USD | ✅ Supported |
111| India NSE/BSE | RELIANCE.NS, TCS.BO | ❌ Not supported |
112
113## Comparison with Yahoo Finance
114
115| Feature | Yahoo Finance (yfinance) | Tencent Finance (tfin) |
116|---------|--------------------------|------------------------|
117| Mainland China Access | Often blocked/restricted | ✅ Direct access |
118| Rate Limiting | Frequent | ✅ Stable |
119| US Stocks | ✅ Supported | ✅ Supported |
120| China A-Shares | Limited | ✅ Full support |
121| Hong Kong Stocks | Supported | ✅ Supported |
122| Indian Stocks | ✅ Supported | ❌ Not supported |
123| Options/Dividends | Supported | ❌ Not supported |
124
125## Requirements
126
127- Python 3.7+
128- requests
129- rich
130
131```bash
132pip3 install requests rich
133```
134
135## Troubleshooting
136
137### "No data found"
138- Verify the symbol format
139- Try with prefix: `usAAPL` instead of `AAPL`
140- Some international markets may not be supported
141
142### Connection errors
143- Check internet connection
144- Tencent API is optimized for mainland China and generally very stable
145
146## License
147
148MIT License
149
150## Author
151
152Created by Menrfa