# 财务数据查询

> 查询财务数据

## 接口基本信息

- **接口名称**: `get_stock_financial_data`
- **功能描述**: 查询 A 股财务数据及衍生财务指标，支持资产负债表、利润表、现金流量表、现金流量补充资料及单季度数据
- **数据更新频率**: 季度/年度更新
- **请求方法**: `POST`
- **API 路径**: `https://api.wanxingai.com/openapi/get_stock_financial_data/`

---

## 输入参数说明

| 参数名 | 类型 | 必选 | 描述 | 示例 |
| --- | --- | --- | --- | --- |
| `stock_code` | str | **是** | 完整股票代码，需带交易所后缀。多个股票可用英文逗号分隔 | `300033.SZ` |
| `date` | str | 否 | 查询日期。支持 `YYYYMMDD` 或 `YYYY-MM-DD`。不传时默认当天。系统会根据该日期自动计算最近报告期 | `20260526` |
| `unit` | str | 否 | 指标单位参数，默认 `100`。一般无需传 | `100` |
| `report_period` | str | 否 | 指定报告期。支持 `YYYYMMDD` 或 `YYYY-MM-DD`。不传时系统会根据 `date` 自动计算最近报告期。报告期通常为 `0331`、`0630`、`0930`、`1231` | `20260331` |
| `indicators` | array | **是** | 需要查询的指标列表。支持字符串或对象。字符串形式用于常规查询；对象形式可为单个指标指定特殊参数 | `["currency_fund_stock", "sq_revenue_stock"]` |

---

## 指标参数规则

系统会根据指标类型自动生成底层查询参数，用户通常只需要传入 `stock_code`、`date` 和 `indicators`。

| 指标类型 | 判断规则 | 使用参数 | 示例 |
| --- | --- | --- | --- |
| 普通财报指标 | 非 `sq_` 开头的指标 | `[最近报告期, unit]` | `["20260331", "100"]` |
| 单季度指标 | `sq_` 开头的指标 | `[当前查询日期, unit]` | `["20260526", "100"]` |
| 特殊参数指标 | 用户在单个指标中显式传入 `indiparams` | 完全使用用户传入的参数 | `["100", "2025", "100"]` |

例如传入 `date=20260526` 时，系统会自动计算最近报告期为 `20260331`。普通财报指标使用 `["20260331", "100"]`，单季度指标使用 `["20260526", "100"]`。

---

### 请求参数示例

#### 示例 1：查询普通财报指标

```
{
  "stock_code": "300033.SZ",
  "date": "20260526",
  "indicators": [
    "currency_fund_stock",
    "settle_reserves_stock",
    "total_assets_stock",
    "np_stock"
  ]
}
```

#### 示例 2：查询单季度指标

```
{
  "stock_code": "300033.SZ",
  "date": "20260526",
  "indicators": [
    "sq_revenue_stock",
    "sq_np_stock",
    "sq_np_atoopc_stock"
  ]
}
```

#### 示例 3：混合查询普通指标、单季度指标和特殊参数指标

```
{
  "stock_code": "300033.SZ",
  "date": "20260526",
  "indicators": [
    "currency_fund_stock",
    "settle_reserves_stock",
    "sq_revenue_stock",
    {
      "indicator": "sq_operating_total_cost_2_stock",
      "indiparams": ["100", "2025", "100"]
    }
  ]
}
```

---

### 返回数据说明

返回 JSON 对象，格式如下：

```
{
  "status": 200,
  "message": [
    {
      "stock_code": "300033.SZ",
      "data": [
        {
          "indicator": "currency_fund_stock",
          "description": "货币资金",
          "value": 123456789
        }
      ]
    }
  ]
}
```

| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| `status` | int | 状态码。`200` 表示成功，`201` 表示参数错误，`401` 表示余额不足或鉴权失败，`500` 表示服务异常 |
| `message` | array | 返回结果数组 |
| `stock_code` | str | 标准股票代码 |
| `data` | array[object] | 指标数据列表 |
| `indicator` | str | 开放平台指标名 |
| `description` | str | 指标中文名称 |
| `value` | number/string/null | 指标值。若暂无数据，可能返回 `null` |

