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.