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.
Files changed (282) hide show
  1. lib_x17_fintech-2.1.3.dist-info/METADATA +633 -0
  2. lib_x17_fintech-2.1.3.dist-info/RECORD +282 -0
  3. lib_x17_fintech-2.1.3.dist-info/WHEEL +5 -0
  4. lib_x17_fintech-2.1.3.dist-info/licenses/LICENSE +1 -0
  5. lib_x17_fintech-2.1.3.dist-info/top_level.txt +1 -0
  6. xfintech/__init__.py +0 -0
  7. xfintech/connect/__init__.py +18 -0
  8. xfintech/connect/artifact/__init__.py +5 -0
  9. xfintech/connect/artifact/artifact.py +168 -0
  10. xfintech/connect/artifact/tests/__init__.py +3 -0
  11. xfintech/connect/artifact/tests/test_class_artifact_all.py +564 -0
  12. xfintech/connect/common/__init__.py +12 -0
  13. xfintech/connect/common/connect.py +49 -0
  14. xfintech/connect/common/connectref.py +119 -0
  15. xfintech/connect/common/error.py +62 -0
  16. xfintech/connect/common/tests/__init__.py +1 -0
  17. xfintech/connect/common/tests/test_class_connectlike_all.py +544 -0
  18. xfintech/connect/common/tests/test_class_connectref_all.py +586 -0
  19. xfintech/connect/common/tests/test_class_errors_all.py +524 -0
  20. xfintech/connect/instance/__init__.py +7 -0
  21. xfintech/connect/instance/macos.py +121 -0
  22. xfintech/connect/instance/s3.py +176 -0
  23. xfintech/connect/instance/tests/__init__.py +1 -0
  24. xfintech/connect/instance/tests/test_class_macosconnect_all.py +692 -0
  25. xfintech/connect/instance/tests/test_class_s3connect_all.py +603 -0
  26. xfintech/data/__init__.py +20 -0
  27. xfintech/data/common/__init__.py +15 -0
  28. xfintech/data/common/cache.py +186 -0
  29. xfintech/data/common/coolant.py +171 -0
  30. xfintech/data/common/metric.py +138 -0
  31. xfintech/data/common/paginate.py +132 -0
  32. xfintech/data/common/params.py +162 -0
  33. xfintech/data/common/retry.py +201 -0
  34. xfintech/data/common/tests/__init__.py +1 -0
  35. xfintech/data/common/tests/test_class_cache_all.py +681 -0
  36. xfintech/data/common/tests/test_class_coolant_all.py +534 -0
  37. xfintech/data/common/tests/test_class_metric_all.py +705 -0
  38. xfintech/data/common/tests/test_class_paginate_all.py +508 -0
  39. xfintech/data/common/tests/test_class_params_all.py +891 -0
  40. xfintech/data/common/tests/test_class_retry_all.py +714 -0
  41. xfintech/data/job/__init__.py +17 -0
  42. xfintech/data/job/errors.py +112 -0
  43. xfintech/data/job/house.py +156 -0
  44. xfintech/data/job/job.py +247 -0
  45. xfintech/data/job/joblike.py +47 -0
  46. xfintech/data/job/tests/__init__.py +1 -0
  47. xfintech/data/job/tests/test_class_errors_all.py +275 -0
  48. xfintech/data/job/tests/test_class_house_all.py +801 -0
  49. xfintech/data/job/tests/test_class_job_all.py +684 -0
  50. xfintech/data/job/tests/test_class_joblike_all.py +482 -0
  51. xfintech/data/relay/__init__.py +7 -0
  52. xfintech/data/relay/client.py +114 -0
  53. xfintech/data/relay/clientlike.py +45 -0
  54. xfintech/data/relay/tests/test_class_relayclient_all.py +484 -0
  55. xfintech/data/relay/tests/test_class_relayclientlike_all.py +500 -0
  56. xfintech/data/source/__init__.py +7 -0
  57. xfintech/data/source/baostock/__init__.py +21 -0
  58. xfintech/data/source/baostock/job/__init__.py +5 -0
  59. xfintech/data/source/baostock/job/job.py +217 -0
  60. xfintech/data/source/baostock/job/tests/__init__.py +0 -0
  61. xfintech/data/source/baostock/job/tests/test_class_baostockjob_all.py +547 -0
  62. xfintech/data/source/baostock/session/__init__.py +8 -0
  63. xfintech/data/source/baostock/session/relay.py +223 -0
  64. xfintech/data/source/baostock/session/session.py +241 -0
  65. xfintech/data/source/baostock/session/tests/__init__.py +0 -0
  66. xfintech/data/source/baostock/session/tests/test_class_relay_all.py +694 -0
  67. xfintech/data/source/baostock/session/tests/test_class_session_all.py +505 -0
  68. xfintech/data/source/baostock/stock/__init__.py +0 -0
  69. xfintech/data/source/baostock/stock/hs300stock/__init__.py +3 -0
  70. xfintech/data/source/baostock/stock/hs300stock/constant.py +49 -0
  71. xfintech/data/source/baostock/stock/hs300stock/hs300stock.py +133 -0
  72. xfintech/data/source/baostock/stock/hs300stock/tests/__init__.py +1 -0
  73. xfintech/data/source/baostock/stock/hs300stock/tests/test_class_hs300index_all.py +413 -0
  74. xfintech/data/source/baostock/stock/minuteline/__init__.py +19 -0
  75. xfintech/data/source/baostock/stock/minuteline/constant.py +89 -0
  76. xfintech/data/source/baostock/stock/minuteline/minuteline.py +163 -0
  77. xfintech/data/source/baostock/stock/minuteline/tests/__init__.py +0 -0
  78. xfintech/data/source/baostock/stock/minuteline/tests/test_class_minuteline_all.py +582 -0
  79. xfintech/data/source/baostock/stock/stock/__init__.py +19 -0
  80. xfintech/data/source/baostock/stock/stock/constant.py +55 -0
  81. xfintech/data/source/baostock/stock/stock/stock.py +149 -0
  82. xfintech/data/source/baostock/stock/stock/tests/__init__.py +0 -0
  83. xfintech/data/source/baostock/stock/stock/tests/test_class_stock_all.py +508 -0
  84. xfintech/data/source/baostock/stock/stockinfo/__init__.py +5 -0
  85. xfintech/data/source/baostock/stock/stockinfo/constant.py +66 -0
  86. xfintech/data/source/baostock/stock/stockinfo/stockinfo.py +176 -0
  87. xfintech/data/source/baostock/stock/stockinfo/tests/__init__.py +1 -0
  88. xfintech/data/source/baostock/stock/stockinfo/tests/test_class_stockinfo_all.py +617 -0
  89. xfintech/data/source/baostock/stock/sz50stock/__init__.py +3 -0
  90. xfintech/data/source/baostock/stock/sz50stock/constant.py +49 -0
  91. xfintech/data/source/baostock/stock/sz50stock/sz50stock.py +133 -0
  92. xfintech/data/source/baostock/stock/sz50stock/tests/__init__.py +1 -0
  93. xfintech/data/source/baostock/stock/sz50stock/tests/test_class_sz50stock_all.py +397 -0
  94. xfintech/data/source/baostock/stock/tradedate/__init__.py +19 -0
  95. xfintech/data/source/baostock/stock/tradedate/constant.py +72 -0
  96. xfintech/data/source/baostock/stock/tradedate/tests/__init__.py +0 -0
  97. xfintech/data/source/baostock/stock/tradedate/tests/test_class_tradedate_all.py +695 -0
  98. xfintech/data/source/baostock/stock/tradedate/tradedate.py +208 -0
  99. xfintech/data/source/baostock/stock/zz500stock/__init__.py +3 -0
  100. xfintech/data/source/baostock/stock/zz500stock/constant.py +55 -0
  101. xfintech/data/source/baostock/stock/zz500stock/tests/__init__.py +1 -0
  102. xfintech/data/source/baostock/stock/zz500stock/tests/test_class_zz500stock_all.py +421 -0
  103. xfintech/data/source/baostock/stock/zz500stock/zz500stock.py +133 -0
  104. xfintech/data/source/tushare/__init__.py +61 -0
  105. xfintech/data/source/tushare/job/__init__.py +5 -0
  106. xfintech/data/source/tushare/job/job.py +257 -0
  107. xfintech/data/source/tushare/job/tests/test_class_tusharejob_all.py +589 -0
  108. xfintech/data/source/tushare/session/__init__.py +5 -0
  109. xfintech/data/source/tushare/session/relay.py +231 -0
  110. xfintech/data/source/tushare/session/session.py +239 -0
  111. xfintech/data/source/tushare/session/tests/test_class_relay_all.py +719 -0
  112. xfintech/data/source/tushare/session/tests/test_class_session_all.py +705 -0
  113. xfintech/data/source/tushare/stock/__init__.py +55 -0
  114. xfintech/data/source/tushare/stock/adjfactor/__init__.py +19 -0
  115. xfintech/data/source/tushare/stock/adjfactor/adjfactor.py +150 -0
  116. xfintech/data/source/tushare/stock/adjfactor/constant.py +71 -0
  117. xfintech/data/source/tushare/stock/adjfactor/tests/__init__.py +0 -0
  118. xfintech/data/source/tushare/stock/adjfactor/tests/test_class_adjfactor_all.py +372 -0
  119. xfintech/data/source/tushare/stock/capflow/__init__.py +19 -0
  120. xfintech/data/source/tushare/stock/capflow/capflow.py +171 -0
  121. xfintech/data/source/tushare/stock/capflow/constant.py +105 -0
  122. xfintech/data/source/tushare/stock/capflow/tests/__init__.py +0 -0
  123. xfintech/data/source/tushare/stock/capflow/tests/test_class_capflow_all.py +589 -0
  124. xfintech/data/source/tushare/stock/capflowdc/__init__.py +19 -0
  125. xfintech/data/source/tushare/stock/capflowdc/capflowdc.py +167 -0
  126. xfintech/data/source/tushare/stock/capflowdc/constant.py +95 -0
  127. xfintech/data/source/tushare/stock/capflowdc/tests/__init__.py +0 -0
  128. xfintech/data/source/tushare/stock/capflowdc/tests/test_class_capflowdc_all.py +814 -0
  129. xfintech/data/source/tushare/stock/capflowths/__init__.py +19 -0
  130. xfintech/data/source/tushare/stock/capflowths/capflowths.py +173 -0
  131. xfintech/data/source/tushare/stock/capflowths/constant.py +92 -0
  132. xfintech/data/source/tushare/stock/capflowths/tests/__init__.py +0 -0
  133. xfintech/data/source/tushare/stock/capflowths/tests/test_class_capflowths_all.py +551 -0
  134. xfintech/data/source/tushare/stock/company/__init__.py +19 -0
  135. xfintech/data/source/tushare/stock/company/company.py +188 -0
  136. xfintech/data/source/tushare/stock/company/constant.py +92 -0
  137. xfintech/data/source/tushare/stock/company/tests/__init__.py +1 -0
  138. xfintech/data/source/tushare/stock/company/tests/test_class_company_all.py +829 -0
  139. xfintech/data/source/tushare/stock/companybusiness/__init__.py +21 -0
  140. xfintech/data/source/tushare/stock/companybusiness/companybusiness.py +183 -0
  141. xfintech/data/source/tushare/stock/companybusiness/constant.py +91 -0
  142. xfintech/data/source/tushare/stock/companybusiness/tests/__init__.py +0 -0
  143. xfintech/data/source/tushare/stock/companybusiness/tests/test_class_companybusiness_all.py +633 -0
  144. xfintech/data/source/tushare/stock/companycashflow/__init__.py +21 -0
  145. xfintech/data/source/tushare/stock/companycashflow/companycashflow.py +277 -0
  146. xfintech/data/source/tushare/stock/companycashflow/constant.py +293 -0
  147. xfintech/data/source/tushare/stock/companycashflow/tests/__init__.py +0 -0
  148. xfintech/data/source/tushare/stock/companycashflow/tests/test_class_companycashflow_all.py +619 -0
  149. xfintech/data/source/tushare/stock/companydebt/__init__.py +19 -0
  150. xfintech/data/source/tushare/stock/companydebt/companydebt.py +339 -0
  151. xfintech/data/source/tushare/stock/companydebt/constant.py +403 -0
  152. xfintech/data/source/tushare/stock/companydebt/tests/__init__.py +0 -0
  153. xfintech/data/source/tushare/stock/companydebt/tests/test_class_companydebt_all.py +655 -0
  154. xfintech/data/source/tushare/stock/companyoverview/__init__.py +21 -0
  155. xfintech/data/source/tushare/stock/companyoverview/companyoverview.py +214 -0
  156. xfintech/data/source/tushare/stock/companyoverview/constant.py +152 -0
  157. xfintech/data/source/tushare/stock/companyoverview/tests/__init__.py +0 -0
  158. xfintech/data/source/tushare/stock/companyoverview/tests/test_class_companyoverview_all.py +647 -0
  159. xfintech/data/source/tushare/stock/companyprofit/__init__.py +21 -0
  160. xfintech/data/source/tushare/stock/companyprofit/companyprofit.py +272 -0
  161. xfintech/data/source/tushare/stock/companyprofit/constant.py +259 -0
  162. xfintech/data/source/tushare/stock/companyprofit/tests/__init__.py +0 -0
  163. xfintech/data/source/tushare/stock/companyprofit/tests/test_class_companyprofit_all.py +635 -0
  164. xfintech/data/source/tushare/stock/conceptcapflowdc/__init__.py +21 -0
  165. xfintech/data/source/tushare/stock/conceptcapflowdc/conceptcapflowdc.py +175 -0
  166. xfintech/data/source/tushare/stock/conceptcapflowdc/constant.py +106 -0
  167. xfintech/data/source/tushare/stock/conceptcapflowdc/tests/__init__.py +0 -0
  168. xfintech/data/source/tushare/stock/conceptcapflowdc/tests/test_class_conceptcapflowdc_all.py +568 -0
  169. xfintech/data/source/tushare/stock/conceptcapflowths/__init__.py +21 -0
  170. xfintech/data/source/tushare/stock/conceptcapflowths/conceptcapflowths.py +188 -0
  171. xfintech/data/source/tushare/stock/conceptcapflowths/constant.py +89 -0
  172. xfintech/data/source/tushare/stock/conceptcapflowths/tests/__init__.py +0 -0
  173. xfintech/data/source/tushare/stock/conceptcapflowths/tests/test_class_conceptcapflowths_all.py +516 -0
  174. xfintech/data/source/tushare/stock/dayline/__init__.py +19 -0
  175. xfintech/data/source/tushare/stock/dayline/constant.py +87 -0
  176. xfintech/data/source/tushare/stock/dayline/dayline.py +177 -0
  177. xfintech/data/source/tushare/stock/dayline/tests/__init__.py +0 -0
  178. xfintech/data/source/tushare/stock/dayline/tests/test_class_dayline_all.py +585 -0
  179. xfintech/data/source/tushare/stock/industrycapflowths/__init__.py +21 -0
  180. xfintech/data/source/tushare/stock/industrycapflowths/constant.py +89 -0
  181. xfintech/data/source/tushare/stock/industrycapflowths/industrycapflowths.py +192 -0
  182. xfintech/data/source/tushare/stock/industrycapflowths/tests/__init__.py +0 -0
  183. xfintech/data/source/tushare/stock/industrycapflowths/tests/test_class_industrycapflowths_all.py +683 -0
  184. xfintech/data/source/tushare/stock/marketindexcapflowdc/__init__.py +21 -0
  185. xfintech/data/source/tushare/stock/marketindexcapflowdc/constant.py +90 -0
  186. xfintech/data/source/tushare/stock/marketindexcapflowdc/marketindexcapflowdc.py +173 -0
  187. xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/__init__.py +0 -0
  188. xfintech/data/source/tushare/stock/marketindexcapflowdc/tests/test_class_marketindexcapflowdc_all.py +793 -0
  189. xfintech/data/source/tushare/stock/monthline/__init__.py +19 -0
  190. xfintech/data/source/tushare/stock/monthline/constant.py +87 -0
  191. xfintech/data/source/tushare/stock/monthline/monthline.py +180 -0
  192. xfintech/data/source/tushare/stock/monthline/tests/__init__.py +0 -0
  193. xfintech/data/source/tushare/stock/monthline/tests/test_class_monthline_all.py +574 -0
  194. xfintech/data/source/tushare/stock/stock/__init__.py +19 -0
  195. xfintech/data/source/tushare/stock/stock/constant.py +105 -0
  196. xfintech/data/source/tushare/stock/stock/stock.py +193 -0
  197. xfintech/data/source/tushare/stock/stock/tests/__init__.py +0 -0
  198. xfintech/data/source/tushare/stock/stock/tests/test_class_stock_all.py +788 -0
  199. xfintech/data/source/tushare/stock/stockdividend/__init__.py +21 -0
  200. xfintech/data/source/tushare/stock/stockdividend/constant.py +111 -0
  201. xfintech/data/source/tushare/stock/stockdividend/stockdividend.py +180 -0
  202. xfintech/data/source/tushare/stock/stockdividend/tests/__init__.py +0 -0
  203. xfintech/data/source/tushare/stock/stockdividend/tests/test_class_stockdividend_all.py +725 -0
  204. xfintech/data/source/tushare/stock/stockinfo/__init__.py +19 -0
  205. xfintech/data/source/tushare/stock/stockinfo/constant.py +104 -0
  206. xfintech/data/source/tushare/stock/stockinfo/stockinfo.py +208 -0
  207. xfintech/data/source/tushare/stock/stockinfo/tests/__init__.py +0 -0
  208. xfintech/data/source/tushare/stock/stockinfo/tests/test_class_stockinfo_all.py +881 -0
  209. xfintech/data/source/tushare/stock/stockipo/__init__.py +19 -0
  210. xfintech/data/source/tushare/stock/stockipo/constant.py +90 -0
  211. xfintech/data/source/tushare/stock/stockipo/stockipo.py +234 -0
  212. xfintech/data/source/tushare/stock/stockipo/tests/__init__.py +1 -0
  213. xfintech/data/source/tushare/stock/stockipo/tests/test_class_stockipo_all.py +750 -0
  214. xfintech/data/source/tushare/stock/stockpledge/__init__.py +19 -0
  215. xfintech/data/source/tushare/stock/stockpledge/constant.py +72 -0
  216. xfintech/data/source/tushare/stock/stockpledge/stockpledge.py +158 -0
  217. xfintech/data/source/tushare/stock/stockpledge/tests/__init__.py +0 -0
  218. xfintech/data/source/tushare/stock/stockpledge/tests/test_class_stockpledge_all.py +664 -0
  219. xfintech/data/source/tushare/stock/stockpledgedetail/__init__.py +21 -0
  220. xfintech/data/source/tushare/stock/stockpledgedetail/constant.py +85 -0
  221. xfintech/data/source/tushare/stock/stockpledgedetail/stockpledgedetail.py +171 -0
  222. xfintech/data/source/tushare/stock/stockpledgedetail/tests/__init__.py +0 -0
  223. xfintech/data/source/tushare/stock/stockpledgedetail/tests/test_class_stockpledgedetail_all.py +112 -0
  224. xfintech/data/source/tushare/stock/stockst/__init__.py +19 -0
  225. xfintech/data/source/tushare/stock/stockst/constant.py +80 -0
  226. xfintech/data/source/tushare/stock/stockst/stockst.py +189 -0
  227. xfintech/data/source/tushare/stock/stockst/tests/__init__.py +0 -0
  228. xfintech/data/source/tushare/stock/stockst/tests/test_class_stockst_all.py +693 -0
  229. xfintech/data/source/tushare/stock/stocksuspend/__init__.py +21 -0
  230. xfintech/data/source/tushare/stock/stocksuspend/constant.py +75 -0
  231. xfintech/data/source/tushare/stock/stocksuspend/stocksuspend.py +151 -0
  232. xfintech/data/source/tushare/stock/stocksuspend/tests/__init__.py +0 -0
  233. xfintech/data/source/tushare/stock/stocksuspend/tests/test_class_stocksuspend_all.py +626 -0
  234. xfintech/data/source/tushare/stock/techindex/__init__.py +19 -0
  235. xfintech/data/source/tushare/stock/techindex/constant.py +600 -0
  236. xfintech/data/source/tushare/stock/techindex/techindex.py +314 -0
  237. xfintech/data/source/tushare/stock/techindex/tests/__init__.py +0 -0
  238. xfintech/data/source/tushare/stock/techindex/tests/test_class_techindex_all.py +576 -0
  239. xfintech/data/source/tushare/stock/tradedate/__init__.py +19 -0
  240. xfintech/data/source/tushare/stock/tradedate/constant.py +93 -0
  241. xfintech/data/source/tushare/stock/tradedate/tests/__init__.py +0 -0
  242. xfintech/data/source/tushare/stock/tradedate/tests/test_class_tradedate_all.py +947 -0
  243. xfintech/data/source/tushare/stock/tradedate/tradedate.py +234 -0
  244. xfintech/data/source/tushare/stock/weekline/__init__.py +19 -0
  245. xfintech/data/source/tushare/stock/weekline/constant.py +87 -0
  246. xfintech/data/source/tushare/stock/weekline/tests/__init__.py +0 -0
  247. xfintech/data/source/tushare/stock/weekline/tests/test_class_weekline_all.py +575 -0
  248. xfintech/data/source/tushare/stock/weekline/weekline.py +182 -0
  249. xfintech/fabric/__init__.py +18 -0
  250. xfintech/fabric/column/__init__.py +7 -0
  251. xfintech/fabric/column/info.py +202 -0
  252. xfintech/fabric/column/kind.py +102 -0
  253. xfintech/fabric/column/tests/__init__.py +0 -0
  254. xfintech/fabric/column/tests/test_class_info_all.py +207 -0
  255. xfintech/fabric/column/tests/test_class_kind_all.py +80 -0
  256. xfintech/fabric/table/__init__.py +5 -0
  257. xfintech/fabric/table/info.py +263 -0
  258. xfintech/fabric/table/tests/__init__.py +0 -0
  259. xfintech/fabric/table/tests/test_class_info_all.py +547 -0
  260. xfintech/serde/__init__.py +35 -0
  261. xfintech/serde/common/__init__.py +9 -0
  262. xfintech/serde/common/dataformat.py +78 -0
  263. xfintech/serde/common/deserialiserlike.py +38 -0
  264. xfintech/serde/common/error.py +182 -0
  265. xfintech/serde/common/serialiserlike.py +38 -0
  266. xfintech/serde/common/tests/__init__.py +1 -0
  267. xfintech/serde/common/tests/test_class_dataformat_all.py +694 -0
  268. xfintech/serde/common/tests/test_class_deserialiserlike_all.py +500 -0
  269. xfintech/serde/common/tests/test_class_errors_all.py +518 -0
  270. xfintech/serde/common/tests/test_class_serialiserlike_all.py +401 -0
  271. xfintech/serde/deserialiser/__init__.py +7 -0
  272. xfintech/serde/deserialiser/pandas.py +113 -0
  273. xfintech/serde/deserialiser/python.py +68 -0
  274. xfintech/serde/deserialiser/tests/__init__.py +1 -0
  275. xfintech/serde/deserialiser/tests/test_class_pandasdeserialiser_all.py +503 -0
  276. xfintech/serde/deserialiser/tests/test_class_pythondeserialiser_all.py +570 -0
  277. xfintech/serde/serialiser/__init__.py +7 -0
  278. xfintech/serde/serialiser/pandas.py +116 -0
  279. xfintech/serde/serialiser/python.py +71 -0
  280. xfintech/serde/serialiser/tests/__init__.py +1 -0
  281. xfintech/serde/serialiser/tests/test_class_pandasserialiser_all.py +474 -0
  282. xfintech/serde/serialiser/tests/test_class_pythonserialiser_all.py +508 -0