---

### 核心指标列表（300+ 项，以下列出主要分类代表字段）

#### 资产负债表

| indicator | description |
| --- | --- |
| `currency_fund_stock` | 货币资金 |
| `settle_reserves_stock` | 结算备付金 |
| `lending_fund_stock` | 拆出资金 |
| `tradable_fnncl_assets_stock` | 交易性金融资产 |
| `derivative_fnncl_assets_stock` | 衍生金融资产 |
| `bill_receivable_stock` | 应收票据 |
| `account_receivable_stock` | 应收账款 |
| `receivable_financing_stock` | 应收款项融资 |
| `prepays_stock` | 预付款项 |
| `other_receivables_stock` | 其他应收款 |
| `inventory_stock` | 存货 |
| `contract_asset_stock` | 合同资产 |
| `total_current_assets_stock` | 流动资产合计 |
| `lt_equity_invest_stock` | 长期股权投资 |
| `invest_property_stock` | 投资性房地产 |
| `fixed_asset_stock` | 固定资产 |
| `construction_in_process_stock` | 在建工程 |
| `right_of_use_assets_stock` | 使用权资产 |
| `intangible_assets_stock` | 无形资产 |
| `goodwill_stock` | 商誉 |
| `dt_assets_stock` | 递延所得税资产 |
| `total_noncurrent_assets_stock` | 非流动资产合计 |
| `total_assets_stock` | 资产总计 |
| `st_borrow_stock` | 短期借款 |
| `bill_payable_stock` | 应付票据 |
| `accounts_payable_stock` | 应付账款 |
| `advance_payment_stock` | 预收款项 |
| `contract_liab_stock` | 合同负债 |
| `payroll_payable_stock` | 应付职工薪酬 |
| `tax_payable_stock` | 应交税费 |
| `other_payables_stock` | 其他应付款 |
| `noncurrent_liab_due_in1y_stock` | 一年内到期的非流动负债 |
| `other_current_liab_stock` | 其他流动负债 |
| `total_current_liab_stock` | 流动负债合计 |
| `lt_loan_stock` | 长期借款 |
| `bond_payable_stock` | 应付债券 |
| `lease_libilities_stock` | 租赁负债 |
| `estimated_liab_stock` | 预计负债 |
| `dt_liab_stock` | 递延所得税负债 |
| `total_noncurrent_liab_stock` | 非流动负债合计 |
| `total_liab_stock` | 负债合计 |
| `actual_received_capital_stock` | 实收资本 |
| `capital_reserve_stock` | 资本公积 |
| `earned_surplus_stock` | 盈余公积 |
| `undstrbtd_profit_stock` | 未分配利润 |
| `total_equity_atoopc_stock` | 归属于母公司所有者权益合计 |
| `minority_equity_stock` | 少数股东权益 |
| `total_owner_equity_stock` | 所有者权益合计 |
| `total_liab_and_owner_equity_stock` | 负债和所有者权益总计 |

#### 利润表

| indicator | description |
| --- | --- |
| `operating_total_revenue_stock` | 营业总收入 |
| `revenue_stock` | 营业收入 |
| `operating_total_cost_stock` | 营业总成本 |
| `operating_cost_stock` | 营业成本 |
| `operating_taxes_and_surcharge_stock` | 税金及附加 |
| `sales_fee_stock` | 销售费用 |
| `manage_fee_stock` | 管理费用 |
| `rad_cost_sum_stock` | 研发费用 |
| `financing_expenses_stock` | 财务费用 |
| `asset_impairment_loss_stock` | 资产减值损失 |
| `credit_impairment_loss_stock` | 信用减值损失 |
| `fv_chg_income_stock` | 公允价值变动收益 |
| `invest_income_stock` | 投资收益 |
| `asset_disposal_gain_stock` | 资产处置收益 |
| `other_income_stock` | 其他收益 |
| `op_stock` | 营业利润 |
| `non_operating_income_stock` | 营业外收入 |
| `nonoperating_cost_stock` | 营业外支出 |
| `total_profit_stock` | 利润总额 |
| `income_tax_cost_stock` | 所得税费用 |
| `np_stock` | 净利润 |
| `np_atoopc_stock` | 归属于母公司所有者的净利润 |
| `minority_gal_stock` | 少数股东损益 |
| `basic_eps_stock` | 基本每股收益 |
| `dlt_earnings_per_share_stock` | 稀释每股收益 |
| `total_compre_income_stock` | 综合收益总额 |

