راهاندازی در Jupyter#
اولین دیتافریم#
در یک cell بنویس
%pip install oxtapus.kernel رو یکبار restart کن.
کد زیر رو اجرا کن:
import polars as pl
import oxtapus as ox
df = ox.tsetmc.daily_prices(["فولاد", "خودرو"], progress=True)
df.head()
برای دیدن آخرین قیمت موجود هر نماد:
latest = (
df.sort("trading_date")
.group_by("symbol")
.agg(
pl.col("trading_date").last(),
pl.col("close_price").last(),
)
)
latest
تبدیل به Pandas#
اگه ابزار بعدیات Pandas یا کتابخونهای مثل statsmodels است، extra مربوطه رو نصب کن و تبدیل رو انجام بده:
%pip install 'oxtapus[pandas]'
pandas_df = df.to_pandas()
اجرای ناهمگام#
Jupyter از await مستقیم پشتیبانی میکنه:
from oxtapus import AsyncClient
async with AsyncClient() as client:
df = await client.market.daily_prices(["فولاد", "خودرو"], progress=True)
usd = await client.assets.history("دلار")
نیازی به asyncio.run، دستکاری حلقهٔ رویداد (event loop) یا nest_asyncio نیست. نمایش
پیشرفت هم در خروجی cell کار میکنه.