@@ -0,0 +1,182 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Dict, List, 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.weekline.constant import (
15
+ KEY,
16
+ NAME,
17
+ PAGINATE,
18
+ SOURCE,
19
+ TARGET,
20
+ )
21
+
22
+
23
+ @JobHouse.register(KEY, alias=KEY)
24
+ class Weekline(TushareJob):
25
+ """
26
+ 描述:
27
+ - 获取A股周线行情数据
28
+ - 每周最后一个交易日更新
29
+ - 本接口是未复权行情
30
+ - 用户需要至少2000积分才可以调取
31
+ - API文档: https://tushare.pro/document/2?doc_id=144
32
+ - SCALE: CrossSection & Individual
33
+ - TYPE: Partitioned
34
+ - PAGINATE: 6000 rows / 1000 pages
35
+
36
+ 属性:
37
+ - name: str, 作业名称 'weekline'。
38
+ - key: str, 作业键 '/tushare/weekline'。
39
+ - session: Session, Tushare会话对象。
40
+ - source: TableInfo, 源表信息(Tushare原始格式)。
41
+ - target: TableInfo, 目标表信息(转换后格式)。
42
+ - params: Params, 查询参数。
43
+ - ts_code: str, 可选, 股票代码
44
+ - trade_date: str, 可选, 交易日期(YYYYMMDD)每周最后一个交易日
45
+ - start_date: str, 可选, 开始日期(YYYYMMDD)
46
+ - end_date: str, 可选, 结束日期(YYYYMMDD)
47
+ - coolant: Coolant, 请求冷却控制。
48
+ - paginate: Paginate, 分页控制(pagesize=6000, pagelimit=1000)。
49
+ - retry: Retry, 重试策略。
50
+ - cache: Cache, 缓存管理。
51
+
52
+ 方法:
53
+ - run(): 执行作业,返回周线行情DataFrame。
54
+ - _run(): 内部执行逻辑,处理日期参数。
55
+ - transform(data): 转换数据格式,将源格式转为目标格式。
56
+ - list_codes(): 返回所有股票代码列表。
57
+ - list_dates(): 返回所有交易日期列表。
58
+
59
+ 例子:
60
+ ```python
61
+ from xfintech.data.source.tushare.session import Session
62
+ from xfintech.data.source.tushare.stock.weekline import Weekline
63
+
64
+ # 创建会话
65
+ session = Session(credential="your_token")
66
+
67
+ # 获取单只股票周线数据
68
+ job = Weekline(
69
+ session=session,
70
+ params={
71
+ "ts_code": "000001.SZ",
72
+ "start_date": "20241101",
73
+ "end_date": "20241231"
74
+ }
75
+ )
76
+ df = job.run()
77
+ print(f"共 {len(df)} 条周线数据")
78
+ ```
79
+ """
80
+
81
+ def __init__(
82
+ self,
83
+ session: Session,
84
+ params: Optional[Params | Dict[str, Any]] = None,
85
+ coolant: Optional[Coolant | Dict[str, Any]] = None,
86
+ retry: Optional[Retry | Dict[str, Any]] = None,
87
+ cache: Optional[Cache | Dict[str, str] | bool] = None,
88
+ ) -> None:
89
+ super().__init__(
90
+ name=NAME,
91
+ key=KEY,
92
+ session=session,
93
+ source=SOURCE,
94
+ target=TARGET,
95
+ params=params,
96
+ coolant=coolant,
97
+ paginate=PAGINATE,
98
+ retry=retry,
99
+ cache=cache,
100
+ )
101
+
102
+ def _run(self) -> pd.DataFrame:
103
+ cached = self._load_cache()
104
+ if cached is not None:
105
+ return cached
106
+
107
+ # Prepare payload dict
108
+ payload = self.params.to_dict()
109
+ payload = self._parse_date_params(
110
+ payload,
111
+ keys=["trade_date", "start_date", "end_date"],
112
+ )
113
+ payload = self._parse_string_params(
114
+ payload,
115
+ keys=["ts_code"],
116
+ )
117
+
118
+ # Fetch and transform data
119
+ data = self._fetchall(
120
+ api=self.connection.weekly,
121
+ **payload,
122
+ )
123
+ result = self.transform(data)
124
+ self._save_cache(result)
125
+ return result
126
+
127
+ # Transform logic
128
+ def transform(
129
+ self,
130
+ data: pd.DataFrame,
131
+ ) -> pd.DataFrame:
132
+ cols = self.target.list_column_names()
133
+ if data is None or data.empty:
134
+ return pd.DataFrame(columns=cols)
135
+
136
+ out = data.copy()
137
+ out["code"] = out["ts_code"].astype(str)
138
+ out["date"] = pd.to_datetime(
139
+ out["trade_date"],
140
+ format="%Y%m%d",
141
+ errors="coerce",
142
+ ).dt.strftime("%Y-%m-%d")
143
+ out["datecode"] = out["trade_date"].astype(str)
144
+ out["percent_change"] = pd.to_numeric(
145
+ out["pct_chg"],
146
+ errors="coerce",
147
+ )
148
+ out["volume"] = pd.to_numeric(
149
+ out["vol"],
150
+ errors="coerce",
151
+ )
152
+
153
+ # Convert numeric fields
154
+ numeric_fields = [
155
+ "open",
156
+ "high",
157
+ "low",
158
+ "close",
159
+ "pre_close",
160
+ "change",
161
+ "amount",
162
+ ]
163
+ for field in numeric_fields:
164
+ out[field] = pd.to_numeric(
165
+ out[field],
166
+ errors="coerce",
167
+ )
168
+
169
+ # Finalize output
170
+ out = out[cols].drop_duplicates()
171
+ out = out.sort_values(by=["code", "date"])
172
+ out = out.reset_index(drop=True)
173
+ self.markpoint("transform[OK]")
174
+ return out
175
+
176
+ def list_codes(self) -> List[str]:
177
+ df = self.run()
178
+ return sorted(df["code"].unique().tolist())
179
+
180
+ def list_dates(self) -> List[str]:
181
+ df = self.run()
182
+ return sorted(df["date"].unique().tolist())
@@ -0,0 +1,18 @@
1
+ """
2
+ Fabric module for defining data structures with column and table information.
3
+
4
+ This module provides classes for describing data schemas:
5
+ - ColumnInfo: Metadata about individual columns (name, type, description)
6
+ - ColumnKind: Enum of supported column data types
7
+ - TableInfo: Metadata about tables and their column structure
8
+ """
9
+
10
+ from .column.info import ColumnInfo
11
+ from .column.kind import ColumnKind
12
+ from .table.info import TableInfo
13
+
14
+ __all__ = [
15
+ "ColumnInfo",
16
+ "ColumnKind",
17
+ "TableInfo",
18
+ ]
@@ -0,0 +1,7 @@
1
+ from .info import ColumnInfo
2
+ from .kind import ColumnKind
3
+
4
+ __all__ = [
5
+ "ColumnKind",
6
+ "ColumnInfo",
7
+ ]
@@ -0,0 +1,202 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ import re
6
+ from typing import Any, Dict, Optional
7
+
8
+ from xfintech.fabric.column.kind import ColumnKind
9
+
10
+
11
+ class ColumnInfo:
12
+ """
13
+ 描述:
14
+ - 列字段信息。
15
+
16
+ 参数:
17
+ - name: str, 列字段名称
18
+ - kind: ColumnKind | str, optional, 列字段数据类型。 默认为 ColumnKind.STRING。
19
+ - desc: str, optional, 列字段描述信息。 默认为""。
20
+ - meta: Dict[str, Any], optional, 列字段元数据。 默认为None。
21
+
22
+ 属性:
23
+ - name: str, 列字段名称,小写存储。
24
+ - kind: ColumnKind, 列字段数据类型。
25
+ - desc: str, 列字段描述信息。
26
+ - meta: Dict[str, Any] | None, 列字段元数据。
27
+ - identifier: str, 列字段唯一标识符,通过 SHA256 哈希生成。
28
+
29
+ 方法:
30
+ - from_dict(data): 从字典创建 ColumnInfo 实例。
31
+ - add_desc(desc): 添加或更新列字段描述信息。
32
+ - add_meta(key, value): 添加或更新列字段元数据。
33
+ - add_kind(kind): 添加或更新列字段数据类型。
34
+ - update(name, kind, desc, meta): 更新列字段信息。
35
+ - describe(): 返回列字段信息的描述字典。
36
+ - to_dict(): 返回列字段信息的字典表示。
37
+
38
+ 例子:
39
+ ```python
40
+ from xfintech.fabric.column.kind import ColumnKind
41
+ from xfintech.fabric.column.info import ColumnInfo
42
+
43
+ f = ColumnInfo(
44
+ name="price",
45
+ kind="Float",
46
+ desc="股票价格",
47
+ meta=None,
48
+ )
49
+
50
+ f2 = ColumnInfo.from_dict({
51
+ "name": "volume",
52
+ "kind": "Integer",
53
+ "desc": "交易量",
54
+ "meta": {"unit": "shares"},
55
+ })
56
+ ```
57
+ """
58
+
59
+ _NAME_PATTERN = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
60
+ _DEFAULT_KIND = ColumnKind.STRING
61
+
62
+ @classmethod
63
+ def from_dict(
64
+ cls,
65
+ data: Dict[str, Any],
66
+ ) -> ColumnInfo:
67
+ return cls(
68
+ name=data["name"],
69
+ kind=data.get("kind"),
70
+ desc=data.get("desc"),
71
+ meta=data.get("meta"),
72
+ )
73
+
74
+ def __init__(
75
+ self,
76
+ name: str,
77
+ kind: Optional[ColumnKind | str] = None,
78
+ desc: Optional[str] = None,
79
+ meta: Optional[Dict[str, Any]] = None,
80
+ ):
81
+ self.name = self._resolve_name(name)
82
+ self.kind = self._resolve_kind(kind)
83
+ self.desc = self._resolve_desc(desc)
84
+ self.meta = self._resolve_meta(meta)
85
+
86
+ def _resolve_name(
87
+ self,
88
+ value: str,
89
+ ) -> str:
90
+ if not self._NAME_PATTERN.match(value):
91
+ raise ValueError(f"Invalid column name: {value}")
92
+ return value.lower()
93
+
94
+ def _resolve_kind(
95
+ self,
96
+ value: Optional[ColumnKind | str],
97
+ ) -> ColumnKind:
98
+ if value is None:
99
+ return self._DEFAULT_KIND
100
+ if isinstance(value, ColumnKind):
101
+ return value
102
+ try:
103
+ return ColumnKind.from_str(value)
104
+ except ValueError as e:
105
+ raise ValueError(f"Invalid column kind: {value!r}") from e
106
+
107
+ def _resolve_desc(
108
+ self,
109
+ value: Optional[str],
110
+ ) -> Optional[str]:
111
+ if value is not None:
112
+ return value.strip()
113
+ else:
114
+ return ""
115
+
116
+ def _resolve_meta(
117
+ self,
118
+ meta: Optional[Dict[str, Any]],
119
+ ) -> Optional[Dict[str, Any]]:
120
+ if meta is not None:
121
+ resolved: Dict[str, Any] = {}
122
+ for k, v in meta.items():
123
+ if isinstance(v, bytes):
124
+ v = v.decode("utf8")
125
+ if isinstance(k, bytes):
126
+ k = k.decode("utf8")
127
+ resolved[k] = v
128
+ return resolved
129
+ else:
130
+ return None
131
+
132
+ @property
133
+ def identifier(self) -> str:
134
+ dna = json.dumps(
135
+ {
136
+ "name": self.name,
137
+ "kind": str(self.kind),
138
+ },
139
+ sort_keys=True,
140
+ ensure_ascii=False,
141
+ separators=(",", ":"),
142
+ )
143
+ return hashlib.sha256(dna.encode("utf-8")).hexdigest()
144
+
145
+ def __str__(self) -> str:
146
+ return f"{self.name}: {self.kind}"
147
+
148
+ def __repr__(self) -> str:
149
+ return self.to_dict().__repr__()
150
+
151
+ def add_desc(self, desc: str) -> "ColumnInfo":
152
+ self.update(desc=desc)
153
+ return self
154
+
155
+ def add_meta(self, key: str, value: Any) -> "ColumnInfo":
156
+ if self.meta is None:
157
+ self.meta = {}
158
+ self.meta[key] = value
159
+ return self
160
+
161
+ def add_kind(self, kind: ColumnKind | str) -> "ColumnInfo":
162
+ self.update(kind=kind)
163
+ return self
164
+
165
+ def update(
166
+ self,
167
+ name: Optional[str] = None,
168
+ kind: Optional[ColumnKind | str] = None,
169
+ desc: Optional[str] = None,
170
+ meta: Optional[Dict[str, Any]] = None,
171
+ ) -> "ColumnInfo":
172
+ if name is not None:
173
+ self.name = self._resolve_name(name)
174
+ if kind is not None:
175
+ self.kind = self._resolve_kind(kind)
176
+ if desc is not None:
177
+ self.desc = self._resolve_desc(desc)
178
+ if meta is not None:
179
+ if self.meta is None:
180
+ self.meta = {}
181
+ self.meta.update(self._resolve_meta(meta))
182
+ return self
183
+
184
+ def describe(self) -> Dict[str, Any]:
185
+ result = {
186
+ "name": self.name,
187
+ "kind": str(self.kind),
188
+ }
189
+ if self.desc:
190
+ result["desc"] = self.desc
191
+ if self.meta:
192
+ result["meta"] = self.meta
193
+ return result
194
+
195
+ def to_dict(self) -> Dict[str, Any]:
196
+ return {
197
+ "identifier": self.identifier,
198
+ "name": self.name,
199
+ "kind": str(self.kind),
200
+ "desc": self.desc,
201
+ "meta": self.meta,
202
+ }
@@ -0,0 +1,102 @@
1
+ from __future__ import annotations
2
+
3
+ from enum import Enum
4
+ from typing import Any
5
+
6
+
7
+ class ColumnKind(str, Enum):
8
+ """
9
+ 描述:
10
+ - 列字段数据类型枚举类。
11
+
12
+ 参数:
13
+ - INTEGER: 整数类型
14
+ - FLOAT: 浮点数类型
15
+ - STRING: 字符串类型(默认类型,未知类型将使用此类型)
16
+ - BOOLEAN: 布尔类型
17
+ - CATEGORICAL: 类别类型
18
+ - DATETIME: 日期时间类型
19
+ - DATE: 日期类型
20
+
21
+ 属性:
22
+ - value: str, 列字段数据类型的字符串表示。
23
+ - name: str, 列字段数据类型的名称。
24
+
25
+ 方法:
26
+ - _missing_(value): 处理缺失值,支持不区分大小写的字符串匹配。
27
+ - from_any(value): 从任意类型创建 ColumnKind 实例。
28
+ - from_str(string): 从字符串创建 ColumnKind 实例(不区分大小写)。
29
+ - __str__(): 返回列字段数据类型的字符串表示。
30
+ - __repr__(): 返回列字段数据类型的表示形式。
31
+ - __eq__(other): 支持与字符串的比较(不区分大小写)。
32
+ - __ne__(value): 不等于比较。
33
+
34
+ 例子:
35
+ ```python
36
+ from xfintech.fabric.column.kind import ColumnKind
37
+
38
+ # 使用枚举值
39
+ kind = ColumnKind.INTEGER
40
+ print(kind) # Integer
41
+ print(repr(kind)) # ColumnKind.INTEGER
42
+
43
+ # 从字符串创建(不区分大小写)
44
+ kind = ColumnKind.from_str("float")
45
+ print(kind) # Float
46
+
47
+ kind = ColumnKind.from_str("STRING")
48
+ print(kind) # String
49
+
50
+ # 从任意类型创建
51
+ kind = ColumnKind.from_any("boolean")
52
+ print(kind) # Boolean
53
+
54
+ kind = ColumnKind.from_any(ColumnKind.CATEGORICAL)
55
+ print(kind) # Categorical
56
+ ```
57
+ """
58
+
59
+ INTEGER = "Integer"
60
+ FLOAT = "Float"
61
+ STRING = "String"
62
+ BOOLEAN = "Boolean"
63
+ CATEGORICAL = "Categorical"
64
+ DATETIME = "Datetime"
65
+ DATE = "Date"
66
+
67
+ @classmethod
68
+ def _missing_(cls, value):
69
+ if isinstance(value, str):
70
+ for member in cls:
71
+ if member.value.lower() == value.lower():
72
+ return member
73
+ return ColumnKind.STRING
74
+
75
+ @classmethod
76
+ def from_str(cls, string: str) -> ColumnKind:
77
+ for dkind in ColumnKind:
78
+ if dkind.value.lower() == string.lower():
79
+ return dkind
80
+ return ColumnKind.STRING
81
+
82
+ @classmethod
83
+ def from_any(cls, value: Any) -> ColumnKind:
84
+ if isinstance(value, ColumnKind):
85
+ return value
86
+ if isinstance(value, str):
87
+ return cls.from_str(value)
88
+ return ColumnKind.STRING
89
+
90
+ def __str__(self) -> str:
91
+ return self.value
92
+
93
+ def __repr__(self) -> str:
94
+ return f"{self.__class__.__name__}.{self.name}"
95
+
96
+ def __eq__(self, other) -> bool:
97
+ if isinstance(other, str):
98
+ return self.value.lower() == other.lower()
99
+ return super().__eq__(other)
100
+
101
+ def __ne__(self, value):
102
+ return not self.__eq__(value)
File without changes