From 16d68558b2473d28cf4a586ebff56c266d9c254f Mon Sep 17 00:00:00 2001 From: yilv <874448085@qq.com> Date: Tue, 3 Mar 2026 15:25:28 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=92=8CREADME=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 requirements.txt 文件,包含核心依赖库 - 新增 README.md 文件,提供SDK安装、使用说明和示例代码 --- README.md | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 5 +++ 2 files changed, 87 insertions(+) create mode 100644 README.md create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..fec3efe --- /dev/null +++ b/README.md @@ -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()) +``` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8e1b458 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +requests +beautifulsoup4 +markdownify +lxml +websockets