#### 现金流量表

| indicator | description |
| --- | --- |
| `cash_received_of_sales_service_stock` | 销售商品、提供劳务收到的现金 |
| `refund_of_tax_and_levies_stock` | 收到的税费返还 |
| `cash_received_of_other_oa_stock` | 收到其他与经营活动有关的现金 |
| `sub_total_of_ci_from_oa_stock` | 经营活动现金流入小计 |
| `goods_buy_and_service_cash_pay_stock` | 购买商品、接受劳务支付的现金 |
| `cash_paid_to_staff_etc_stock` | 支付给职工以及为职工支付的现金 |
| `payments_of_all_taxes_stock` | 支付的各项税费 |
| `other_cash_paid_related_to_oa_stock` | 支付其他与经营活动有关的现金 |
| `sub_total_of_cos_from_oa_stock` | 经营活动现金流出小计 |
| `ncf_from_oa_stock` | 经营活动产生的现金流量净额 |
| `cash_received_of_dspsl_invest_stock` | 收回投资收到的现金 |
| `invest_income_cash_received_stock` | 取得投资收益收到的现金 |
| `sub_total_of_ci_from_ia_stock` | 投资活动现金流入小计 |
| `cash_paid_for_assets_stock` | 购建固定资产、无形资产和其他长期资产支付的现金 |
| `invest_paid_cash_stock` | 投资支付的现金 |
| `sub_total_of_cos_from_ia_stock` | 投资活动现金流出小计 |
| `ncf_from_ia_stock` | 投资活动产生的现金流量净额 |
| `cash_received_of_absorb_invest_stock` | 吸收投资收到的现金 |
| `cash_received_of_borrowing_stock` | 取得借款收到的现金 |
| `sub_total_of_ci_from_fa_stock` | 筹资活动现金流入小计 |
| `cash_pay_for_debt_stock` | 偿还债务支付的现金 |
| `cash_paid_of_distribution_stock` | 分配股利、利润或偿付利息支付的现金 |
| `sub_total_of_cos_from_fa_stock` | 筹资活动现金流出小计 |
| `ncf_from_fa_stock` | 筹资活动产生的现金流量净额 |
| `net_increase_in_cce_stock` | 现金及现金等价物净增加额 |
| `initial_cce_balance_stock` | 期初现金及现金等价物余额 |
| `final_balance_of_cce_stock` | 期末现金及现金等价物余额 |

#### 现金流量表补充资料

| indicator | description |
| --- | --- |
| `np_cfs_stock` | 净利润 |
| `asset_impairment_reserve_stock` | 资产减值准备 |
| `depreciation_etc_stock` | 固定资产折旧、油气资产折耗、生产性生物资产折旧 |
| `intangible_assets_amortized_stock` | 无形资产摊销 |
| `lt_deferred_expenses_amrtzt_stock` | 长期待摊费用摊销 |
| `loss_of_disposal_assets_stock` | 处置固定资产、无形资产和其他长期资产的损失 |
| `fixed_assets_scrap_loss_stock` | 固定资产报废损失 |
| `loss_from_fv_chg_stock` | 公允价值变动损失 |
| `finance_cost_cfs_stock` | 财务费用 |
| `invest_loss_stock` | 投资损失 |
| `dt_assets_decrease_stock` | 递延所得税资产减少 |
| `dt_liab_increase_stock` | 递延所得税负债增加 |
| `inventory_decrease_stock` | 存货的减少 |
| `operating_items_decrease_stock` | 经营性应收项目的减少 |
| `increase_of_operating_item_stock` | 经营性应付项目的增加 |
| `ncf_from_oa_im_stock` | 经营活动产生的现金流量净额 |
| `ending_balance_of_cash_stock` | 现金的期末余额 |
| `initial_balance_of_cash_stock` | 现金的期初余额 |

