refactor-sync-to-async-api-client
This rule describes how to refactor a function from obb usage to API Client logic.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
This rule describes how to refactor a function from obb usage to API Client logic.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | refactor-sync-to-async-api-client |
| description | This rule describes how to refactor a function from obb usage to API Client logic. |
This rule describes how to refactor functions that synchronously extract data from OpenBB (or similar) sources into an asynchronous, API-client-based pattern. Use this rule to standardize data extraction across the codebase.
This rule describes how to refactor functions that synchronously extract data from OpenBB (or similar) sources into an asynchronous, API-client-based pattern. Use this rule to standardize data extraction across the codebase.
obb.equity.price.historical or similar synchronous OpenBB SDK methods.async def and update all call sites to use await.OpenBBAPIClient).EquityHistoricalQueryParams).await api_client.fetch_data(...)).Add or update the following imports as needed:
from humbldata.core.standard_models.openbbapi.EquityHistoricalQueryParams import EquityHistoricalQueryParams
from humbldata.core.utils.openbb_api_client import OpenBBAPIClient
Please
QueryParams class must exist for the API route being queried (e.g., EquityHistoricalQueryParams for equity.price.historical).src/humbldata/core/standard_models/openbbapi/ folder, named according to the route (e.g., EquityHistoricalQueryParams.py).EquityHistoricalQueryParams).pydantic.BaseModel (or your project's base QueryParams class).src/humbldata/core/standard_models/openbbapi/.If you do not know the required parameters for the API route, prompt the user to provide them or to specify the OpenBB endpoint's signature.
from pydantic import BaseModel
class EquityHistoricalQueryParams(BaseModel):
symbol: str
start_date: str
end_date: str
provider: str = "yfinance"
# Add other parameters as needed
Before:
self.equity_historical_data: pl.LazyFrame = (
obb.equity.price.historical(
symbol=self.context_params.symbols,
start_date=self.context_params.start_date,
end_date=self.context_params.end_date,
provider=self.context_params.provider,
)
.to_polars()
.lazy()
)
After:
api_query_params = EquityHistoricalQueryParams(
symbol=self.context_params.symbols,
start_date=self.context_params.start_date,
end_date=self.context_params.end_date,
provider=self.context_params.provider,
)
api_client = OpenBBAPIClient()
api_client.api_query_params = api_query_params
api_response = await api_client.fetch_data(
obb_path="equity.price.historical",
api_query_params=api_query_params,
)
self.equity_historical_data = api_response.to_polars(collect=False)
symbol column as in the original logic.