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