📝 docs(tsl-api): add missing financial API codegen entries
This commit is contained in:
@@ -114,6 +114,154 @@ class TslApiFrameworkTests(unittest.TestCase):
|
||||
self.assertEqual([], fallback_pages)
|
||||
self.assertEqual([], fallback_rows)
|
||||
|
||||
def test_recent_financial_functions_have_normalized_signatures_and_sources(self):
|
||||
expected = {
|
||||
"adjustmentFactor": (
|
||||
"AdjustmentFactor",
|
||||
"adjustmentFactor(rate_day)",
|
||||
"dotnet/financial/market-specified_date.md",
|
||||
),
|
||||
"stockZtOrDtCloseOfMD": (
|
||||
"StockZtOrDtCloseOfMD",
|
||||
"stockZtOrDtCloseOfMD(flag)",
|
||||
"dotnet/financial/market-specified_date.md",
|
||||
),
|
||||
"getEtfListByDate": (
|
||||
"GetETFListByDate",
|
||||
"getEtfListByDate(bk_name, end_t)",
|
||||
"dotnet/financial/fund-etf.md",
|
||||
),
|
||||
"getIndexAdjustDate": (
|
||||
"GetIndexAdjustDate",
|
||||
"getIndexAdjustDate(index_id, beg_t, end_t)",
|
||||
"dotnet/financial/index-index_info.md",
|
||||
),
|
||||
"fi_report_excessYields": (
|
||||
"fi_report_ExcessYields",
|
||||
"fi_report_excessYields(rt_data, fname_pf, fname_bm, "
|
||||
"fname_date, plot_type)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_corrAnalysis": (
|
||||
"fi_report_CorrAnalysis",
|
||||
"fi_report_corrAnalysis(rt_data, fname_date)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_historicalPerformance": (
|
||||
"fi_report_HistoricalPerformance",
|
||||
"fi_report_historicalPerformance(rt_data, fname_bm, "
|
||||
"fname_date, cycle, factor_roll_n_year)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_periodReturn": (
|
||||
"fi_report_PeriodReturn",
|
||||
"fi_report_periodReturn(rt_data, fname_date)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_returnAndRisk": (
|
||||
"fi_report_ReturnAndRisk",
|
||||
"fi_report_returnAndRisk(rt_data, fname_date, qk_type, cycle, "
|
||||
"days_in_1_y)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_riskFeature": (
|
||||
"fi_report_RiskFeature",
|
||||
"fi_report_riskFeature(rt_data, fname_bm, fname_date, "
|
||||
"days_in_1_y)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"fi_report_rollReturn": (
|
||||
"fi_report_RollReturn",
|
||||
"fi_report_rollReturn(rt_data, fname_date, cycle)",
|
||||
"dotnet/financial/financial_engineering-factor_research-"
|
||||
"performance_analysis-return_evaluation-intermediate-"
|
||||
"common_reports.md",
|
||||
),
|
||||
"financialItemIn12Month_HK": (
|
||||
"FinancialItemIn12Month_HK",
|
||||
"financialItemIn12Month_HK(r_date, info_id, "
|
||||
"if_to_func_currency)",
|
||||
"dotnet/financial/financial_analysis-extended_"
|
||||
"fundamental_data.md",
|
||||
),
|
||||
"reportType_HK": (
|
||||
"ReportType_HK",
|
||||
"reportType_HK(r_date, r_type)",
|
||||
"dotnet/financial/financial_analysis-extended_"
|
||||
"fundamental_data.md",
|
||||
),
|
||||
"originalToFunctionalCurrency_HK": (
|
||||
"OriginalToFunctionalCurrency_HK",
|
||||
"originalToFunctionalCurrency_HK(end_t, original_value, "
|
||||
"original_currency)",
|
||||
"dotnet/financial/financial_analysis-extended_"
|
||||
"fundamental_data.md",
|
||||
),
|
||||
}
|
||||
with FUNCTION_INDEX.open(encoding="utf-8", newline="") as handle:
|
||||
rows = list(csv.DictReader(handle, delimiter="\t"))
|
||||
|
||||
by_name = {row["name"]: row for row in rows}
|
||||
self.assertEqual(set(expected), set(expected) & set(by_name))
|
||||
for name, (query_name, signature, page) in expected.items():
|
||||
with self.subTest(name=name):
|
||||
row = by_name[name]
|
||||
self.assertEqual("dotnet", row["scope"])
|
||||
self.assertEqual("financial", row["module"])
|
||||
self.assertEqual(signature, row["signature"])
|
||||
self.assertEqual(page, row["page"])
|
||||
result = run_script(API_LOOKUP, "--name", query_name)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertIn(f"## `{signature}`", result.stdout)
|
||||
self.assertIn(f"{page}#", result.stdout)
|
||||
|
||||
parameter_text = signature.partition("(")[2].removesuffix(")")
|
||||
for parameter in filter(None, parameter_text.split(", ")):
|
||||
self.assertRegex(
|
||||
parameter,
|
||||
r"^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$",
|
||||
)
|
||||
|
||||
parameter_types = []
|
||||
for line in result.stdout.splitlines():
|
||||
match = re.fullmatch(
|
||||
r"\| `[^`]+`\s+\|\s+([^|]+?)\s+\|.*",
|
||||
line,
|
||||
)
|
||||
if match:
|
||||
parameter_types.append(match.group(1).strip())
|
||||
self.assertTrue(parameter_types)
|
||||
self.assertTrue(
|
||||
all(value == value.casefold() for value in parameter_types)
|
||||
)
|
||||
|
||||
return_types = [
|
||||
line.removeprefix("返回:").strip()
|
||||
for line in result.stdout.splitlines()
|
||||
if line.startswith("返回:")
|
||||
]
|
||||
self.assertEqual(1, len(return_types))
|
||||
self.assertEqual(return_types[0], return_types[0].casefold())
|
||||
|
||||
for name in (
|
||||
"financialItemIn12Month_HK",
|
||||
"reportType_HK",
|
||||
"originalToFunctionalCurrency_HK",
|
||||
):
|
||||
self.assertIn("_HK", by_name[name]["signature"])
|
||||
|
||||
def test_class_index_covers_all_indexed_class_kinds(self):
|
||||
result = run_script(CLASS_LOOKUP, "--list", "--format", "json")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user