財務条件を Company Query にする
売上、利益、BS/CF、利益率などの自然文条件を company_query.v1 に変換し、sf query で実行する手順です。
このページの内容9項目
財務しきい値や財務ランキングを含む依頼は、sf company search の自然文 q に残しません。 agent / backend が company_query.v1 を作り、sf query で実行します。
sf data capabilities --json sf query --file company-query.json --json
credit は、実行可能な Company Query が Search に到達したときに 1 request credit です。 unsupported / weak / needs_human は 0 件成功として扱いません。
使う場面
次の条件が入る場合は、この workflow を使います。
- 売上、営業利益、純利益、経常利益、税引前利益
- 総資産、負債、純資産、現金、棚卸資産、有利子負債
- 営業CF、投資CF、財務CF、設備投資、減価償却費
- 営業利益率、純利益率など approved margin
- 上位 / 下位 / top / bottom / 大きい / 少ない などの財務ランキング
- 2026年に新規上場、上場廃止、市場変更、合併、spin-off などの event 条件と財務条件の組み合わせ
社名やテーマだけの検索は Company Search を使います。 財務条件とテーマ語が混ざる場合も、財務条件は company_query.v1 に構造化し、テーマ語の coverage は warning として読みます。
1. 財務 catalog を読む
metric 名を決める前に、CLI の catalog を読みます。
sf data capabilities --json
見る key:
financial_metric_catalog.contract_versionfinancial_metric_catalog.metrics[].canonical_metricfinancial_metric_catalog.metrics[].supported_operatorsfinancial_metric_catalog.aliases[]financial_metric_catalog.compiler_hints[]financial_metric_catalog.unsupported_conditions[]financial_metric_catalog.unsupported_conditions[].agent_contractfinancial_metric_catalog.metrics[].policy.source_fact_filterfinancial_metric_catalog.metrics[].policy.guardrailsfinancial_metric_catalog.metrics[].policy.component_formulafinancial_metric_catalog.metrics[].policy.derived_formulafinancial_metric_catalog.provenance_policy
compiler_hints[] は自然文の変換規則です。assets は total_assets、liabilities は total_liabilities、operating_cf は operating_cash_flow にしてから JSON を出します。 これは schema alias ではありません。 unsupported_conditions[] は source_health_gap_id、source_neutral_policy_hold、agent_contract も返します。企業再編や上場廃止をまたぐ Financial Gold screen は corporate_action_lineage_financial_screen として止め、lineage_event_id と metric_basis の source-neutral policy がないまま successor/current-listed fact に近似しません。
2. company_query.v1 を作る
例: 上場企業で営業利益と純利益が黒字、かつ売上1000億円以上
{
"contract_version": "company_query.v1",
"raw_request": "上場企業で営業利益と純利益が黒字、かつ売上1000億円以上",
"predicates": [
{
"type": "listing_status",
"operator": "in",
"values": ["listed"]
},
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "operating_income",
"operator": "positive",
"period": { "latest": true }
},
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "net_income",
"operator": "positive",
"period": { "latest": true }
},
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "revenue",
"operator": "gte",
"period": { "latest": true },
"value": {
"amount": 100000000000,
"currency": "JPY",
"unit": "absolute"
}
}
],
"requested_output": {
"limit": 20
},
"execution_policy": {
"allow_db_writes": false,
"allow_external_search": false,
"allow_llm_sql": false,
"allow_unvalidated_q_fallback": false
}
}
金額は JPY の absolute value にします。利益率は 0.05 のような ratio、または明示した percent として出します。 費用、税金、設備投資、自己株式は報告値の符号を反転しません。
3. event 条件は event predicate にする
2026年に新規上場した金融業で利息収益100億円以上、売上1000億円以上 のような依頼では、listing_status=listed に置き換えません。 listing_event と Financial Gold predicate を同じ company_query.v1 に入れます。
{
"contract_version": "company_query.v1",
"raw_request": "2026年に新規上場した金融業で利息収益100億円以上、売上1000億円以上",
"predicates": [
{
"type": "listing_event",
"operator": "match",
"event_types": ["new_listing"],
"date": {
"gte": "2026-01-01",
"lte": "2026-12-31"
}
},
{
"type": "industry_33_code",
"operator": "in",
"values": ["7050", "7100", "7150", "7200"]
},
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "interest_income",
"operator": "gte",
"period": { "latest": true },
"value": {
"amount": 10000000000,
"currency": "JPY",
"unit": "absolute"
}
},
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "revenue",
"operator": "gte",
"period": { "latest": true },
"value": {
"amount": 100000000000,
"currency": "JPY",
"unit": "absolute"
}
}
],
"requested_output": {
"limit": 20
}
}
合併や spin-off など participant role が必要な条件は corporate_event を使います。実行時は company_events executor の company id set と financial_gold executor の company id set を交差してから Search に渡します。
4. ranking は sort にする
営業CFが大きい上場企業トップ20 のような依頼では、架空のしきい値を作りません。 requested_output.sort[] を使います。
{
"contract_version": "company_query.v1",
"raw_request": "営業CFが大きい上場企業トップ20",
"predicates": [
{
"type": "listing_status",
"operator": "in",
"values": ["listed"]
}
],
"requested_output": {
"limit": 20,
"sort": [
{
"type": "financial_metric",
"source": "biz_1738_gold_financial_dataset",
"metric": "operating_cash_flow",
"direction": "desc",
"period": { "latest": true }
}
]
},
"execution_policy": {
"allow_db_writes": false,
"allow_external_search": false,
"allow_llm_sql": false,
"allow_unvalidated_q_fallback": false
}
}
desc は上位 / 最大 / highest、asc は下位 / 最小 / lowest です。
5. 実行して key を読む
sf query --file company-query.json --json
確認する key:
okquery.statusquery.gaps[]query.warnings[]query.executors.company_events.statusquery.executors.company_events.result.matched_events[]query.executors.financial_gold.statusquery.executors.financial_gold.request.filters[]query.executors.financial_gold.result.orderingquery.executors.financial_gold.result.matched_countquery.executors.financial_gold.result.matched_financial_facts[]search.meta.returned_companiessearch.meta.coverage_warnings
会社が hit した理由を説明する場合は、matched_count だけでなく matched_financial_facts[] の metric_id、value、period_end、filing_id、source_id、source_fact_ref を読みます。 event 条件がある場合は、matched_events[] の event_type、event_date、participant_role、source_url も読みます。
unsupported を止める
次は supported metric へ近似しません。
- ROE
- EBITDA
- 自己資本比率
- free cash flow
- approved margin 以外の generic ratio
- 財務条件同士の OR / NOT complement set
5期連続増収などの trend- 任意 fiscal year selector
- short-term debt / long-term debt
ordinary_profitliteral
この場合は unsupported_predicate または response の blocking gap を残します。 sf company search "<財務条件>" --json に逃がさないでください。
復旧方法
| 状態 | 次にやること |
|---|---|
invalid_request | schema、metric 名、operator、source を直す |
company_event_hosted_table_pending | event predicate を削らず、hosted event executor の readiness を確認する |
company_event_no_matches | event 条件だけで 0 件。現在上場条件に置き換えない |
company_query_candidate_intersection_empty | event set と Financial Gold set の交差が 0 件。条件を分解して確認する |
financial_gold_adapter_unsupported | financial_metric_catalog.unsupported_conditions[].agent_contract を読み、unsupported 条件を削るか人間に確認する |
needs_human | clarification_requests[] の質問に答えて query plan を作り直す |
weak | semantic tag や coverage の弱さを表示し、財務条件とテーマ条件を分ける |
financial_gold_no_matches | executor は動いている。閾値、業種、上場状態を見直す |
financial_gold_result_truncated / company_event_result_truncated | 業種、市場区分、上場状態、event date、しきい値を追加して絞る |
matched_count: 0 でも、unsupported / weak / hosted_table_pending がある場合は市場不在ではありません。 status: "ready" かつ matched_count: 0 のときだけ、現在の hosted Financial Gold filter では matching company id がないと説明します。
次に読む
- API contract: Company Query API
- CLI reference: コマンドとフラグ
- 低ヒットの見直し: 低ヒット検索の見直し方
- 出所と coverage: データの出所