lib-x17-fintech 2.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lib_x17_fintech-2.1.3.dist-info/METADATA +633 -0
- lib_x17_fintech-2.1.3.dist-info/RECORD +282 -0
- lib_x17_fintech-2.1.3.dist-info/WHEEL +5 -0
- lib_x17_fintech-2.1.3.dist-info/licenses/LICENSE +1 -0
- lib_x17_fintech-2.1.3.dist-info/top_level.txt +1 -0
- xfintech/__init__.py +0 -0
- xfintech/connect/__init__.py +18 -0
- xfintech/connect/artifact/__init__.py +5 -0
- xfintech/connect/artifact/artifact.py +168 -0
- xfintech/connect/artifact/tests/__init__.py +3 -0
- xfintech/connect/artifact/tests/test_class_artifact_all.py +564 -0
- xfintech/connect/common/__init__.py +12 -0
- xfintech/connect/common/connect.py +49 -0
- xfintech/connect/common/connectref.py +119 -0
- xfintech/connect/common/error.py +62 -0
- xfintech/connect/common/tests/__init__.py +1 -0
- xfintech/connect/common/tests/test_class_connectlike_all.py +544 -0
- xfintech/connect/common/tests/test_class_connectref_all.py +586 -0
- xfintech/connect/common/tests/test_class_errors_all.py +524 -0
- xfintech/connect/instance/__init__.py +7 -0
- xfintech/connect/instance/macos.py +121 -0
- xfintech/connect/instance/s3.py +176 -0
- xfintech/connect/instance/tests/__init__.py +1 -0
- xfintech/connect/instance/tests/test_class_macosconnect_all.py +692 -0
- xfintech/connect/instance/tests/test_class_s3connect_all.py +603 -0
- xfintech/data/__init__.py +20 -0
- xfintech/data/common/__init__.py +15 -0
- xfintech/data/common/cache.py +186 -0
- xfintech/data/common/coolant.py +171 -0
- xfintech/data/common/metric.py +138 -0
- xfintech/data/common/paginate.py +132 -0
- xfintech/data/common/params.py +162 -0
- xfintech/data/common/retry.py +201 -0
- xfintech/data/common/tests/__init__.py +1 -0
- xfintech/data/common/tests/test_class_cache_all.py +681 -0
- xfintech/data/common/tests/test_class_coolant_all.py +534 -0
- xfintech/data/common/tests/test_class_metric_all.py +705 -0
- xfintech/data/common/tests/test_class_paginate_all.py +508 -0
- xfintech/data/common/tests/test_class_params_all.py +891 -0
- xfintech/data/common/tests/test_class_retry_all.py +714 -0
- xfintech/data/job/__init__.py +17 -0
- xfintech/data/job/errors.py +112 -0
- xfintech/data/job/house.py +156 -0
- xfintech/data/job/job.py +247 -0
- xfintech/data/job/joblike.py +47 -0
- xfintech/data/job/tests/__init__.py +1 -0
- xfintech/data/job/tests/test_class_errors_all.py +275 -0
- xfintech/data/job/tests/test_class_house_all.py +801 -0
- xfintech/data/job/tests/test_class_job_all.py +684 -0
- xfintech/data/job/tests/test_class_joblike_all.py +482 -0
- xfintech/data/relay/__init__.py +7 -0
- xfintech/data/relay/client.py +114 -0
- xfintech/data/relay/clientlike.py +45 -0
- xfintech/data/relay/tests/test_class_relayclient_all.py +484 -0
- xfintech/data/relay/tests/test_class_relayclientlike_all.py +500 -0
- xfintech/data/source/__init__.py +7 -0
- xfintech/data/source/baostock/__init__.py +21 -0
- xfintech/data/source/baostock/job/__init__.py +5 -0
- xfintech/data/source/baostock/job/job.py +217 -0
- xfintech/data/source/baostock/job/tests/__init__.py +0 -0
- xfintech/data/source/baostock/job/tests/test_class_baostockjob_all.py +547 -0
- xfintech/data/source/baostock/session/__init__.py +8 -0
- xfintech/data/source/baostock/session/relay.py +223 -0
- xfintech/data/source/baostock/session/session.py +241 -0
- xfintech/data/source/baostock/session/tests/__init__.py +0 -0
- xfintech/data/source/baostock/session/tests/test_class_relay_all.py +694 -0
- xfintech/data/source/baostock/session/tests/test_class_session_all.py +505 -0
- xfintech/data/source/baostock/stock/__init__.py +0 -0
- xfintech/data/source/baostock/stock/hs300stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/hs300stock/constant.py +49 -0
- xfintech/data/source/baostock/stock/hs300stock/hs300stock.py +133 -0
- xfintech/data/source/baostock/stock/hs300stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/hs300stock/tests/test_class_hs300index_all.py +413 -0
- xfintech/data/source/baostock/stock/minuteline/__init__.py +19 -0
- xfintech/data/source/baostock/stock/minuteline/constant.py +89 -0
- xfintech/data/source/baostock/stock/minuteline/minuteline.py +163 -0
- xfintech/data/source/baostock/stock/minuteline/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/minuteline/tests/test_class_minuteline_all.py +582 -0
- xfintech/data/source/baostock/stock/stock/__init__.py +19 -0
- xfintech/data/source/baostock/stock/stock/constant.py +55 -0
- xfintech/data/source/baostock/stock/stock/stock.py +149 -0
- xfintech/data/source/baostock/stock/stock/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/stock/tests/test_class_stock_all.py +508 -0
- xfintech/data/source/baostock/stock/stockinfo/__init__.py +5 -0
- xfintech/data/source/baostock/stock/stockinfo/constant.py +66 -0
- xfintech/data/source/baostock/stock/stockinfo/stockinfo.py +176 -0
- xfintech/data/source/baostock/stock/stockinfo/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/stockinfo/tests/test_class_stockinfo_all.py +617 -0
- xfintech/data/source/baostock/stock/sz50stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/sz50stock/constant.py +49 -0
- xfintech/data/source/baostock/stock/sz50stock/sz50stock.py +133 -0
- xfintech/data/source/baostock/stock/sz50stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/sz50stock/tests/test_class_sz50stock_all.py +397 -0
- xfintech/data/source/baostock/stock/tradedate/__init__.py +19 -0
- xfintech/data/source/baostock/stock/tradedate/constant.py +72 -0
- xfintech/data/source/baostock/stock/tradedate/tests/__init__.py +0 -0
- xfintech/data/source/baostock/stock/tradedate/tests/test_class_tradedate_all.py +695 -0
- xfintech/data/source/baostock/stock/tradedate/tradedate.py +208 -0
- xfintech/data/source/baostock/stock/zz500stock/__init__.py +3 -0
- xfintech/data/source/baostock/stock/zz500stock/constant.py +55 -0
- xfintech/data/source/baostock/stock/zz500stock/tests/__init__.py +1 -0
- xfintech/data/source/baostock/stock/zz500stock/tests/test_class_zz500stock_all.py +421 -0
- xfintech/data/source/baostock/stock/zz500stock/zz500stock.py +133 -0
- xfintech/data/source/tushare/__init__.py +61 -0
- xfintech/data/source/tushare/job/__init__.py +5 -0
- xfintech/data/source/tushare/job/job.py +257 -0
- xfintech/data/source/tushare/job/tests/test_class_tusharejob_all.py +589 -0
- xfintech/data/source/tushare/session/__init__.py +5 -0
- xfintech/data/source/tushare/session/relay.py +231 -0
- xfintech/data/source/tushare/session/session.py +239 -0
- xfintech/data/source/tushare/session/tests/test_class_relay_all.py +719 -0
- xfintech/data/source/tushare/session/tests/test_class_session_all.py +705 -0
- xfintech/data/source/tushare/stock/__init__.py +55 -0
- xfintech/data/source/tushare/stock/adjfactor/__init__.py +19 -0
- xfintech/data/source/tushare/stock/adjfactor/adjfactor.py +150 -0
- xfintech/data/source/tushare/stock/adjfactor/constant.py +71 -0
- xfintech/data/source/tushare/stock/adjfactor/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/adjfactor/tests/test_class_adjfactor_all.py +372 -0
- xfintech/data/source/tushare/stock/capflow/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflow/capflow.py +171 -0
- xfintech/data/source/tushare/stock/capflow/constant.py +105 -0
- xfintech/data/source/tushare/stock/capflow/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflow/tests/test_class_capflow_all.py +589 -0
- xfintech/data/source/tushare/stock/capflowdc/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflowdc/capflowdc.py +167 -0
- xfintech/data/source/tushare/stock/capflowdc/constant.py +95 -0
- xfintech/data/source/tushare/stock/capflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflowdc/tests/test_class_capflowdc_all.py +814 -0
- xfintech/data/source/tushare/stock/capflowths/__init__.py +19 -0
- xfintech/data/source/tushare/stock/capflowths/capflowths.py +173 -0
- xfintech/data/source/tushare/stock/capflowths/constant.py +92 -0
- xfintech/data/source/tushare/stock/capflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/capflowths/tests/test_class_capflowths_all.py +551 -0
- xfintech/data/source/tushare/stock/company/__init__.py +19 -0
- xfintech/data/source/tushare/stock/company/company.py +188 -0
- xfintech/data/source/tushare/stock/company/constant.py +92 -0
- xfintech/data/source/tushare/stock/company/tests/__init__.py +1 -0
- xfintech/data/source/tushare/stock/company/tests/test_class_company_all.py +829 -0
- xfintech/data/source/tushare/stock/companybusiness/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companybusiness/companybusiness.py +183 -0
- xfintech/data/source/tushare/stock/companybusiness/constant.py +91 -0
- xfintech/data/source/tushare/stock/companybusiness/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companybusiness/tests/test_class_companybusiness_all.py +633 -0
- xfintech/data/source/tushare/stock/companycashflow/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companycashflow/companycashflow.py +277 -0
- xfintech/data/source/tushare/stock/companycashflow/constant.py +293 -0
- xfintech/data/source/tushare/stock/companycashflow/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companycashflow/tests/test_class_companycashflow_all.py +619 -0
- xfintech/data/source/tushare/stock/companydebt/__init__.py +19 -0
- xfintech/data/source/tushare/stock/companydebt/companydebt.py +339 -0
- xfintech/data/source/tushare/stock/companydebt/constant.py +403 -0
- xfintech/data/source/tushare/stock/companydebt/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companydebt/tests/test_class_companydebt_all.py +655 -0
- xfintech/data/source/tushare/stock/companyoverview/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companyoverview/companyoverview.py +214 -0
- xfintech/data/source/tushare/stock/companyoverview/constant.py +152 -0
- xfintech/data/source/tushare/stock/companyoverview/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companyoverview/tests/test_class_companyoverview_all.py +647 -0
- xfintech/data/source/tushare/stock/companyprofit/__init__.py +21 -0
- xfintech/data/source/tushare/stock/companyprofit/companyprofit.py +272 -0
- xfintech/data/source/tushare/stock/companyprofit/constant.py +259 -0
- xfintech/data/source/tushare/stock/companyprofit/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/companyprofit/tests/test_class_companyprofit_all.py +635 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/__init__.py +21 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/conceptcapflowdc.py +175 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/constant.py +106 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/conceptcapflowdc/tests/test_class_conceptcapflowdc_all.py +568 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/__init__.py +21 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/conceptcapflowths.py +188 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/constant.py +89 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/conceptcapflowths/tests/test_class_conceptcapflowths_all.py +516 -0
- xfintech/data/source/tushare/stock/dayline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/dayline/constant.py +87 -0
- xfintech/data/source/tushare/stock/dayline/dayline.py +177 -0
- xfintech/data/source/tushare/stock/dayline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/dayline/tests/test_class_dayline_all.py +585 -0
- xfintech/data/source/tushare/stock/industrycapflowths/__init__.py +21 -0
- xfintech/data/source/tushare/stock/industrycapflowths/constant.py +89 -0
- xfintech/data/source/tushare/stock/industrycapflowths/industrycapflowths.py +192 -0
- xfintech/data/source/tushare/stock/industrycapflowths/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/industrycapflowths/tests/test_class_industrycapflowths_all.py +683 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/__init__.py +21 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/constant.py +90 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/marketindexcapflowdc.py +173 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/test_class_marketindexcapflowdc_all.py +793 -0
- xfintech/data/source/tushare/stock/monthline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/monthline/constant.py +87 -0
- xfintech/data/source/tushare/stock/monthline/monthline.py +180 -0
- xfintech/data/source/tushare/stock/monthline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/monthline/tests/test_class_monthline_all.py +574 -0
- xfintech/data/source/tushare/stock/stock/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stock/constant.py +105 -0
- xfintech/data/source/tushare/stock/stock/stock.py +193 -0
- xfintech/data/source/tushare/stock/stock/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stock/tests/test_class_stock_all.py +788 -0
- xfintech/data/source/tushare/stock/stockdividend/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stockdividend/constant.py +111 -0
- xfintech/data/source/tushare/stock/stockdividend/stockdividend.py +180 -0
- xfintech/data/source/tushare/stock/stockdividend/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockdividend/tests/test_class_stockdividend_all.py +725 -0
- xfintech/data/source/tushare/stock/stockinfo/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockinfo/constant.py +104 -0
- xfintech/data/source/tushare/stock/stockinfo/stockinfo.py +208 -0
- xfintech/data/source/tushare/stock/stockinfo/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockinfo/tests/test_class_stockinfo_all.py +881 -0
- xfintech/data/source/tushare/stock/stockipo/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockipo/constant.py +90 -0
- xfintech/data/source/tushare/stock/stockipo/stockipo.py +234 -0
- xfintech/data/source/tushare/stock/stockipo/tests/__init__.py +1 -0
- xfintech/data/source/tushare/stock/stockipo/tests/test_class_stockipo_all.py +750 -0
- xfintech/data/source/tushare/stock/stockpledge/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockpledge/constant.py +72 -0
- xfintech/data/source/tushare/stock/stockpledge/stockpledge.py +158 -0
- xfintech/data/source/tushare/stock/stockpledge/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockpledge/tests/test_class_stockpledge_all.py +664 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/constant.py +85 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/stockpledgedetail.py +171 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockpledgedetail/tests/test_class_stockpledgedetail_all.py +112 -0
- xfintech/data/source/tushare/stock/stockst/__init__.py +19 -0
- xfintech/data/source/tushare/stock/stockst/constant.py +80 -0
- xfintech/data/source/tushare/stock/stockst/stockst.py +189 -0
- xfintech/data/source/tushare/stock/stockst/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stockst/tests/test_class_stockst_all.py +693 -0
- xfintech/data/source/tushare/stock/stocksuspend/__init__.py +21 -0
- xfintech/data/source/tushare/stock/stocksuspend/constant.py +75 -0
- xfintech/data/source/tushare/stock/stocksuspend/stocksuspend.py +151 -0
- xfintech/data/source/tushare/stock/stocksuspend/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/stocksuspend/tests/test_class_stocksuspend_all.py +626 -0
- xfintech/data/source/tushare/stock/techindex/__init__.py +19 -0
- xfintech/data/source/tushare/stock/techindex/constant.py +600 -0
- xfintech/data/source/tushare/stock/techindex/techindex.py +314 -0
- xfintech/data/source/tushare/stock/techindex/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/techindex/tests/test_class_techindex_all.py +576 -0
- xfintech/data/source/tushare/stock/tradedate/__init__.py +19 -0
- xfintech/data/source/tushare/stock/tradedate/constant.py +93 -0
- xfintech/data/source/tushare/stock/tradedate/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/tradedate/tests/test_class_tradedate_all.py +947 -0
- xfintech/data/source/tushare/stock/tradedate/tradedate.py +234 -0
- xfintech/data/source/tushare/stock/weekline/__init__.py +19 -0
- xfintech/data/source/tushare/stock/weekline/constant.py +87 -0
- xfintech/data/source/tushare/stock/weekline/tests/__init__.py +0 -0
- xfintech/data/source/tushare/stock/weekline/tests/test_class_weekline_all.py +575 -0
- xfintech/data/source/tushare/stock/weekline/weekline.py +182 -0
- xfintech/fabric/__init__.py +18 -0
- xfintech/fabric/column/__init__.py +7 -0
- xfintech/fabric/column/info.py +202 -0
- xfintech/fabric/column/kind.py +102 -0
- xfintech/fabric/column/tests/__init__.py +0 -0
- xfintech/fabric/column/tests/test_class_info_all.py +207 -0
- xfintech/fabric/column/tests/test_class_kind_all.py +80 -0
- xfintech/fabric/table/__init__.py +5 -0
- xfintech/fabric/table/info.py +263 -0
- xfintech/fabric/table/tests/__init__.py +0 -0
- xfintech/fabric/table/tests/test_class_info_all.py +547 -0
- xfintech/serde/__init__.py +35 -0
- xfintech/serde/common/__init__.py +9 -0
- xfintech/serde/common/dataformat.py +78 -0
- xfintech/serde/common/deserialiserlike.py +38 -0
- xfintech/serde/common/error.py +182 -0
- xfintech/serde/common/serialiserlike.py +38 -0
- xfintech/serde/common/tests/__init__.py +1 -0
- xfintech/serde/common/tests/test_class_dataformat_all.py +694 -0
- xfintech/serde/common/tests/test_class_deserialiserlike_all.py +500 -0
- xfintech/serde/common/tests/test_class_errors_all.py +518 -0
- xfintech/serde/common/tests/test_class_serialiserlike_all.py +401 -0
- xfintech/serde/deserialiser/__init__.py +7 -0
- xfintech/serde/deserialiser/pandas.py +113 -0
- xfintech/serde/deserialiser/python.py +68 -0
- xfintech/serde/deserialiser/tests/__init__.py +1 -0
- xfintech/serde/deserialiser/tests/test_class_pandasdeserialiser_all.py +503 -0
- xfintech/serde/deserialiser/tests/test_class_pythondeserialiser_all.py +570 -0
- xfintech/serde/serialiser/__init__.py +7 -0
- xfintech/serde/serialiser/pandas.py +116 -0
- xfintech/serde/serialiser/python.py +71 -0
- xfintech/serde/serialiser/tests/__init__.py +1 -0
- xfintech/serde/serialiser/tests/test_class_pandasserialiser_all.py +474 -0
- xfintech/serde/serialiser/tests/test_class_pythonserialiser_all.py +508 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from xfintech.data.common.cache import Cache
|
|
8
|
+
from xfintech.data.common.coolant import Coolant
|
|
9
|
+
from xfintech.data.common.params import Params
|
|
10
|
+
from xfintech.data.common.retry import Retry
|
|
11
|
+
from xfintech.data.job import JobHouse
|
|
12
|
+
from xfintech.data.source.tushare.job import TushareJob
|
|
13
|
+
from xfintech.data.source.tushare.session.session import Session
|
|
14
|
+
from xfintech.data.source.tushare.stock.companydebt.constant import (
|
|
15
|
+
KEY,
|
|
16
|
+
NAME,
|
|
17
|
+
PAGINATE,
|
|
18
|
+
SOURCE,
|
|
19
|
+
TARGET,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@JobHouse.register(KEY, alias=KEY)
|
|
24
|
+
class CompanyDebt(TushareJob):
|
|
25
|
+
"""
|
|
26
|
+
描述:
|
|
27
|
+
- 获取A股上市公司资产负债表数据
|
|
28
|
+
- API文档: https://tushare.pro/document/2?doc_id=36
|
|
29
|
+
- SCALE: CrossSection & Individual
|
|
30
|
+
- TYPE: Partitioned
|
|
31
|
+
- PAGINATE: 1000 rows / 1000 pages
|
|
32
|
+
|
|
33
|
+
属性:
|
|
34
|
+
- name: str, 作业名称 'companydebt'。
|
|
35
|
+
- key: str, 作业键 '/tushare/companydebt'。
|
|
36
|
+
- session: Session, Tushare会话对象。
|
|
37
|
+
- source: TableInfo, 源表信息(Tushare原始格式)。
|
|
38
|
+
- target: TableInfo, 目标表信息(转换后格式)。
|
|
39
|
+
- params: Params, 查询参数。
|
|
40
|
+
- ts_code: str, 必需, 股票代码(如'000001.SZ')
|
|
41
|
+
- ann_date: str, 可选, 公告日期(YYYYMMDD)
|
|
42
|
+
- start_date: str, 可选, 公告开始日期(YYYYMMDD)
|
|
43
|
+
- end_date: str, 可选, 公告结束日期(YYYYMMDD)
|
|
44
|
+
- period: str, 可选, 报告期(YYYYMMDD,如2017-01表示第一季度)
|
|
45
|
+
- year: str, 可选, 报告年度(YYYY)
|
|
46
|
+
- report_type: str, 可选, 报告类型(见文档说明)
|
|
47
|
+
- comp_type: str, 可选, 公司类型(1一般工商业 2银行 3保险 4证券)
|
|
48
|
+
- coolant: Coolant, 请求冷却控制。
|
|
49
|
+
- paginate: Paginate, 分页控制(pagesize=1000, pagelimit=100)。
|
|
50
|
+
- retry: Retry, 重试策略。
|
|
51
|
+
- cache: Cache, 缓存管理。
|
|
52
|
+
|
|
53
|
+
方法:
|
|
54
|
+
- run(): 执行作业,返回资产负债表DataFrame。
|
|
55
|
+
- _run(): 内部执行逻辑,处理参数并调用API。
|
|
56
|
+
- transform(data): 转换数据格式,将源格式转为目标格式。
|
|
57
|
+
|
|
58
|
+
例子:
|
|
59
|
+
```python
|
|
60
|
+
from xfintech.data.source.tushare.session import Session
|
|
61
|
+
from xfintech.data.source.tushare.stock.companydebt import CompanyDebt
|
|
62
|
+
|
|
63
|
+
session = Session(credential="your_token")
|
|
64
|
+
debt = CompanyDebt(
|
|
65
|
+
session=session,
|
|
66
|
+
params={
|
|
67
|
+
"ts_code": "000001.SZ",
|
|
68
|
+
"start_date": "20200101",
|
|
69
|
+
"end_date": "20201231",
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
df = debt.run()
|
|
73
|
+
```
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
def __init__(
|
|
77
|
+
self,
|
|
78
|
+
session: Session,
|
|
79
|
+
params: Optional[Params | Dict[str, Any]] = None,
|
|
80
|
+
coolant: Optional[Coolant | Dict[str, Any]] = None,
|
|
81
|
+
retry: Optional[Retry | Dict[str, Any]] = None,
|
|
82
|
+
cache: Optional[Cache | Dict[str, str] | bool] = None,
|
|
83
|
+
) -> None:
|
|
84
|
+
super().__init__(
|
|
85
|
+
name=NAME,
|
|
86
|
+
key=KEY,
|
|
87
|
+
session=session,
|
|
88
|
+
source=SOURCE,
|
|
89
|
+
target=TARGET,
|
|
90
|
+
params=params,
|
|
91
|
+
coolant=coolant,
|
|
92
|
+
paginate=PAGINATE,
|
|
93
|
+
retry=retry,
|
|
94
|
+
cache=cache,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def _run(self) -> pd.DataFrame:
|
|
98
|
+
cached = self._load_cache()
|
|
99
|
+
if cached is not None:
|
|
100
|
+
return cached
|
|
101
|
+
|
|
102
|
+
# Prepare payload dict
|
|
103
|
+
payload = self.params.to_dict()
|
|
104
|
+
payload = self._parse_date_params(
|
|
105
|
+
payload,
|
|
106
|
+
keys=["ann_date", "start_date", "end_date"],
|
|
107
|
+
)
|
|
108
|
+
payload = self._parse_string_params(
|
|
109
|
+
payload,
|
|
110
|
+
keys=["ts_code", "report_type", "comp_type"],
|
|
111
|
+
)
|
|
112
|
+
payload = self._parse_year_params(
|
|
113
|
+
payload,
|
|
114
|
+
key="year",
|
|
115
|
+
)
|
|
116
|
+
payload = self._parse_period_params(
|
|
117
|
+
payload,
|
|
118
|
+
key="period",
|
|
119
|
+
)
|
|
120
|
+
fields = SOURCE.list_column_names()
|
|
121
|
+
payload["fields"] = ",".join(fields)
|
|
122
|
+
|
|
123
|
+
# Fetch and transform data
|
|
124
|
+
data = self._fetchall(
|
|
125
|
+
api=self.connection.balancesheet_vip,
|
|
126
|
+
**payload,
|
|
127
|
+
)
|
|
128
|
+
result = self.transform(data)
|
|
129
|
+
self._save_cache(result)
|
|
130
|
+
return result
|
|
131
|
+
|
|
132
|
+
# Transform logic
|
|
133
|
+
def transform(
|
|
134
|
+
self,
|
|
135
|
+
data: pd.DataFrame,
|
|
136
|
+
) -> pd.DataFrame:
|
|
137
|
+
cols = self.target.list_column_names()
|
|
138
|
+
if data is None or data.empty:
|
|
139
|
+
return pd.DataFrame(columns=cols)
|
|
140
|
+
|
|
141
|
+
transformed = {}
|
|
142
|
+
transformed["code"] = data["ts_code"].astype(str)
|
|
143
|
+
transformed["datecode"] = data["end_date"].astype(str)
|
|
144
|
+
transformed["date"] = pd.to_datetime(
|
|
145
|
+
data["end_date"],
|
|
146
|
+
format="%Y%m%d",
|
|
147
|
+
errors="coerce",
|
|
148
|
+
).dt.strftime("%Y-%m-%d")
|
|
149
|
+
|
|
150
|
+
# Convert other date fields
|
|
151
|
+
for col in [
|
|
152
|
+
"ann_date",
|
|
153
|
+
"f_ann_date",
|
|
154
|
+
"end_date",
|
|
155
|
+
]:
|
|
156
|
+
transformed[col] = pd.to_datetime(
|
|
157
|
+
data[col],
|
|
158
|
+
format="%Y%m%d",
|
|
159
|
+
errors="coerce",
|
|
160
|
+
).dt.strftime("%Y-%m-%d")
|
|
161
|
+
|
|
162
|
+
# Convert string fields
|
|
163
|
+
for col in [
|
|
164
|
+
"comp_type",
|
|
165
|
+
"report_type",
|
|
166
|
+
"end_type",
|
|
167
|
+
"update_flag",
|
|
168
|
+
]:
|
|
169
|
+
transformed[col] = data[col].astype(str)
|
|
170
|
+
|
|
171
|
+
# Convert numeric fields
|
|
172
|
+
numeric_fields = [
|
|
173
|
+
"total_share",
|
|
174
|
+
"cap_rese",
|
|
175
|
+
"undistr_porfit",
|
|
176
|
+
"surplus_rese",
|
|
177
|
+
"special_rese",
|
|
178
|
+
"money_cap",
|
|
179
|
+
"trad_asset",
|
|
180
|
+
"notes_receiv",
|
|
181
|
+
"accounts_receiv",
|
|
182
|
+
"oth_receiv",
|
|
183
|
+
"prepayment",
|
|
184
|
+
"div_receiv",
|
|
185
|
+
"int_receiv",
|
|
186
|
+
"inventories",
|
|
187
|
+
"amor_exp",
|
|
188
|
+
"nca_within_1y",
|
|
189
|
+
"sett_rsrv",
|
|
190
|
+
"loanto_oth_bank_fi",
|
|
191
|
+
"premium_receiv",
|
|
192
|
+
"reinsur_receiv",
|
|
193
|
+
"reinsur_res_receiv",
|
|
194
|
+
"pur_resale_fa",
|
|
195
|
+
"oth_cur_assets",
|
|
196
|
+
"total_cur_assets",
|
|
197
|
+
"fa_avail_for_sale",
|
|
198
|
+
"htm_invest",
|
|
199
|
+
"lt_eqt_invest",
|
|
200
|
+
"invest_real_estate",
|
|
201
|
+
"time_deposits",
|
|
202
|
+
"oth_assets",
|
|
203
|
+
"lt_rec",
|
|
204
|
+
"fix_assets",
|
|
205
|
+
"cip",
|
|
206
|
+
"const_materials",
|
|
207
|
+
"fixed_assets_disp",
|
|
208
|
+
"produc_bio_assets",
|
|
209
|
+
"oil_and_gas_assets",
|
|
210
|
+
"intan_assets",
|
|
211
|
+
"r_and_d",
|
|
212
|
+
"goodwill",
|
|
213
|
+
"lt_amor_exp",
|
|
214
|
+
"defer_tax_assets",
|
|
215
|
+
"decr_in_disbur",
|
|
216
|
+
"oth_nca",
|
|
217
|
+
"total_nca",
|
|
218
|
+
"cash_reser_cb",
|
|
219
|
+
"depos_in_oth_bfi",
|
|
220
|
+
"prec_metals",
|
|
221
|
+
"deriv_assets",
|
|
222
|
+
"rr_reins_une_prem",
|
|
223
|
+
"rr_reins_outstd_cla",
|
|
224
|
+
"rr_reins_lins_liab",
|
|
225
|
+
"rr_reins_lthins_liab",
|
|
226
|
+
"refund_depos",
|
|
227
|
+
"ph_pledge_loans",
|
|
228
|
+
"refund_cap_depos",
|
|
229
|
+
"indep_acct_assets",
|
|
230
|
+
"client_depos",
|
|
231
|
+
"client_prov",
|
|
232
|
+
"transac_seat_fee",
|
|
233
|
+
"invest_as_receiv",
|
|
234
|
+
"total_assets",
|
|
235
|
+
"lt_borr",
|
|
236
|
+
"st_borr",
|
|
237
|
+
"cb_borr",
|
|
238
|
+
"depos_ib_deposits",
|
|
239
|
+
"loan_oth_bank",
|
|
240
|
+
"trading_fl",
|
|
241
|
+
"notes_payable",
|
|
242
|
+
"acct_payable",
|
|
243
|
+
"adv_receipts",
|
|
244
|
+
"sold_for_repur_fa",
|
|
245
|
+
"comm_payable",
|
|
246
|
+
"payroll_payable",
|
|
247
|
+
"taxes_payable",
|
|
248
|
+
"int_payable",
|
|
249
|
+
"div_payable",
|
|
250
|
+
"oth_payable",
|
|
251
|
+
"acc_exp",
|
|
252
|
+
"deferred_inc",
|
|
253
|
+
"st_bonds_payable",
|
|
254
|
+
"payable_to_reinsurer",
|
|
255
|
+
"rsrv_insur_cont",
|
|
256
|
+
"acting_trading_sec",
|
|
257
|
+
"acting_uw_sec",
|
|
258
|
+
"non_cur_liab_due_1y",
|
|
259
|
+
"oth_cur_liab",
|
|
260
|
+
"total_cur_liab",
|
|
261
|
+
"bond_payable",
|
|
262
|
+
"lt_payable",
|
|
263
|
+
"specific_payables",
|
|
264
|
+
"estimated_liab",
|
|
265
|
+
"defer_tax_liab",
|
|
266
|
+
"defer_inc_non_cur_liab",
|
|
267
|
+
"oth_ncl",
|
|
268
|
+
"total_ncl",
|
|
269
|
+
"depos_oth_bfi",
|
|
270
|
+
"deriv_liab",
|
|
271
|
+
"depos",
|
|
272
|
+
"agency_bus_liab",
|
|
273
|
+
"oth_liab",
|
|
274
|
+
"prem_receiv_adva",
|
|
275
|
+
"depos_received",
|
|
276
|
+
"ph_invest",
|
|
277
|
+
"reser_une_prem",
|
|
278
|
+
"reser_outstd_claims",
|
|
279
|
+
"reser_lins_liab",
|
|
280
|
+
"reser_lthins_liab",
|
|
281
|
+
"indept_acc_liab",
|
|
282
|
+
"pledge_borr",
|
|
283
|
+
"indem_payable",
|
|
284
|
+
"policy_div_payable",
|
|
285
|
+
"total_liab",
|
|
286
|
+
"treasury_share",
|
|
287
|
+
"ordin_risk_reser",
|
|
288
|
+
"forex_differ",
|
|
289
|
+
"invest_loss_unconf",
|
|
290
|
+
"minority_int",
|
|
291
|
+
"total_hldr_eqy_exc_min_int",
|
|
292
|
+
"total_hldr_eqy_inc_min_int",
|
|
293
|
+
"total_liab_hldr_eqy",
|
|
294
|
+
"lt_payroll_payable",
|
|
295
|
+
"oth_comp_income",
|
|
296
|
+
"oth_eqt_tools",
|
|
297
|
+
"oth_eqt_tools_p_shr",
|
|
298
|
+
"lending_funds",
|
|
299
|
+
"acc_receivable",
|
|
300
|
+
"st_fin_payable",
|
|
301
|
+
"payables",
|
|
302
|
+
"hfs_assets",
|
|
303
|
+
"hfs_sales",
|
|
304
|
+
"cost_fin_assets",
|
|
305
|
+
"fair_value_fin_assets",
|
|
306
|
+
"cip_total",
|
|
307
|
+
"oth_pay_total",
|
|
308
|
+
"long_pay_total",
|
|
309
|
+
"debt_invest",
|
|
310
|
+
"oth_debt_invest",
|
|
311
|
+
"oth_eq_invest",
|
|
312
|
+
"oth_illiq_fin_assets",
|
|
313
|
+
"oth_eq_ppbond",
|
|
314
|
+
"receiv_financing",
|
|
315
|
+
"use_right_assets",
|
|
316
|
+
"lease_liab",
|
|
317
|
+
"contract_assets",
|
|
318
|
+
"contract_liab",
|
|
319
|
+
"accounts_receiv_bill",
|
|
320
|
+
"accounts_pay",
|
|
321
|
+
"oth_rcv_total",
|
|
322
|
+
"fix_assets_total",
|
|
323
|
+
]
|
|
324
|
+
for col in numeric_fields:
|
|
325
|
+
if col in data.columns:
|
|
326
|
+
transformed[col] = pd.to_numeric(data[col], errors="coerce")
|
|
327
|
+
|
|
328
|
+
# Ensure all target columns exist (add missing ones with NaN)
|
|
329
|
+
for col in cols:
|
|
330
|
+
if col not in transformed:
|
|
331
|
+
transformed[col] = pd.NA
|
|
332
|
+
|
|
333
|
+
# Select target columns, drop duplicates, and sort
|
|
334
|
+
out = pd.DataFrame(transformed)
|
|
335
|
+
out = out[cols].drop_duplicates()
|
|
336
|
+
out = out.sort_values(by=["code", "date"])
|
|
337
|
+
out = out.reset_index(drop=True)
|
|
338
|
+
self.markpoint("transform[OK]")
|
|
339
|
+
return out
|