fix: fetch dataset scope options from WorldQuant platform
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Literal
|
||||
from pydantic import Field
|
||||
|
||||
from ..backtests.contracts import ControlInput, PreviewInput, RerunInput, StartInput
|
||||
from ..catalog.contracts import UNIVERSES, CatalogFilters, Scope
|
||||
from ..catalog.contracts import CatalogFilters, Scope
|
||||
from ..research.contracts import (
|
||||
ChatboxResearchInput,
|
||||
InputPageArgs,
|
||||
@@ -105,7 +105,7 @@ class BacktestRerunArgs(BacktestRunArgs):
|
||||
|
||||
|
||||
CATALOG = {
|
||||
"get_catalog_scopes": (EmptyArgs, "读取本版支持的研究范围组合,不表示账户已获平台权限。"),
|
||||
"get_catalog_scopes": (EmptyArgs, "从平台读取当前账户可用的研究范围组合。"),
|
||||
"search_catalog": (
|
||||
CatalogSearchArgs,
|
||||
"分页查询本地目录。省略 dataset_id 查询数据集;提供 dataset_id 查询其字段、类型和完整集合版本。无缓存时说明需在数据集页同步,不编造字段。",
|
||||
@@ -200,11 +200,13 @@ def bounded(value):
|
||||
return value
|
||||
|
||||
|
||||
async def read_tool(business, name, args):
|
||||
async def read_tool(business, name, args, platform_client=None):
|
||||
from datetime import timezone
|
||||
|
||||
if name == "get_catalog_scopes":
|
||||
data = {"universes": UNIVERSES, "instrument_type": "EQUITY", "delays": [0, 1]}
|
||||
from ..catalog.platform import platform_options
|
||||
|
||||
data = await platform_options(platform_client)
|
||||
elif name == "search_catalog":
|
||||
data = await business.catalog.search(args.filters, args.dataset_id)
|
||||
data.update(
|
||||
@@ -271,6 +273,8 @@ async def read_tool(business, name, args):
|
||||
if isinstance(data, list):
|
||||
data = {"items": data[:20]}
|
||||
data["_meta"] = ResultMetadata(observed_at=datetime.now(timezone.utc)).model_dump(mode="json")
|
||||
if name == "get_catalog_scopes":
|
||||
data["_meta"]["source"] = "worldquant_platform"
|
||||
return bounded(data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user