#### 单季度数据

| indicator | description |
| --- | --- |
| `sq_operating_total_revenue_stock` | 单季度.营业总收入 |
| `sq_revenue_stock` | 单季度.营业收入 |
| `sq_operating_total_cost_stock` | 单季度.营业总成本 |
| `sq_operating_cost_stock` | 单季度.营业成本 |
| `sq_sales_fee_stock` | 单季度.销售费用 |
| `sq_manage_fee_stock` | 单季度.管理费用 |
| `sq_rad_cost_sum_stock` | 单季度.研发费用 |
| `sq_finance_cost_stock` | 单季度.财务费用 |
| `sq_invest_income_stock` | 单季度.投资收益 |
| `sq_op_stock` | 单季度.营业利润 |
| `sq_total_profit_stock` | 单季度.利润总额 |
| `sq_income_tax_cost_stock` | 单季度.所得税费用 |
| `sq_np_stock` | 单季度.净利润 |
| `sq_np_atoopc_stock` | 单季度.归属于母公司所有者的净利润 |
| `sq_basic_eps_stock` | 单季度.基本每股收益 |
| `sq_ncf_from_oa_stock` | 单季度.经营活动产生的现金流量净额 |
| `sq_ncf_from_ia_stock` | 单季度.投资活动产生的现金流量净额 |
| `sq_ncf_from_fa_stock` | 单季度.筹资活动产生的现金流量净额 |
| `sq_net_increase_in_cce_stock` | 单季度.现金及现金等价物净增加额 |
| ...（其余单季度指标前缀均为 `sq_`） | 与非单季度字段一一对应 |

---

## 使用示例

```python
import requests

url = "https://api.wanxingai.com/openapi/get_stock_financial_data/"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-********"
}

payload = {
    "stock_code": "300033.SZ",
    "date": "20260526",
    "indicators": [
        "currency_fund_stock",
        "settle_reserves_stock",
        "total_assets_stock",
        "sq_revenue_stock",
        "sq_np_stock",
        {
            "indicator": "sq_operating_total_cost_2_stock",
            "indiparams": ["100", "2025", "100"]
        }
    ]
}

resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
```

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        String json = """
        {
          "stock_code": "300033.SZ",
          "date": "20260526",
          "indicators": [
            "currency_fund_stock",
            "settle_reserves_stock",
            "total_assets_stock",
            "sq_revenue_stock",
            "sq_np_stock",
            {
              "indicator": "sq_operating_total_cost_2_stock",
              "indiparams": ["100", "2025", "100"]
            }
          ]
        }
        """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.wanxingai.com/openapi/get_stock_financial_data/"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer sk-********")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```curl
curl -X POST https://api.wanxingai.com/openapi/get_stock_financial_data/ \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer sk-********" \\
  -d '{
    "stock_code": "300033.SZ",
    "date": "20260526",
    "indicators": [
      "currency_fund_stock",
      "settle_reserves_stock",
      "total_assets_stock",
      "sq_revenue_stock",
      "sq_np_stock",
      {
        "indicator": "sq_operating_total_cost_2_stock",
        "indiparams": ["100", "2025", "100"]
      }
    ]
  }'
```

### 注意事项

1. 接口支持 300+ 项财务指标，用户可通过 `indicators` 参数按需查询
2. `indicators` 为必填参数，至少传入一个指标
3. 普通财报指标默认使用最近报告期参数，例如 `["20260331", "100"]`
4. 单季度指标，即 `sq_` 开头的指标，默认使用当前查询日期参数，例如 `["20260526", "100"]`
5. 如果某个指标需要特殊参数，可以使用对象形式传入 `indiparams`，系统会按传入参数查询
6. `date` 不传时默认当天
7. `unit` 不传时默认 `100`
8. 返回结果中的 `indicator` 为开放平台指标名
