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,633 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lib-x17-fintech
|
|
3
|
+
Version: 2.1.3
|
|
4
|
+
Summary: fintech module for x17 echosystem
|
|
5
|
+
Author-email: Xing Xing <x.xing.work@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pyarrow>=21.0.0
|
|
11
|
+
Requires-Dist: pytz>=2025.0
|
|
12
|
+
Requires-Dist: backoff>=2.0
|
|
13
|
+
Requires-Dist: tushare>=1.4.0
|
|
14
|
+
Requires-Dist: baostock>=0.8.0
|
|
15
|
+
Requires-Dist: pandas>=2.2.2
|
|
16
|
+
Requires-Dist: numpy>=1.25.2
|
|
17
|
+
Requires-Dist: boto3>=1.17.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
20
|
+
Requires-Dist: pytest-cov>=6.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-benchmark; extra == "dev"
|
|
22
|
+
Requires-Dist: ruff>=0.13; extra == "dev"
|
|
23
|
+
Requires-Dist: setuptools; extra == "dev"
|
|
24
|
+
Requires-Dist: wheel; extra == "dev"
|
|
25
|
+
Requires-Dist: twine; extra == "dev"
|
|
26
|
+
Requires-Dist: build; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# lib-x17-fintech
|
|
30
|
+
|
|
31
|
+
专业的金融数据处理库 - 提供统一的存储抽象、数据获取、模式管理和序列化能力。
|
|
32
|
+
|
|
33
|
+
[](https://www.python.org/downloads/)
|
|
34
|
+
[](LICENSE)
|
|
35
|
+
[](pytest.ini)
|
|
36
|
+
[](.coverage)
|
|
37
|
+
|
|
38
|
+
## 概述
|
|
39
|
+
|
|
40
|
+
`lib-x17-fintech` 是一个功能完整的金融数据处理库,为 X17 生态系统提供核心数据基础设施。通过模块化设计,提供从数据获取到存储的完整解决方案。
|
|
41
|
+
|
|
42
|
+
### 核心特性
|
|
43
|
+
|
|
44
|
+
- 🔌 **存储抽象** - 统一的接口支持本地文件系统和 AWS S3
|
|
45
|
+
- 📊 **数据获取** - 完整的 Job 系统,支持 Tushare、Baostock 等数据源
|
|
46
|
+
- 📐 **模式管理** - 灵活的表结构定义和验证
|
|
47
|
+
- 💾 **序列化** - 多格式支持(Parquet、CSV、JSON、Pickle)
|
|
48
|
+
- ⚡ **高性能** - 智能缓存、重试和分页机制
|
|
49
|
+
- 🛡️ **类型安全** - 完整的类型提示和协议接口
|
|
50
|
+
|
|
51
|
+
## 快速开始
|
|
52
|
+
|
|
53
|
+
### 安装
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 基础安装
|
|
57
|
+
pip install lib-x17-fintech
|
|
58
|
+
|
|
59
|
+
# 开发环境(包含测试工具)
|
|
60
|
+
pip install lib-x17-fintech[dev]
|
|
61
|
+
|
|
62
|
+
# 从源码安装
|
|
63
|
+
git clone <repository-url>
|
|
64
|
+
cd lib-x17-fintech
|
|
65
|
+
pip install -e .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 基本用法
|
|
69
|
+
|
|
70
|
+
#### 1. 获取金融数据
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from xfintech.data.source.tushare import Session, Stock
|
|
74
|
+
|
|
75
|
+
# 创建会话
|
|
76
|
+
session = Session(credential="your_tushare_token")
|
|
77
|
+
|
|
78
|
+
# 获取股票列表
|
|
79
|
+
job = Stock(session=session)
|
|
80
|
+
result = job.run()
|
|
81
|
+
|
|
82
|
+
print(result.data) # pandas DataFrame
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### 2. 保存数据到存储
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from xfintech.connect import MacOSConnect, Artifact, ConnectRef
|
|
89
|
+
from xfintech.serde import PandasSerialiser, DataFormat
|
|
90
|
+
|
|
91
|
+
# 创建存储连接
|
|
92
|
+
connect = MacOSConnect()
|
|
93
|
+
|
|
94
|
+
# 保存数据
|
|
95
|
+
artifact = Artifact(
|
|
96
|
+
ref=ConnectRef("~/data/stocks.parquet"),
|
|
97
|
+
data=result.data
|
|
98
|
+
)
|
|
99
|
+
artifact.write(connect, PandasSerialiser, DataFormat.PARQUET)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 3. 定义数据模式
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from xfintech.fabric import TableInfo, ColumnInfo, ColumnKind
|
|
106
|
+
|
|
107
|
+
# 定义表结构
|
|
108
|
+
schema = TableInfo(
|
|
109
|
+
name="stock_daily",
|
|
110
|
+
columns=[
|
|
111
|
+
ColumnInfo(name="ts_code", kind=ColumnKind.STRING),
|
|
112
|
+
ColumnInfo(name="trade_date", kind=ColumnKind.DATE),
|
|
113
|
+
ColumnInfo(name="open", kind=ColumnKind.FLOAT),
|
|
114
|
+
ColumnInfo(name="close", kind=ColumnKind.FLOAT),
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# 验证数据
|
|
119
|
+
schema.validate(dataframe)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### 4. 完整数据管道
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from xfintech.data.source.tushare import Session, Dayline
|
|
126
|
+
from xfintech.data.common import Cache, Retry
|
|
127
|
+
from xfintech.connect import S3Connect, Artifact, ConnectRef
|
|
128
|
+
from xfintech.serde import PandasSerialiser, DataFormat
|
|
129
|
+
|
|
130
|
+
# 1. 获取数据(带缓存和重试)
|
|
131
|
+
session = Session(credential="token")
|
|
132
|
+
job = Dayline(
|
|
133
|
+
session=session,
|
|
134
|
+
params={"ts_code": "000001.SZ", "start_date": "20260101"},
|
|
135
|
+
cache=Cache(),
|
|
136
|
+
retry=Retry(retry=3, wait=1.0, rate=2.0)
|
|
137
|
+
)
|
|
138
|
+
result = job.run()
|
|
139
|
+
|
|
140
|
+
# 2. 保存到 S3
|
|
141
|
+
connect = S3Connect(bucket="my-bucket")
|
|
142
|
+
artifact = Artifact(
|
|
143
|
+
ref=ConnectRef("data/dayline/000001.parquet"),
|
|
144
|
+
data=result.data,
|
|
145
|
+
meta={"job": job.name, "duration": job.metric.duration}
|
|
146
|
+
)
|
|
147
|
+
artifact.write(connect, PandasSerialiser, DataFormat.PARQUET)
|
|
148
|
+
|
|
149
|
+
print(f"✅ 保存 {len(result.data)} 行数据,耗时 {job.metric.duration:.2f} 秒")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 模块架构
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
xfintech/
|
|
156
|
+
├── connect/ # 存储连接抽象
|
|
157
|
+
│ ├── MacOSConnect - 本地文件系统
|
|
158
|
+
│ ├── S3Connect - AWS S3
|
|
159
|
+
│ └── Artifact - 数据工件
|
|
160
|
+
│
|
|
161
|
+
├── data/ # 数据获取基础设施
|
|
162
|
+
│ ├── common/ - 通用工具(Cache, Retry, Metric)
|
|
163
|
+
│ ├── job/ - Job 系统和注册中心
|
|
164
|
+
│ ├── relay/ - 中继客户端
|
|
165
|
+
│ └── source/ - 数据源(Tushare, Baostock)
|
|
166
|
+
│
|
|
167
|
+
├── fabric/ # 数据模式管理
|
|
168
|
+
│ ├── TableInfo - 表结构定义
|
|
169
|
+
│ ├── ColumnInfo - 列信息
|
|
170
|
+
│ └── ColumnKind - 数据类型枚举
|
|
171
|
+
│
|
|
172
|
+
└── serde/ # 序列化/反序列化
|
|
173
|
+
├── PythonSerialiser - Python 对象
|
|
174
|
+
├── PandasSerialiser - DataFrame
|
|
175
|
+
└── DataFormat - 格式枚举
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 模块详解
|
|
179
|
+
|
|
180
|
+
### [xfintech.connect](xfintech/connect/README.md) - 存储连接
|
|
181
|
+
|
|
182
|
+
统一的存储抽象层,支持多种后端。
|
|
183
|
+
|
|
184
|
+
**主要功能**:
|
|
185
|
+
- `MacOSConnect` - 本地文件系统操作
|
|
186
|
+
- `S3Connect` - AWS S3 对象存储
|
|
187
|
+
- `Artifact` - 数据工件管理
|
|
188
|
+
- `ConnectRef` - 路径引用
|
|
189
|
+
|
|
190
|
+
**快速示例**:
|
|
191
|
+
```python
|
|
192
|
+
from xfintech.connect import MacOSConnect, Artifact, ConnectRef
|
|
193
|
+
|
|
194
|
+
connect = MacOSConnect()
|
|
195
|
+
artifact = Artifact(ref=ConnectRef("~/data/file.parquet"), data=df)
|
|
196
|
+
artifact.write(connect, serialiser, format)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
[📖 完整文档](xfintech/connect/README.md)
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### [xfintech.data](xfintech/data/README.md) - 数据获取
|
|
204
|
+
|
|
205
|
+
完整的数据获取基础设施,Job 系统管理数据请求生命周期。
|
|
206
|
+
|
|
207
|
+
**主要功能**:
|
|
208
|
+
- `Job` - 作业基类
|
|
209
|
+
- `TushareJob` - Tushare 数据源
|
|
210
|
+
- `Cache` - 智能缓存
|
|
211
|
+
- `Retry` - 指数退避重试
|
|
212
|
+
- `Metric` - 性能监控
|
|
213
|
+
|
|
214
|
+
**快速示例**:
|
|
215
|
+
```python
|
|
216
|
+
from xfintech.data.source.tushare import Session, Stock
|
|
217
|
+
from xfintech.data.common import Cache, Retry
|
|
218
|
+
|
|
219
|
+
session = Session(credential="token")
|
|
220
|
+
job = Stock(
|
|
221
|
+
session=session,
|
|
222
|
+
cache=Cache(),
|
|
223
|
+
retry=Retry(retry=3, wait=1.0)
|
|
224
|
+
)
|
|
225
|
+
result = job.run()
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**支持的数据源**:
|
|
229
|
+
- ✅ Tushare (28+ 股票数据类)
|
|
230
|
+
- ✅ Baostock
|
|
231
|
+
- 🔄 更多数据源开发中...
|
|
232
|
+
|
|
233
|
+
[📖 完整文档](xfintech/data/README.md)
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### [xfintech.fabric](xfintech/fabric/README.md) - 数据模式
|
|
238
|
+
|
|
239
|
+
灵活的表结构定义和验证系统。
|
|
240
|
+
|
|
241
|
+
**主要功能**:
|
|
242
|
+
- `TableInfo` - 表结构定义
|
|
243
|
+
- `ColumnInfo` - 列信息管理
|
|
244
|
+
- `ColumnKind` - 7 种数据类型
|
|
245
|
+
- 数据验证和文档生成
|
|
246
|
+
|
|
247
|
+
**快速示例**:
|
|
248
|
+
```python
|
|
249
|
+
from xfintech.fabric import TableInfo, ColumnInfo, ColumnKind
|
|
250
|
+
|
|
251
|
+
schema = TableInfo(
|
|
252
|
+
name="stock_daily",
|
|
253
|
+
columns=[
|
|
254
|
+
ColumnInfo(name="ts_code", kind=ColumnKind.STRING),
|
|
255
|
+
ColumnInfo(name="close", kind=ColumnKind.FLOAT),
|
|
256
|
+
]
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
# 验证数据
|
|
260
|
+
schema.validate(df)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
[📖 完整文档](xfintech/fabric/README.md)
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### [xfintech.serde](xfintech/serde/README.md) - 序列化
|
|
268
|
+
|
|
269
|
+
多格式序列化和反序列化支持。
|
|
270
|
+
|
|
271
|
+
**主要功能**:
|
|
272
|
+
- `PythonSerialiser` - Python 对象(Pickle)
|
|
273
|
+
- `PandasSerialiser` - DataFrame(Parquet/CSV/JSON)
|
|
274
|
+
- `DataFormat` - 格式枚举
|
|
275
|
+
- 自动类型检测
|
|
276
|
+
|
|
277
|
+
**快速示例**:
|
|
278
|
+
```python
|
|
279
|
+
from xfintech.serde import PandasSerialiser, DataFormat
|
|
280
|
+
|
|
281
|
+
# 序列化
|
|
282
|
+
serialised = PandasSerialiser.serialise(df, DataFormat.PARQUET)
|
|
283
|
+
|
|
284
|
+
# 反序列化
|
|
285
|
+
df = PandasSerialiser.deserialise(serialised, DataFormat.PARQUET)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**支持格式**:
|
|
289
|
+
| 格式 | 扩展名 | 适用场景 |
|
|
290
|
+
|------|--------|----------|
|
|
291
|
+
| Parquet | .parquet | 大数据集(推荐)|
|
|
292
|
+
| CSV | .csv | 文本导入/导出 |
|
|
293
|
+
| JSON | .json | API 交互 |
|
|
294
|
+
| Pickle | .pkl | Python 对象 |
|
|
295
|
+
|
|
296
|
+
[📖 完整文档](xfintech/serde/README.md)
|
|
297
|
+
|
|
298
|
+
## 使用场景
|
|
299
|
+
|
|
300
|
+
### 场景 1: 构建数据仓库
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from xfintech.data.source.tushare import Session, Dayline
|
|
304
|
+
from xfintech.connect import S3Connect, Artifact, ConnectRef
|
|
305
|
+
from xfintech.serde import PandasSerialiser, DataFormat
|
|
306
|
+
from datetime import datetime, timedelta
|
|
307
|
+
|
|
308
|
+
def build_data_warehouse():
|
|
309
|
+
"""构建股票日线数据仓库"""
|
|
310
|
+
session = Session(credential="token")
|
|
311
|
+
connect = S3Connect(bucket="datawarehouse")
|
|
312
|
+
|
|
313
|
+
# 获取过去 30 天的数据
|
|
314
|
+
end_date = datetime.now()
|
|
315
|
+
start_date = end_date - timedelta(days=30)
|
|
316
|
+
|
|
317
|
+
symbols = ["000001.SZ", "600000.SH", "000002.SZ"]
|
|
318
|
+
|
|
319
|
+
for symbol in symbols:
|
|
320
|
+
job = Dayline(
|
|
321
|
+
session=session,
|
|
322
|
+
params={
|
|
323
|
+
"ts_code": symbol,
|
|
324
|
+
"start_date": start_date.strftime("%Y%m%d"),
|
|
325
|
+
"end_date": end_date.strftime("%Y%m%d")
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
result = job.run()
|
|
329
|
+
|
|
330
|
+
# 保存到 S3
|
|
331
|
+
path = f"stocks/daily/{symbol}/{end_date.strftime('%Y%m%d')}.parquet"
|
|
332
|
+
artifact = Artifact(ref=ConnectRef(path), data=result.data)
|
|
333
|
+
artifact.write(connect, PandasSerialiser, DataFormat.PARQUET)
|
|
334
|
+
|
|
335
|
+
print(f"✅ {symbol}: {len(result.data)} 行")
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### 场景 2: 数据质量监控
|
|
339
|
+
|
|
340
|
+
```python
|
|
341
|
+
from xfintech.data.source.tushare import Session, Stock
|
|
342
|
+
from xfintech.fabric import TableInfo, ColumnInfo, ColumnKind
|
|
343
|
+
|
|
344
|
+
def monitor_data_quality():
|
|
345
|
+
"""监控数据质量"""
|
|
346
|
+
# 1. 定义期望的模式
|
|
347
|
+
expected_schema = TableInfo(
|
|
348
|
+
name="stock_basic",
|
|
349
|
+
columns=[
|
|
350
|
+
ColumnInfo(name="ts_code", kind=ColumnKind.STRING),
|
|
351
|
+
ColumnInfo(name="name", kind=ColumnKind.STRING),
|
|
352
|
+
ColumnInfo(name="list_date", kind=ColumnKind.DATE),
|
|
353
|
+
]
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
# 2. 获取数据
|
|
357
|
+
session = Session(credential="token")
|
|
358
|
+
job = Stock(session=session)
|
|
359
|
+
result = job.run()
|
|
360
|
+
|
|
361
|
+
# 3. 验证
|
|
362
|
+
try:
|
|
363
|
+
expected_schema.validate(result.data)
|
|
364
|
+
print("✅ 数据质量检查通过")
|
|
365
|
+
except Exception as e:
|
|
366
|
+
print(f"❌ 数据质量问题: {e}")
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### 场景 3: 增量数据更新
|
|
370
|
+
|
|
371
|
+
```python
|
|
372
|
+
from xfintech.data.source.tushare import Session, TradeDate, Dayline
|
|
373
|
+
from xfintech.connect import MacOSConnect, Artifact, ConnectRef
|
|
374
|
+
from xfintech.serde import PandasSerialiser, DataFormat
|
|
375
|
+
import pandas as pd
|
|
376
|
+
|
|
377
|
+
def incremental_update():
|
|
378
|
+
"""增量更新每日数据"""
|
|
379
|
+
session = Session(credential="token")
|
|
380
|
+
connect = MacOSConnect()
|
|
381
|
+
|
|
382
|
+
# 1. 获取最新交易日
|
|
383
|
+
trade_date_job = TradeDate(
|
|
384
|
+
session=session,
|
|
385
|
+
params={"exchange": "SSE"}
|
|
386
|
+
)
|
|
387
|
+
trade_dates = trade_date_job.run().data
|
|
388
|
+
latest_date = trade_dates['cal_date'].max()
|
|
389
|
+
|
|
390
|
+
# 2. 检查是否已存在
|
|
391
|
+
ref = ConnectRef(f"~/data/daily/{latest_date}.parquet")
|
|
392
|
+
if connect.exists(ref):
|
|
393
|
+
print(f"📌 {latest_date} 数据已存在,跳过")
|
|
394
|
+
return
|
|
395
|
+
|
|
396
|
+
# 3. 获取并保存新数据
|
|
397
|
+
job = Dayline(
|
|
398
|
+
session=session,
|
|
399
|
+
params={"trade_date": latest_date}
|
|
400
|
+
)
|
|
401
|
+
result = job.run()
|
|
402
|
+
|
|
403
|
+
artifact = Artifact(ref=ref, data=result.data)
|
|
404
|
+
artifact.write(connect, PandasSerialiser, DataFormat.PARQUET)
|
|
405
|
+
|
|
406
|
+
print(f"✅ 更新 {latest_date}: {len(result.data)} 行")
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## 测试
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# 运行所有测试
|
|
413
|
+
pytest
|
|
414
|
+
|
|
415
|
+
# 带覆盖率报告
|
|
416
|
+
pytest --cov=xfintech --cov-report=html
|
|
417
|
+
|
|
418
|
+
# 运行特定模块测试
|
|
419
|
+
pytest xfintech/connect/
|
|
420
|
+
pytest xfintech/data/
|
|
421
|
+
pytest xfintech/fabric/
|
|
422
|
+
pytest xfintech/serde/
|
|
423
|
+
|
|
424
|
+
# 性能基准测试
|
|
425
|
+
pytest --benchmark-only
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
**测试统计**:
|
|
429
|
+
- ✅ 2,467 测试全部通过
|
|
430
|
+
- 📊 98% 代码覆盖率
|
|
431
|
+
- ⚡ 所有测试 < 5 秒
|
|
432
|
+
|
|
433
|
+
## 开发
|
|
434
|
+
|
|
435
|
+
### 项目结构
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
lib-x17-fintech/
|
|
439
|
+
├── xfintech/ # 源代码
|
|
440
|
+
│ ├── connect/ # 存储模块
|
|
441
|
+
│ ├── data/ # 数据模块
|
|
442
|
+
│ ├── fabric/ # 模式模块
|
|
443
|
+
│ └── serde/ # 序列化模块
|
|
444
|
+
├── tests/ # 测试(镜像源码结构)
|
|
445
|
+
├── example/ # 示例代码
|
|
446
|
+
├── pyproject.toml # 项目配置
|
|
447
|
+
├── pytest.ini # 测试配置
|
|
448
|
+
├── environment.yml # Conda 环境
|
|
449
|
+
└── makefile # 构建脚本
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### 环境设置
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
# 使用 Conda
|
|
456
|
+
conda env create -f environment.yml
|
|
457
|
+
conda activate xfintech
|
|
458
|
+
|
|
459
|
+
# 或使用 pip
|
|
460
|
+
python -m venv venv
|
|
461
|
+
source venv/bin/activate # Linux/Mac
|
|
462
|
+
pip install -e .[dev]
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### 代码规范
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
# 格式化和 Lint
|
|
469
|
+
ruff check xfintech/
|
|
470
|
+
ruff format xfintech/
|
|
471
|
+
|
|
472
|
+
# 类型检查
|
|
473
|
+
mypy xfintech/
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### 构建和发布
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
# 构建包
|
|
480
|
+
python -m build
|
|
481
|
+
|
|
482
|
+
# 发布到 PyPI
|
|
483
|
+
twine upload dist/*
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
## 配置
|
|
487
|
+
|
|
488
|
+
### 环境变量
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Tushare 配置
|
|
492
|
+
export TUSHARE_TOKEN="your_token_here"
|
|
493
|
+
|
|
494
|
+
# AWS 配置(用于 S3Connect)
|
|
495
|
+
export AWS_ACCESS_KEY_ID="your_key"
|
|
496
|
+
export AWS_SECRET_ACCESS_KEY="your_secret"
|
|
497
|
+
export AWS_DEFAULT_REGION="us-east-1"
|
|
498
|
+
|
|
499
|
+
# 缓存目录
|
|
500
|
+
export XFINTECH_CACHE_DIR="/custom/cache/path"
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### 配置文件
|
|
504
|
+
|
|
505
|
+
创建 `~/.xfintech/config.toml`:
|
|
506
|
+
|
|
507
|
+
```toml
|
|
508
|
+
[tushare]
|
|
509
|
+
token = "your_tushare_token"
|
|
510
|
+
|
|
511
|
+
[cache]
|
|
512
|
+
path = "/data/cache"
|
|
513
|
+
ttl = 86400 # 24 hours
|
|
514
|
+
|
|
515
|
+
[s3]
|
|
516
|
+
bucket = "my-data-bucket"
|
|
517
|
+
region = "us-east-1"
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
## 最佳实践
|
|
521
|
+
|
|
522
|
+
### ✅ 推荐做法
|
|
523
|
+
|
|
524
|
+
```python
|
|
525
|
+
# 1. 始终使用缓存
|
|
526
|
+
from xfintech.data.common import Cache
|
|
527
|
+
job = SomeJob(session=session, cache=Cache())
|
|
528
|
+
|
|
529
|
+
# 2. 配置重试策略
|
|
530
|
+
from xfintech.data.common import Retry
|
|
531
|
+
job = SomeJob(session=session, retry=Retry(retry=3, wait=1.0, rate=2.0))
|
|
532
|
+
|
|
533
|
+
# 3. 使用上下文管理器
|
|
534
|
+
with connect:
|
|
535
|
+
artifact.write(connect, serialiser, format)
|
|
536
|
+
|
|
537
|
+
# 4. 验证数据模式
|
|
538
|
+
schema.validate(dataframe)
|
|
539
|
+
|
|
540
|
+
# 5. 监控性能
|
|
541
|
+
result = job.run()
|
|
542
|
+
print(f"耗时: {job.metric.duration} 秒")
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### ❌ 避免的做法
|
|
546
|
+
|
|
547
|
+
```python
|
|
548
|
+
# 1. 不使用缓存(重复 API 调用)
|
|
549
|
+
job = SomeJob(session=session) # 缺少 cache
|
|
550
|
+
|
|
551
|
+
# 2. 硬编码路径
|
|
552
|
+
path = "/Users/john/data/file.csv" # 使用 ConnectRef
|
|
553
|
+
|
|
554
|
+
# 3. 忽略错误
|
|
555
|
+
result = job.run() # 不检查 job.metric.errors
|
|
556
|
+
|
|
557
|
+
# 4. 不验证数据
|
|
558
|
+
artifact.write(connect, serialiser, format) # 先验证
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## 常见问题
|
|
562
|
+
|
|
563
|
+
### Q: 如何选择存储后端?
|
|
564
|
+
|
|
565
|
+
**A**:
|
|
566
|
+
- 本地开发/小数据集 → `MacOSConnect`
|
|
567
|
+
- 生产环境/大数据集/团队协作 → `S3Connect`
|
|
568
|
+
|
|
569
|
+
### Q: 哪种序列化格式最适合?
|
|
570
|
+
|
|
571
|
+
**A**:
|
|
572
|
+
- 性能优先(大数据)→ Parquet
|
|
573
|
+
- 人类可读 → CSV
|
|
574
|
+
- API 交互 → JSON
|
|
575
|
+
- Python 对象 → Pickle
|
|
576
|
+
|
|
577
|
+
### Q: 如何提高数据获取性能?
|
|
578
|
+
|
|
579
|
+
**A**:
|
|
580
|
+
1. 启用缓存: `Cache()`
|
|
581
|
+
2. 调大分页: `Paginate(pagesize=5000)`
|
|
582
|
+
3. 并发获取: 使用 `ThreadPoolExecutor`
|
|
583
|
+
4. 使用中继: `Session(mode="relay")`
|
|
584
|
+
|
|
585
|
+
### Q: 测试失败怎么办?
|
|
586
|
+
|
|
587
|
+
**A**:
|
|
588
|
+
```bash
|
|
589
|
+
# 查看详细错误
|
|
590
|
+
pytest -v
|
|
591
|
+
|
|
592
|
+
# 只运行失败的测试
|
|
593
|
+
pytest --lf
|
|
594
|
+
|
|
595
|
+
# 查看标准输出
|
|
596
|
+
pytest -s
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## 贡献
|
|
600
|
+
|
|
601
|
+
欢迎贡献!请遵循以下流程:
|
|
602
|
+
|
|
603
|
+
1. Fork 项目
|
|
604
|
+
2. 创建特性分支 (`git checkout -b feature/amazing`)
|
|
605
|
+
3. 提交更改 (`git commit -m 'Add amazing feature'`)
|
|
606
|
+
4. 推送到分支 (`git push origin feature/amazing`)
|
|
607
|
+
5. 创建 Pull Request
|
|
608
|
+
|
|
609
|
+
## 许可证
|
|
610
|
+
|
|
611
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
612
|
+
|
|
613
|
+
## 作者
|
|
614
|
+
|
|
615
|
+
**Xing Xing** - [x.xing.work@gmail.com](mailto:x.xing.work@gmail.com)
|
|
616
|
+
|
|
617
|
+
## 相关项目
|
|
618
|
+
|
|
619
|
+
- `lib-x17-cloudcdk` - AWS CDK 基础设施
|
|
620
|
+
- `lib-x17-cloudsdk` - 云服务 SDK
|
|
621
|
+
- `lib-x17-cloudmeta` - 云元数据管理
|
|
622
|
+
|
|
623
|
+
## 更新日志
|
|
624
|
+
|
|
625
|
+
### v2.0.0 (2026-01-09)
|
|
626
|
+
- ✨ 完整的四模块架构(connect, data, fabric, serde)
|
|
627
|
+
- 📚 完善的文档和示例
|
|
628
|
+
- ✅ 2,467 测试,98% 覆盖率
|
|
629
|
+
- 🚀 性能优化和缓存机制
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
**让金融数据处理变得简单、高效、可靠!** 🚀
|