chore: 添加项目依赖和README文档
- 新增 requirements.txt 文件,包含核心依赖库 - 新增 README.md 文件,提供SDK安装、使用说明和示例代码
This commit is contained in:
1 parent
f59d438688
commit
16d68558b2
2 files changed
+87
No files matched your search
@@ -0,0 +1,82 @@
|
||||
# iTick Python SDK
|
||||
|
||||
Official Python SDK for iTick Market Data API.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install itick-python
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### REST API
|
||||
|
||||
```python
|
||||
from itick import Client, Environment, KlinePeriod
|
||||
|
||||
client = Client(token="YOUR_API_TOKEN", environment=Environment.FREE)
|
||||
|
||||
# --- Basic Data ---
|
||||
# Get Crypto Quote
|
||||
quote = client.crypto.get_quote(region="BA", code="BTCUSDT")
|
||||
print(quote)
|
||||
|
||||
# Get Stock Depth
|
||||
depth = client.stock.get_depth(region="US", code="AAPL")
|
||||
print(depth)
|
||||
|
||||
# Get K-lines (1 Minute)
|
||||
klines = client.stock.get_kline(region="US", code="AAPL", period=KlinePeriod.ONE_MINUTE.value)
|
||||
print(klines)
|
||||
|
||||
# --- Batch Requests ---
|
||||
# Get multiple quotes
|
||||
quotes = client.crypto.get_quotes(region="BA", codes=["BTCUSDT", "ETHUSDT"])
|
||||
print(quotes)
|
||||
|
||||
# --- Stock Specific Info ---
|
||||
# Get Stock Info
|
||||
info = client.stock.get_info(region="US", code="AAPL")
|
||||
print(info)
|
||||
|
||||
# Get IPOs
|
||||
ipos = client.stock.get_ipo(region="US", type="upcoming")
|
||||
print(ipos)
|
||||
|
||||
# --- Symbol & Market Info ---
|
||||
# Get Product List
|
||||
symbols = client.symbol.get_list(type="stock", region="US")
|
||||
print(symbols)
|
||||
|
||||
# Get Holidays
|
||||
holidays = client.symbol.get_holidays(region_code="US")
|
||||
print(holidays)
|
||||
```
|
||||
|
||||
### WebSocket API
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
from itick import SocketClient, Environment, Product
|
||||
|
||||
async def main():
|
||||
def on_message(msg):
|
||||
print("Received:", msg)
|
||||
|
||||
client = SocketClient(token="YOUR_API_TOKEN", product=Product.CRYPTO, environment=Environment.FREE, on_message=on_message)
|
||||
|
||||
await client.connect()
|
||||
|
||||
# Wait for authentication (optional, usually fast)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await client.subscribe(["BTCUSDT$BA"], ["quote", "depth"])
|
||||
|
||||
# Keep running
|
||||
while True:
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
requests
|
||||
beautifulsoup4
|
||||
markdownify
|
||||
lxml
|
||||
websockets
|
||||
Reference in new issue
Block a user