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,314 @@
|
|
|
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.techindex.constant import (
|
|
15
|
+
_IN_BFQ_COLS,
|
|
16
|
+
_IN_HFQ_COLS,
|
|
17
|
+
_IN_QFQ_COLS,
|
|
18
|
+
_OUT_BA_COLS,
|
|
19
|
+
_OUT_FA_COLS,
|
|
20
|
+
_OUT_MAIN_COLS,
|
|
21
|
+
_OUT_NA_COLS,
|
|
22
|
+
KEY,
|
|
23
|
+
NAME,
|
|
24
|
+
PAGINATE,
|
|
25
|
+
SOURCE,
|
|
26
|
+
TARGET,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@JobHouse.register(KEY, alias=KEY)
|
|
31
|
+
class TechIndex(TushareJob):
|
|
32
|
+
"""
|
|
33
|
+
描述:
|
|
34
|
+
- 获取A股股票技术面因子数据
|
|
35
|
+
- 技术面因子包括动量、波动率、成交量、趋势等多个维度
|
|
36
|
+
- 因子数据由Tushare自行生产
|
|
37
|
+
- 5000积分每分钟可以请求30次,
|
|
38
|
+
- API文档: https://tushare.pro/document/2?doc_id=328
|
|
39
|
+
- SCALE: CrossSection & Individual
|
|
40
|
+
- TYPE: Partitioned
|
|
41
|
+
- PAGINATE: 10000 rows / 1000 pages
|
|
42
|
+
|
|
43
|
+
属性:
|
|
44
|
+
- name: str, 作业名称 'techindex'。
|
|
45
|
+
- key: str, 作业键 '/tushare/techindex'。
|
|
46
|
+
- session: Session, Tushare会话对象。
|
|
47
|
+
- source: TableInfo, 源表信息(Tushare原始格式)。
|
|
48
|
+
- target: TableInfo, 目标表信息(转换后格式)。
|
|
49
|
+
- params: Params, 查询参数。
|
|
50
|
+
- ts_code: str, 可选, 股票代码
|
|
51
|
+
- trade_date: str, 可选, 特定交易日期(YYYYMMDD)
|
|
52
|
+
- start_date: str, 可选, 开始日期(YYYYMMDD)
|
|
53
|
+
- end_date: str, 可选, 结束日期(YYYYMMDD)
|
|
54
|
+
- coolant: Coolant, 请求冷却控制。
|
|
55
|
+
- paginate: Paginate, 分页控制(pagesize=10000, pagelimit=1000)。
|
|
56
|
+
- retry: Retry, 重试策略。
|
|
57
|
+
- cache: Cache, 缓存管理。
|
|
58
|
+
|
|
59
|
+
方法:
|
|
60
|
+
- run(): 执行作业,返回技术面因子DataFrame。
|
|
61
|
+
- _run(): 内部执行逻辑,处理日期参数。
|
|
62
|
+
- transform(data): 转换数据格式,将源格式转为目标格式。
|
|
63
|
+
- na_transform(data): 转换N/A因子数据格式。
|
|
64
|
+
- ba_transform(data): 转换前复权因子数据格式。
|
|
65
|
+
- fa_transform(data): 转换后复权因子数据格式。
|
|
66
|
+
- slice_main(data): 切片主因子数据。
|
|
67
|
+
- slice_na(data): 切片N/A因子数据。
|
|
68
|
+
- slice_ba(data): 切片前复权因子数据。
|
|
69
|
+
- slice_fa(data): 切片后复权因子数据。
|
|
70
|
+
|
|
71
|
+
例子:
|
|
72
|
+
```python
|
|
73
|
+
from xfintech.data.source.tushare.session import Session
|
|
74
|
+
from xfintech.data.source.tushare.stock.techindex import TechIndex
|
|
75
|
+
|
|
76
|
+
# 创建会话
|
|
77
|
+
session = Session(credential="your_token")
|
|
78
|
+
|
|
79
|
+
# 获取单只股票全部技术面因子
|
|
80
|
+
job = TechIndex(
|
|
81
|
+
session=session,
|
|
82
|
+
params={"ts_code": "000001.SZ"}
|
|
83
|
+
)
|
|
84
|
+
df = job.run()
|
|
85
|
+
print(f"共 {len(df)} 条技术面因子数据")
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
def __init__(
|
|
91
|
+
self,
|
|
92
|
+
session: Session,
|
|
93
|
+
params: Optional[Params | Dict[str, Any]] = None,
|
|
94
|
+
coolant: Optional[Coolant | Dict[str, Any]] = None,
|
|
95
|
+
retry: Optional[Retry | Dict[str, Any]] = None,
|
|
96
|
+
cache: Optional[Cache | Dict[str, str] | bool] = None,
|
|
97
|
+
) -> None:
|
|
98
|
+
super().__init__(
|
|
99
|
+
name=NAME,
|
|
100
|
+
key=KEY,
|
|
101
|
+
session=session,
|
|
102
|
+
source=SOURCE,
|
|
103
|
+
target=TARGET,
|
|
104
|
+
params=params,
|
|
105
|
+
coolant=coolant,
|
|
106
|
+
paginate=PAGINATE,
|
|
107
|
+
retry=retry,
|
|
108
|
+
cache=cache,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def _run(self) -> pd.DataFrame:
|
|
112
|
+
cached = self._load_cache()
|
|
113
|
+
if cached is not None:
|
|
114
|
+
return cached
|
|
115
|
+
|
|
116
|
+
# Prepare payload dict
|
|
117
|
+
payload = self.params.to_dict()
|
|
118
|
+
payload = self._parse_date_params(
|
|
119
|
+
payload,
|
|
120
|
+
keys=["trade_date", "start_date", "end_date"],
|
|
121
|
+
)
|
|
122
|
+
payload = self._parse_string_params(
|
|
123
|
+
payload,
|
|
124
|
+
keys=["ts_code"],
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Fetch data from API
|
|
128
|
+
data = self._fetchall(
|
|
129
|
+
api=self.connection.stk_factor_pro,
|
|
130
|
+
**payload,
|
|
131
|
+
)
|
|
132
|
+
result = self.transform(data)
|
|
133
|
+
self._save_cache(result)
|
|
134
|
+
return result
|
|
135
|
+
|
|
136
|
+
def _transform_main(
|
|
137
|
+
self,
|
|
138
|
+
data: pd.DataFrame,
|
|
139
|
+
) -> pd.DataFrame:
|
|
140
|
+
cols = [item.name for item in _OUT_MAIN_COLS]
|
|
141
|
+
if data is None or data.empty:
|
|
142
|
+
return pd.DataFrame(columns=cols)
|
|
143
|
+
|
|
144
|
+
# Create a copy and transform
|
|
145
|
+
transformed = {}
|
|
146
|
+
transformed["code"] = data["ts_code"].astype(str)
|
|
147
|
+
transformed["date"] = pd.to_datetime(
|
|
148
|
+
data["trade_date"],
|
|
149
|
+
format="%Y%m%d",
|
|
150
|
+
errors="coerce",
|
|
151
|
+
).dt.strftime("%Y-%m-%d")
|
|
152
|
+
transformed["datecode"] = data["trade_date"].astype(str)
|
|
153
|
+
transformed["change"] = pd.to_numeric(data["change"], errors="coerce")
|
|
154
|
+
transformed["percent_change"] = pd.to_numeric(data["pct_chg"], errors="coerce")
|
|
155
|
+
transformed["volume"] = pd.to_numeric(data["vol"], errors="coerce")
|
|
156
|
+
transformed["amount"] = pd.to_numeric(data["amount"], errors="coerce")
|
|
157
|
+
transformed["turnover_rate"] = pd.to_numeric(data["turnover_rate"], errors="coerce")
|
|
158
|
+
transformed["turnover_rate_f"] = pd.to_numeric(data["turnover_rate_f"], errors="coerce")
|
|
159
|
+
transformed["volume_ratio"] = pd.to_numeric(data["volume_ratio"], errors="coerce")
|
|
160
|
+
transformed["pe"] = pd.to_numeric(data["pe"], errors="coerce")
|
|
161
|
+
transformed["pe_ttm"] = pd.to_numeric(data["pe_ttm"], errors="coerce")
|
|
162
|
+
transformed["pb"] = pd.to_numeric(data["pb"], errors="coerce")
|
|
163
|
+
transformed["ps"] = pd.to_numeric(data["ps"], errors="coerce")
|
|
164
|
+
transformed["ps_ttm"] = pd.to_numeric(data["ps_ttm"], errors="coerce")
|
|
165
|
+
transformed["dv_ratio"] = pd.to_numeric(data["dv_ratio"], errors="coerce")
|
|
166
|
+
transformed["dv_ttm"] = pd.to_numeric(data["dv_ttm"], errors="coerce")
|
|
167
|
+
transformed["total_share"] = pd.to_numeric(data["total_share"], errors="coerce")
|
|
168
|
+
transformed["float_share"] = pd.to_numeric(data["float_share"], errors="coerce")
|
|
169
|
+
transformed["free_share"] = pd.to_numeric(data["free_share"], errors="coerce")
|
|
170
|
+
transformed["total_mv"] = pd.to_numeric(data["total_mv"], errors="coerce")
|
|
171
|
+
transformed["circle_mv"] = pd.to_numeric(data["circ_mv"], errors="coerce")
|
|
172
|
+
transformed["adj_factor"] = pd.to_numeric(data["adj_factor"], errors="coerce")
|
|
173
|
+
transformed["downdays"] = pd.to_numeric(data["downdays"], errors="coerce")
|
|
174
|
+
transformed["updays"] = pd.to_numeric(data["updays"], errors="coerce")
|
|
175
|
+
transformed["lowdays"] = pd.to_numeric(data["lowdays"], errors="coerce")
|
|
176
|
+
transformed["topdays"] = pd.to_numeric(data["topdays"], errors="coerce")
|
|
177
|
+
return pd.DataFrame(transformed)
|
|
178
|
+
|
|
179
|
+
def _transform_na(
|
|
180
|
+
self,
|
|
181
|
+
data: pd.DataFrame,
|
|
182
|
+
) -> pd.DataFrame:
|
|
183
|
+
cols = [item.name for item in _OUT_NA_COLS]
|
|
184
|
+
if data is None or data.empty:
|
|
185
|
+
return pd.DataFrame(columns=cols)
|
|
186
|
+
|
|
187
|
+
# Create a copy and transform
|
|
188
|
+
transformed = {}
|
|
189
|
+
for col in _IN_BFQ_COLS:
|
|
190
|
+
src = col.name
|
|
191
|
+
dst = src.replace("_bfq", "")
|
|
192
|
+
if src in data.columns:
|
|
193
|
+
transformed[dst] = pd.to_numeric(
|
|
194
|
+
data[src],
|
|
195
|
+
errors="coerce",
|
|
196
|
+
)
|
|
197
|
+
else:
|
|
198
|
+
transformed[dst] = pd.NA
|
|
199
|
+
return pd.DataFrame(transformed)
|
|
200
|
+
|
|
201
|
+
def _transform_ba(
|
|
202
|
+
self,
|
|
203
|
+
data: pd.DataFrame,
|
|
204
|
+
) -> pd.DataFrame:
|
|
205
|
+
cols = [item.name for item in _OUT_BA_COLS]
|
|
206
|
+
if data is None or data.empty:
|
|
207
|
+
return pd.DataFrame(columns=cols)
|
|
208
|
+
|
|
209
|
+
# Create a copy and transform
|
|
210
|
+
transformed = {}
|
|
211
|
+
for col in _IN_HFQ_COLS:
|
|
212
|
+
src = col.name
|
|
213
|
+
dst = "ba_" + src.replace("_hfq", "")
|
|
214
|
+
if src in data.columns:
|
|
215
|
+
transformed[dst] = pd.to_numeric(
|
|
216
|
+
data[src],
|
|
217
|
+
errors="coerce",
|
|
218
|
+
)
|
|
219
|
+
else:
|
|
220
|
+
transformed[dst] = pd.NA
|
|
221
|
+
return pd.DataFrame(transformed)
|
|
222
|
+
|
|
223
|
+
def _transform_fa(
|
|
224
|
+
self,
|
|
225
|
+
data: pd.DataFrame,
|
|
226
|
+
) -> pd.DataFrame:
|
|
227
|
+
cols = [item.name for item in _OUT_FA_COLS]
|
|
228
|
+
if data is None or data.empty:
|
|
229
|
+
return pd.DataFrame(columns=cols)
|
|
230
|
+
|
|
231
|
+
# Create a copy and transform
|
|
232
|
+
transformed = {}
|
|
233
|
+
for col in _IN_QFQ_COLS:
|
|
234
|
+
src = col.name
|
|
235
|
+
dst = "fa_" + src.replace("_qfq", "")
|
|
236
|
+
if src in data.columns:
|
|
237
|
+
transformed[dst] = pd.to_numeric(
|
|
238
|
+
data[src],
|
|
239
|
+
errors="coerce",
|
|
240
|
+
)
|
|
241
|
+
else:
|
|
242
|
+
transformed[dst] = pd.NA
|
|
243
|
+
return pd.DataFrame(transformed)
|
|
244
|
+
|
|
245
|
+
def transform(
|
|
246
|
+
self,
|
|
247
|
+
data: pd.DataFrame,
|
|
248
|
+
) -> pd.DataFrame:
|
|
249
|
+
cols = self.target.list_column_names()
|
|
250
|
+
if data is None or data.empty:
|
|
251
|
+
return pd.DataFrame(columns=cols)
|
|
252
|
+
|
|
253
|
+
main_df = self._transform_main(data)
|
|
254
|
+
na_df = self._transform_na(data)
|
|
255
|
+
ba_df = self._transform_ba(data)
|
|
256
|
+
fa_df = self._transform_fa(data)
|
|
257
|
+
result = pd.concat([main_df, na_df, ba_df, fa_df], axis=1)
|
|
258
|
+
return result[cols].reset_index(drop=True)
|
|
259
|
+
|
|
260
|
+
def slice_main(
|
|
261
|
+
self,
|
|
262
|
+
data: pd.DataFrame | None = None,
|
|
263
|
+
) -> pd.DataFrame:
|
|
264
|
+
if data is not None:
|
|
265
|
+
df = data
|
|
266
|
+
else:
|
|
267
|
+
df = self.run()
|
|
268
|
+
maincols = [item.name for item in _OUT_MAIN_COLS]
|
|
269
|
+
if df.empty:
|
|
270
|
+
return pd.DataFrame(columns=maincols)
|
|
271
|
+
else:
|
|
272
|
+
return df[maincols].copy().reset_index(drop=True)
|
|
273
|
+
|
|
274
|
+
def slice_na(
|
|
275
|
+
self,
|
|
276
|
+
data: pd.DataFrame | None = None,
|
|
277
|
+
) -> pd.DataFrame:
|
|
278
|
+
if data is not None:
|
|
279
|
+
df = data
|
|
280
|
+
else:
|
|
281
|
+
df = self.run()
|
|
282
|
+
nacols = [item.name for item in _OUT_MAIN_COLS + _OUT_NA_COLS]
|
|
283
|
+
if df.empty:
|
|
284
|
+
return pd.DataFrame(columns=nacols)
|
|
285
|
+
else:
|
|
286
|
+
return df[nacols].copy().reset_index(drop=True)
|
|
287
|
+
|
|
288
|
+
def slice_ba(
|
|
289
|
+
self,
|
|
290
|
+
data: pd.DataFrame | None = None,
|
|
291
|
+
) -> pd.DataFrame:
|
|
292
|
+
if data is not None:
|
|
293
|
+
df = data
|
|
294
|
+
else:
|
|
295
|
+
df = self.run()
|
|
296
|
+
bacols = [item.name for item in _OUT_MAIN_COLS + _OUT_BA_COLS]
|
|
297
|
+
if df.empty:
|
|
298
|
+
return pd.DataFrame(columns=bacols)
|
|
299
|
+
else:
|
|
300
|
+
return df[bacols].copy().reset_index(drop=True)
|
|
301
|
+
|
|
302
|
+
def slice_fa(
|
|
303
|
+
self,
|
|
304
|
+
data: pd.DataFrame | None = None,
|
|
305
|
+
) -> pd.DataFrame:
|
|
306
|
+
if data is not None:
|
|
307
|
+
df = data
|
|
308
|
+
else:
|
|
309
|
+
df = self.run()
|
|
310
|
+
facols = [item.name for item in _OUT_MAIN_COLS + _OUT_FA_COLS]
|
|
311
|
+
if df.empty:
|
|
312
|
+
return pd.DataFrame(columns=facols)
|
|
313
|
+
else:
|
|
314
|
+
return df[facols].copy().reset_index(drop=True)
|
|
File without changes
|