@v587d/capital-generation 2.28.0 → 2.30.0
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.
- package/CHANGELOG.md +59 -0
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/collector-runtime.js +56 -1
- package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
- package/lib/data-collector/catalog-taxonomy.js +33 -0
- package/lib/data-collector/tools.js +7 -7
- package/lib/host-version.d.ts +9 -0
- package/lib/host-version.js +57 -0
- package/lib/python-runtime/errors.d.ts +1 -1
- package/lib/python-runtime/errors.js +2 -0
- package/lib/python-runtime/manager.d.ts +28 -1
- package/lib/python-runtime/manager.js +141 -5
- package/lib/python-runtime/probe.d.ts +24 -0
- package/lib/python-runtime/probe.js +66 -50
- package/lib/runtime-entry.js +8 -0
- package/lib/sources/csindex-http.d.ts +4 -0
- package/lib/sources/csindex-http.js +233 -0
- package/lib/sources/eastmoney-http.js +1504 -1
- package/lib/sources/fuyao-rest.js +168 -8
- package/lib/sources/official-http.d.ts +4 -0
- package/lib/sources/official-http.js +477 -0
- package/lib/sources/python-remote.d.ts +25 -0
- package/lib/sources/python-remote.js +461 -0
- package/lib/sources/sina-http.d.ts +2 -0
- package/lib/sources/sina-http.js +484 -0
- package/lib/sources/tencent-http.js +23 -8
- package/lib/sources/ths-http.d.ts +2 -0
- package/lib/sources/ths-http.js +514 -0
- package/lib/time/tools.js +19 -0
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/sources.d.ts +7 -0
- package/lib/web-retriever/sources.js +46 -21
- package/lib/web-retriever/throttle.d.ts +8 -0
- package/lib/web-retriever/throttle.js +13 -0
- package/lib/web-retriever/tools.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +6 -3
- package/preset/capital-generation/agent.patch.yml +7 -5
- package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
- package/python/scripts/baostock_stock_basic.py +129 -0
- package/python/scripts/baostock_valuation_history.py +141 -0
- package/python/scripts/pbc_social_financing.py +291 -0
- package/python/vendor/baostock/LICENSE +19 -0
- package/python/vendor/baostock/__init__.py +42 -0
- package/python/vendor/baostock/common/__init__.py +0 -0
- package/python/vendor/baostock/common/contants.py +189 -0
- package/python/vendor/baostock/common/context.py +4 -0
- package/python/vendor/baostock/corpreport/__init__.py +0 -0
- package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
- package/python/vendor/baostock/data/__init__.py +0 -0
- package/python/vendor/baostock/data/messageheader.py +17 -0
- package/python/vendor/baostock/data/msg.py +21 -0
- package/python/vendor/baostock/data/resultset.py +200 -0
- package/python/vendor/baostock/demo/__init__.py +0 -0
- package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
- package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
- package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
- package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
- package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
- package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
- package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
- package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
- package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
- package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
- package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
- package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
- package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
- package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
- package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
- package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
- package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
- package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
- package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
- package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
- package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
- package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
- package/python/vendor/baostock/evaluation/__init__.py +0 -0
- package/python/vendor/baostock/evaluation/season_index.py +758 -0
- package/python/vendor/baostock/login/__init__.py +0 -0
- package/python/vendor/baostock/login/loginout.py +230 -0
- package/python/vendor/baostock/macroscopic/__init__.py +0 -0
- package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
- package/python/vendor/baostock/metadata/__init__.py +0 -0
- package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
- package/python/vendor/baostock/security/__init__.py +0 -0
- package/python/vendor/baostock/security/history.py +265 -0
- package/python/vendor/baostock/security/sectorinfo.py +1024 -0
- package/python/vendor/baostock/util/__init__.py +0 -0
- package/python/vendor/baostock/util/socketutil.py +97 -0
- package/python/vendor/baostock/util/stringutil.py +83 -0
- package/python/vendor/et_xmlfile/LICENSE +23 -0
- package/python/vendor/et_xmlfile/LICENSE.python +298 -0
- package/python/vendor/et_xmlfile/__init__.py +8 -0
- package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
- package/python/vendor/et_xmlfile/xmlfile.py +158 -0
- package/python/vendor/openpyxl/LICENSE +23 -0
- package/python/vendor/openpyxl/__init__.py +19 -0
- package/python/vendor/openpyxl/_constants.py +13 -0
- package/python/vendor/openpyxl/cell/__init__.py +4 -0
- package/python/vendor/openpyxl/cell/_writer.py +136 -0
- package/python/vendor/openpyxl/cell/cell.py +332 -0
- package/python/vendor/openpyxl/cell/read_only.py +136 -0
- package/python/vendor/openpyxl/cell/rich_text.py +202 -0
- package/python/vendor/openpyxl/cell/text.py +184 -0
- package/python/vendor/openpyxl/chart/_3d.py +105 -0
- package/python/vendor/openpyxl/chart/__init__.py +19 -0
- package/python/vendor/openpyxl/chart/_chart.py +199 -0
- package/python/vendor/openpyxl/chart/area_chart.py +106 -0
- package/python/vendor/openpyxl/chart/axis.py +401 -0
- package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
- package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
- package/python/vendor/openpyxl/chart/chartspace.py +195 -0
- package/python/vendor/openpyxl/chart/data_source.py +246 -0
- package/python/vendor/openpyxl/chart/descriptors.py +43 -0
- package/python/vendor/openpyxl/chart/error_bar.py +62 -0
- package/python/vendor/openpyxl/chart/label.py +127 -0
- package/python/vendor/openpyxl/chart/layout.py +74 -0
- package/python/vendor/openpyxl/chart/legend.py +75 -0
- package/python/vendor/openpyxl/chart/line_chart.py +129 -0
- package/python/vendor/openpyxl/chart/marker.py +90 -0
- package/python/vendor/openpyxl/chart/picture.py +35 -0
- package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
- package/python/vendor/openpyxl/chart/pivot.py +65 -0
- package/python/vendor/openpyxl/chart/plotarea.py +162 -0
- package/python/vendor/openpyxl/chart/print_settings.py +57 -0
- package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
- package/python/vendor/openpyxl/chart/reader.py +32 -0
- package/python/vendor/openpyxl/chart/reference.py +124 -0
- package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
- package/python/vendor/openpyxl/chart/series.py +197 -0
- package/python/vendor/openpyxl/chart/series_factory.py +41 -0
- package/python/vendor/openpyxl/chart/shapes.py +89 -0
- package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
- package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
- package/python/vendor/openpyxl/chart/text.py +78 -0
- package/python/vendor/openpyxl/chart/title.py +76 -0
- package/python/vendor/openpyxl/chart/trendline.py +98 -0
- package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
- package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
- package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
- package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
- package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
- package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
- package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
- package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
- package/python/vendor/openpyxl/chartsheet/views.py +51 -0
- package/python/vendor/openpyxl/comments/__init__.py +4 -0
- package/python/vendor/openpyxl/comments/author.py +21 -0
- package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
- package/python/vendor/openpyxl/comments/comments.py +62 -0
- package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
- package/python/vendor/openpyxl/compat/__init__.py +54 -0
- package/python/vendor/openpyxl/compat/abc.py +8 -0
- package/python/vendor/openpyxl/compat/numbers.py +43 -0
- package/python/vendor/openpyxl/compat/product.py +17 -0
- package/python/vendor/openpyxl/compat/singleton.py +40 -0
- package/python/vendor/openpyxl/compat/strings.py +25 -0
- package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
- package/python/vendor/openpyxl/descriptors/base.py +272 -0
- package/python/vendor/openpyxl/descriptors/container.py +41 -0
- package/python/vendor/openpyxl/descriptors/excel.py +112 -0
- package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
- package/python/vendor/openpyxl/descriptors/nested.py +129 -0
- package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
- package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
- package/python/vendor/openpyxl/descriptors/slots.py +18 -0
- package/python/vendor/openpyxl/drawing/__init__.py +4 -0
- package/python/vendor/openpyxl/drawing/colors.py +435 -0
- package/python/vendor/openpyxl/drawing/connector.py +144 -0
- package/python/vendor/openpyxl/drawing/drawing.py +92 -0
- package/python/vendor/openpyxl/drawing/effect.py +407 -0
- package/python/vendor/openpyxl/drawing/fill.py +425 -0
- package/python/vendor/openpyxl/drawing/geometry.py +584 -0
- package/python/vendor/openpyxl/drawing/graphic.py +177 -0
- package/python/vendor/openpyxl/drawing/image.py +65 -0
- package/python/vendor/openpyxl/drawing/line.py +144 -0
- package/python/vendor/openpyxl/drawing/picture.py +144 -0
- package/python/vendor/openpyxl/drawing/properties.py +174 -0
- package/python/vendor/openpyxl/drawing/relation.py +17 -0
- package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
- package/python/vendor/openpyxl/drawing/text.py +717 -0
- package/python/vendor/openpyxl/drawing/xdr.py +33 -0
- package/python/vendor/openpyxl/formatting/__init__.py +3 -0
- package/python/vendor/openpyxl/formatting/formatting.py +114 -0
- package/python/vendor/openpyxl/formatting/rule.py +291 -0
- package/python/vendor/openpyxl/formula/__init__.py +3 -0
- package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
- package/python/vendor/openpyxl/formula/translate.py +166 -0
- package/python/vendor/openpyxl/packaging/__init__.py +3 -0
- package/python/vendor/openpyxl/packaging/core.py +115 -0
- package/python/vendor/openpyxl/packaging/custom.py +289 -0
- package/python/vendor/openpyxl/packaging/extended.py +137 -0
- package/python/vendor/openpyxl/packaging/interface.py +56 -0
- package/python/vendor/openpyxl/packaging/manifest.py +194 -0
- package/python/vendor/openpyxl/packaging/relationship.py +158 -0
- package/python/vendor/openpyxl/packaging/workbook.py +185 -0
- package/python/vendor/openpyxl/pivot/__init__.py +1 -0
- package/python/vendor/openpyxl/pivot/cache.py +965 -0
- package/python/vendor/openpyxl/pivot/fields.py +326 -0
- package/python/vendor/openpyxl/pivot/record.py +111 -0
- package/python/vendor/openpyxl/pivot/table.py +1261 -0
- package/python/vendor/openpyxl/reader/__init__.py +1 -0
- package/python/vendor/openpyxl/reader/drawings.py +71 -0
- package/python/vendor/openpyxl/reader/excel.py +349 -0
- package/python/vendor/openpyxl/reader/strings.py +44 -0
- package/python/vendor/openpyxl/reader/workbook.py +133 -0
- package/python/vendor/openpyxl/styles/__init__.py +11 -0
- package/python/vendor/openpyxl/styles/alignment.py +62 -0
- package/python/vendor/openpyxl/styles/borders.py +103 -0
- package/python/vendor/openpyxl/styles/builtins.py +1397 -0
- package/python/vendor/openpyxl/styles/cell_style.py +206 -0
- package/python/vendor/openpyxl/styles/colors.py +172 -0
- package/python/vendor/openpyxl/styles/differential.py +95 -0
- package/python/vendor/openpyxl/styles/fills.py +224 -0
- package/python/vendor/openpyxl/styles/fonts.py +113 -0
- package/python/vendor/openpyxl/styles/named_styles.py +282 -0
- package/python/vendor/openpyxl/styles/numbers.py +200 -0
- package/python/vendor/openpyxl/styles/protection.py +17 -0
- package/python/vendor/openpyxl/styles/proxy.py +62 -0
- package/python/vendor/openpyxl/styles/styleable.py +151 -0
- package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
- package/python/vendor/openpyxl/styles/table.py +94 -0
- package/python/vendor/openpyxl/utils/__init__.py +17 -0
- package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
- package/python/vendor/openpyxl/utils/cell.py +240 -0
- package/python/vendor/openpyxl/utils/dataframe.py +87 -0
- package/python/vendor/openpyxl/utils/datetime.py +140 -0
- package/python/vendor/openpyxl/utils/escape.py +43 -0
- package/python/vendor/openpyxl/utils/exceptions.py +34 -0
- package/python/vendor/openpyxl/utils/formulas.py +24 -0
- package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
- package/python/vendor/openpyxl/utils/inference.py +60 -0
- package/python/vendor/openpyxl/utils/protection.py +22 -0
- package/python/vendor/openpyxl/utils/units.py +108 -0
- package/python/vendor/openpyxl/workbook/__init__.py +4 -0
- package/python/vendor/openpyxl/workbook/_writer.py +197 -0
- package/python/vendor/openpyxl/workbook/child.py +166 -0
- package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
- package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
- package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
- package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
- package/python/vendor/openpyxl/workbook/function_group.py +36 -0
- package/python/vendor/openpyxl/workbook/properties.py +151 -0
- package/python/vendor/openpyxl/workbook/protection.py +163 -0
- package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
- package/python/vendor/openpyxl/workbook/views.py +155 -0
- package/python/vendor/openpyxl/workbook/web.py +98 -0
- package/python/vendor/openpyxl/workbook/workbook.py +438 -0
- package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
- package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
- package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
- package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
- package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
- package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
- package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
- package/python/vendor/openpyxl/worksheet/controls.py +107 -0
- package/python/vendor/openpyxl/worksheet/copier.py +70 -0
- package/python/vendor/openpyxl/worksheet/custom.py +35 -0
- package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
- package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
- package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
- package/python/vendor/openpyxl/worksheet/errors.py +93 -0
- package/python/vendor/openpyxl/worksheet/filters.py +486 -0
- package/python/vendor/openpyxl/worksheet/formula.py +51 -0
- package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
- package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
- package/python/vendor/openpyxl/worksheet/merge.py +141 -0
- package/python/vendor/openpyxl/worksheet/ole.py +133 -0
- package/python/vendor/openpyxl/worksheet/page.py +174 -0
- package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
- package/python/vendor/openpyxl/worksheet/picture.py +8 -0
- package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
- package/python/vendor/openpyxl/worksheet/properties.py +97 -0
- package/python/vendor/openpyxl/worksheet/protection.py +120 -0
- package/python/vendor/openpyxl/worksheet/related.py +17 -0
- package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
- package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
- package/python/vendor/openpyxl/worksheet/table.py +385 -0
- package/python/vendor/openpyxl/worksheet/views.py +155 -0
- package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
- package/python/vendor/openpyxl/writer/__init__.py +1 -0
- package/python/vendor/openpyxl/writer/excel.py +295 -0
- package/python/vendor/openpyxl/writer/theme.py +291 -0
- package/python/vendor/openpyxl/xml/__init__.py +42 -0
- package/python/vendor/openpyxl/xml/constants.py +129 -0
- package/python/vendor/openpyxl/xml/functions.py +87 -0
- package/watchlist/package.json +1 -1
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
估值指标,季频
|
|
4
|
+
@author: baostock.com
|
|
5
|
+
@group : baostock.com
|
|
6
|
+
@contact: baostock@163.com
|
|
7
|
+
@copyright: baostock System & alpha.All Rights Reserved.
|
|
8
|
+
"""
|
|
9
|
+
import time
|
|
10
|
+
import zlib
|
|
11
|
+
import baostock.data.resultset as rs
|
|
12
|
+
import baostock.common.contants as cons
|
|
13
|
+
import baostock.util.stringutil as strUtil
|
|
14
|
+
import baostock.common.context as conx
|
|
15
|
+
import baostock.util.socketutil as sock
|
|
16
|
+
import baostock.data.messageheader as msgheader
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def query_dividend_data(code, year=None, yearType="report"):
|
|
20
|
+
"""估值指标(季频),股息分红
|
|
21
|
+
@param code: 证券代码,不可为空
|
|
22
|
+
@param year: 年份,为空时默认当前年份
|
|
23
|
+
@param yearType: 年份类别,默认为"report":预案公告年份,可选项"operate":除权除息年份
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
data = rs.ResultData()
|
|
27
|
+
|
|
28
|
+
if code is None or code == "":
|
|
29
|
+
print("股票代码不能为空,请检查。")
|
|
30
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
31
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
32
|
+
return data
|
|
33
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
34
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
35
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
36
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
37
|
+
return data
|
|
38
|
+
code = code.lower()
|
|
39
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
40
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
41
|
+
|
|
42
|
+
if year is None or year == "":
|
|
43
|
+
year = time.strftime("%Y", time.localtime())
|
|
44
|
+
if yearType is None or yearType == "":
|
|
45
|
+
print("年份类别输入有误,请修改。")
|
|
46
|
+
data.error_msg = "年份类别输入有误,请修改。"
|
|
47
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
48
|
+
return data
|
|
49
|
+
year = str(year)
|
|
50
|
+
if not year.isdigit():
|
|
51
|
+
print("年份输入有误,请修改。")
|
|
52
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
53
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
54
|
+
return data
|
|
55
|
+
|
|
56
|
+
user_id = ""
|
|
57
|
+
try:
|
|
58
|
+
user_id = getattr(conx, "user_id")
|
|
59
|
+
except Exception:
|
|
60
|
+
print("you don't login.")
|
|
61
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
62
|
+
data.error_msg = "you don't login."
|
|
63
|
+
return data
|
|
64
|
+
|
|
65
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
66
|
+
"query_dividend_data", user_id, "1",
|
|
67
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, yearType)
|
|
68
|
+
|
|
69
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
70
|
+
msg_header = msgheader.to_message_header(
|
|
71
|
+
cons.MESSAGE_TYPE_QUERYDIVIDENDDATA_REQUEST, len(msg_body))
|
|
72
|
+
|
|
73
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYDIVIDENDDATA_REQUEST
|
|
74
|
+
data.msg_body = msg_body
|
|
75
|
+
|
|
76
|
+
head_body = msg_header + msg_body
|
|
77
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
78
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
79
|
+
|
|
80
|
+
if receive_data is None or receive_data.strip() == "":
|
|
81
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
82
|
+
data.error_msg = "网络接收错误。"
|
|
83
|
+
return data
|
|
84
|
+
|
|
85
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
86
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
87
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
88
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
89
|
+
data.msg_body_length = header_arr[2]
|
|
90
|
+
data.error_code = body_arr[0]
|
|
91
|
+
data.error_msg = body_arr[1]
|
|
92
|
+
|
|
93
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
94
|
+
data.method = body_arr[2]
|
|
95
|
+
data.user_id = body_arr[3]
|
|
96
|
+
data.cur_page_num = body_arr[4]
|
|
97
|
+
data.per_page_count = body_arr[5]
|
|
98
|
+
data.setData(body_arr[6])
|
|
99
|
+
data.code = body_arr[7]
|
|
100
|
+
data.year = body_arr[8]
|
|
101
|
+
data.yearType = body_arr[9]
|
|
102
|
+
data.setFields(body_arr[10])
|
|
103
|
+
|
|
104
|
+
return data
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def query_adjust_factor(code, start_date=None, end_date=None):
|
|
108
|
+
"""复权因子信息
|
|
109
|
+
@param code: 证券代码,不可为空
|
|
110
|
+
@param start_date: 起始除权除息日期,为空时默认2015-01-01)
|
|
111
|
+
@param end_date: 终止除权除息日期,为空时默认当前时间
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
data = rs.ResultData()
|
|
115
|
+
|
|
116
|
+
if code is None or code == "":
|
|
117
|
+
print("股票代码不能为空,请检查。")
|
|
118
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
119
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
120
|
+
return data
|
|
121
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
122
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000")
|
|
123
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000"
|
|
124
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
125
|
+
return data
|
|
126
|
+
code = code.lower()
|
|
127
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
128
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
129
|
+
|
|
130
|
+
if start_date is None or start_date == "":
|
|
131
|
+
start_date = cons.DEFAULT_START_DATE
|
|
132
|
+
if end_date is None or end_date == "":
|
|
133
|
+
end_date = time.strftime("%Y-%m-%d", time.localtime())
|
|
134
|
+
|
|
135
|
+
user_id = ""
|
|
136
|
+
try:
|
|
137
|
+
user_id = getattr(conx, "user_id")
|
|
138
|
+
except Exception:
|
|
139
|
+
print("you don't login.")
|
|
140
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
141
|
+
data.error_msg = "you don't login."
|
|
142
|
+
return data
|
|
143
|
+
|
|
144
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
145
|
+
"query_adjust_factor", user_id, "1",
|
|
146
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, start_date, end_date)
|
|
147
|
+
|
|
148
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
149
|
+
msg_header = msgheader.to_message_header(
|
|
150
|
+
cons.MESSAGE_TYPE_ADJUSTFACTOR_REQUEST, len(msg_body))
|
|
151
|
+
|
|
152
|
+
data.msg_type = cons.MESSAGE_TYPE_ADJUSTFACTOR_REQUEST
|
|
153
|
+
data.msg_body = msg_body
|
|
154
|
+
|
|
155
|
+
head_body = msg_header + msg_body
|
|
156
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
157
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
158
|
+
|
|
159
|
+
if receive_data is None or receive_data.strip() == "":
|
|
160
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
161
|
+
data.error_msg = "网络接收错误。"
|
|
162
|
+
return data
|
|
163
|
+
|
|
164
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
165
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
166
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
167
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
168
|
+
data.msg_body_length = header_arr[2]
|
|
169
|
+
data.error_code = body_arr[0]
|
|
170
|
+
data.error_msg = body_arr[1]
|
|
171
|
+
|
|
172
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
173
|
+
data.method = body_arr[2]
|
|
174
|
+
data.user_id = body_arr[3]
|
|
175
|
+
data.cur_page_num = body_arr[4]
|
|
176
|
+
data.per_page_count = body_arr[5]
|
|
177
|
+
data.setData(body_arr[6])
|
|
178
|
+
data.code = body_arr[7] # 股票代码
|
|
179
|
+
data.start_date = body_arr[8]
|
|
180
|
+
data.end_date = body_arr[9]
|
|
181
|
+
data.setFields(body_arr[10])
|
|
182
|
+
|
|
183
|
+
return data
|
|
184
|
+
|
|
185
|
+
def query_daily_adjust_factor(date=None):
|
|
186
|
+
"""获取某日复权因子信息
|
|
187
|
+
@param date: 指定日期,为空时默认当前日
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
if date is None or date == "":
|
|
191
|
+
date = time.strftime("%Y-%m-%d", time.localtime())
|
|
192
|
+
|
|
193
|
+
data = rs.ResultData()
|
|
194
|
+
user_id = ""
|
|
195
|
+
try:
|
|
196
|
+
user_id = getattr(conx, "user_id")
|
|
197
|
+
except Exception:
|
|
198
|
+
print("you don't login.")
|
|
199
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
200
|
+
data.error_msg = "you don't login."
|
|
201
|
+
return data
|
|
202
|
+
|
|
203
|
+
param = "%s,%s,%s" % ("query_daily_adjust_factor", user_id, date)
|
|
204
|
+
|
|
205
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
206
|
+
msg_header = msgheader.to_message_header(
|
|
207
|
+
cons.MESSAGE_TYPE_GETKDaily_ADJUSTFACTOR_REQUEST, len(msg_body))
|
|
208
|
+
|
|
209
|
+
data.msg_type = cons.MESSAGE_TYPE_GETKDaily_ADJUSTFACTOR_REQUEST
|
|
210
|
+
data.msg_body = msg_body
|
|
211
|
+
|
|
212
|
+
head_body = msg_header + msg_body
|
|
213
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
214
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
215
|
+
|
|
216
|
+
if receive_data is None or receive_data.strip() == "":
|
|
217
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
218
|
+
data.error_msg = "网络接收错误。"
|
|
219
|
+
return data
|
|
220
|
+
|
|
221
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
222
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:len(receive_data)]
|
|
223
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
224
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
225
|
+
data.msg_body_length = header_arr[2]
|
|
226
|
+
data.error_code = body_arr[0]
|
|
227
|
+
data.error_msg = body_arr[1]
|
|
228
|
+
|
|
229
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
230
|
+
data.method = body_arr[2]
|
|
231
|
+
data.user_id = body_arr[3]
|
|
232
|
+
# data.cur_page_num = body_arr[4]
|
|
233
|
+
# data.per_page_count = body_arr[5]
|
|
234
|
+
data.cur_page_num = '1' #起始第一条记录开始
|
|
235
|
+
data.per_page_count = '20000' #当前query_daily_adjust_factor查询不进行分页查询处理,所有设置一页最多20000条记录。
|
|
236
|
+
data.setData(body_arr[4])
|
|
237
|
+
# data.code = body_arr[7] # 股票代码
|
|
238
|
+
# data.start_date = body_arr[8]
|
|
239
|
+
# data.end_date = body_arr[9]
|
|
240
|
+
data.setFields(body_arr[5])
|
|
241
|
+
data.date = date
|
|
242
|
+
|
|
243
|
+
return data
|
|
244
|
+
|
|
245
|
+
def query_profit_data(code, year=None, quarter=None):
|
|
246
|
+
"""季频盈利能力
|
|
247
|
+
@param code: 证券代码,不可为空
|
|
248
|
+
@param year: 统计年份,为空时默认当前年
|
|
249
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
250
|
+
"""
|
|
251
|
+
data = rs.ResultData()
|
|
252
|
+
if code is None or code == "":
|
|
253
|
+
print("股票代码不能为空,请检查。")
|
|
254
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
255
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
256
|
+
return data
|
|
257
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
258
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
259
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
260
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
261
|
+
return data
|
|
262
|
+
code = code.lower()
|
|
263
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
264
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
265
|
+
|
|
266
|
+
if year is None or year == "":
|
|
267
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
268
|
+
if quarter is None or quarter == "":
|
|
269
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
270
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
271
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
272
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
273
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
274
|
+
year = str(year)
|
|
275
|
+
if not year.isdigit():
|
|
276
|
+
print("年份输入有误,请修改。")
|
|
277
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
278
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
279
|
+
return data
|
|
280
|
+
|
|
281
|
+
user_id = ""
|
|
282
|
+
try:
|
|
283
|
+
user_id = getattr(conx, "user_id")
|
|
284
|
+
except Exception:
|
|
285
|
+
print("you don't login.")
|
|
286
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
287
|
+
data.error_msg = "you don't login."
|
|
288
|
+
return data
|
|
289
|
+
|
|
290
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
291
|
+
"query_profit_data", user_id, "1",
|
|
292
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
293
|
+
|
|
294
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
295
|
+
msg_header = msgheader.to_message_header(
|
|
296
|
+
cons.MESSAGE_TYPE_PROFITDATA_REQUEST, len(msg_body))
|
|
297
|
+
|
|
298
|
+
data.msg_type = cons.MESSAGE_TYPE_PROFITDATA_REQUEST
|
|
299
|
+
data.msg_body = msg_body
|
|
300
|
+
|
|
301
|
+
head_body = msg_header + msg_body
|
|
302
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
303
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
304
|
+
|
|
305
|
+
if receive_data is None or receive_data.strip() == "":
|
|
306
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
307
|
+
data.error_msg = "网络接收错误。"
|
|
308
|
+
return data
|
|
309
|
+
|
|
310
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
311
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
312
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
313
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
314
|
+
data.msg_body_length = header_arr[2]
|
|
315
|
+
data.error_code = body_arr[0]
|
|
316
|
+
data.error_msg = body_arr[1]
|
|
317
|
+
|
|
318
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
319
|
+
data.method = body_arr[2]
|
|
320
|
+
data.user_id = body_arr[3]
|
|
321
|
+
data.cur_page_num = body_arr[4]
|
|
322
|
+
data.per_page_count = body_arr[5]
|
|
323
|
+
data.setData(body_arr[6])
|
|
324
|
+
data.code = body_arr[7]
|
|
325
|
+
data.year = body_arr[8]
|
|
326
|
+
data.quarter = body_arr[9]
|
|
327
|
+
data.setFields(body_arr[10])
|
|
328
|
+
return data
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def query_operation_data(code, year=None, quarter=None):
|
|
332
|
+
"""季频营运能力
|
|
333
|
+
@param code: 证券代码,不可为空
|
|
334
|
+
@param year: 统计年份,为空时默认当前年
|
|
335
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
336
|
+
"""
|
|
337
|
+
data = rs.ResultData()
|
|
338
|
+
if code is None or code == "":
|
|
339
|
+
print("股票代码不能为空,请检查。")
|
|
340
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
341
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
342
|
+
return data
|
|
343
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
344
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
345
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
346
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
347
|
+
return data
|
|
348
|
+
code = code.lower()
|
|
349
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
350
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
351
|
+
|
|
352
|
+
if year is None or year == "":
|
|
353
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
354
|
+
if quarter is None or quarter == "":
|
|
355
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
356
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
357
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
358
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
359
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
360
|
+
year = str(year)
|
|
361
|
+
if not year.isdigit():
|
|
362
|
+
print("年份输入有误,请修改。")
|
|
363
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
364
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
365
|
+
return data
|
|
366
|
+
|
|
367
|
+
user_id = ""
|
|
368
|
+
try:
|
|
369
|
+
user_id = getattr(conx, "user_id")
|
|
370
|
+
except Exception:
|
|
371
|
+
print("you don't login.")
|
|
372
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
373
|
+
data.error_msg = "you don't login."
|
|
374
|
+
return data
|
|
375
|
+
|
|
376
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
377
|
+
"query_operation_data", user_id, "1",
|
|
378
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
379
|
+
|
|
380
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
381
|
+
msg_header = msgheader.to_message_header(
|
|
382
|
+
cons.MESSAGE_TYPE_OPERATIONDATA_REQUEST, len(msg_body))
|
|
383
|
+
|
|
384
|
+
data.msg_type = cons.MESSAGE_TYPE_OPERATIONDATA_REQUEST
|
|
385
|
+
data.msg_body = msg_body
|
|
386
|
+
|
|
387
|
+
head_body = msg_header + msg_body
|
|
388
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
389
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
390
|
+
|
|
391
|
+
if receive_data is None or receive_data.strip() == "":
|
|
392
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
393
|
+
data.error_msg = "网络接收错误。"
|
|
394
|
+
return data
|
|
395
|
+
|
|
396
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
397
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
398
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
399
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
400
|
+
data.msg_body_length = header_arr[2]
|
|
401
|
+
data.error_code = body_arr[0]
|
|
402
|
+
data.error_msg = body_arr[1]
|
|
403
|
+
|
|
404
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
405
|
+
data.method = body_arr[2]
|
|
406
|
+
data.user_id = body_arr[3]
|
|
407
|
+
data.cur_page_num = body_arr[4]
|
|
408
|
+
data.per_page_count = body_arr[5]
|
|
409
|
+
data.setData(body_arr[6])
|
|
410
|
+
data.code = body_arr[7]
|
|
411
|
+
data.year = body_arr[8]
|
|
412
|
+
data.quarter = body_arr[9]
|
|
413
|
+
data.setFields(body_arr[10])
|
|
414
|
+
return data
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def query_growth_data(code, year=None, quarter=None):
|
|
418
|
+
"""季频成长能力
|
|
419
|
+
@param code: 证券代码,不可为空
|
|
420
|
+
@param year: 统计年份,为空时默认当前年
|
|
421
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
422
|
+
"""
|
|
423
|
+
data = rs.ResultData()
|
|
424
|
+
if code is None or code == "":
|
|
425
|
+
print("股票代码不能为空,请检查。")
|
|
426
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
427
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
428
|
+
return data
|
|
429
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
430
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
431
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
432
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
433
|
+
return data
|
|
434
|
+
code = code.lower()
|
|
435
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
436
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
437
|
+
|
|
438
|
+
if year is None or year == "":
|
|
439
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
440
|
+
if quarter is None or quarter == "":
|
|
441
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
442
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
443
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
444
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
445
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
446
|
+
year = str(year)
|
|
447
|
+
if not year.isdigit():
|
|
448
|
+
print("年份输入有误,请修改。")
|
|
449
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
450
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
451
|
+
return data
|
|
452
|
+
|
|
453
|
+
user_id = ""
|
|
454
|
+
try:
|
|
455
|
+
user_id = getattr(conx, "user_id")
|
|
456
|
+
except Exception:
|
|
457
|
+
print("you don't login.")
|
|
458
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
459
|
+
data.error_msg = "you don't login."
|
|
460
|
+
return data
|
|
461
|
+
|
|
462
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
463
|
+
"query_growth_data", user_id, "1",
|
|
464
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
465
|
+
|
|
466
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
467
|
+
msg_header = msgheader.to_message_header(
|
|
468
|
+
cons.MESSAGE_TYPE_QUERYGROWTHDATA_REQUEST, len(msg_body))
|
|
469
|
+
|
|
470
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYGROWTHDATA_REQUEST
|
|
471
|
+
data.msg_body = msg_body
|
|
472
|
+
|
|
473
|
+
head_body = msg_header + msg_body
|
|
474
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
475
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
476
|
+
|
|
477
|
+
if receive_data is None or receive_data.strip() == "":
|
|
478
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
479
|
+
data.error_msg = "网络接收错误。"
|
|
480
|
+
return data
|
|
481
|
+
|
|
482
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
483
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
484
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
485
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
486
|
+
data.msg_body_length = header_arr[2]
|
|
487
|
+
data.error_code = body_arr[0]
|
|
488
|
+
data.error_msg = body_arr[1]
|
|
489
|
+
|
|
490
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
491
|
+
data.method = body_arr[2]
|
|
492
|
+
data.user_id = body_arr[3]
|
|
493
|
+
data.cur_page_num = body_arr[4]
|
|
494
|
+
data.per_page_count = body_arr[5]
|
|
495
|
+
data.setData(body_arr[6])
|
|
496
|
+
data.code = body_arr[7]
|
|
497
|
+
data.year = body_arr[8]
|
|
498
|
+
data.quarter = body_arr[9]
|
|
499
|
+
data.setFields(body_arr[10])
|
|
500
|
+
return data
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def query_dupont_data(code, year=None, quarter=None):
|
|
504
|
+
"""季频杜邦指数
|
|
505
|
+
@param code: 证券代码,不可为空
|
|
506
|
+
@param year: 统计年份,为空时默认当前年
|
|
507
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
508
|
+
"""
|
|
509
|
+
data = rs.ResultData()
|
|
510
|
+
if code is None or code == "":
|
|
511
|
+
print("股票代码不能为空,请检查。")
|
|
512
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
513
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
514
|
+
return data
|
|
515
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
516
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
517
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
518
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
519
|
+
return data
|
|
520
|
+
code = code.lower()
|
|
521
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
522
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
523
|
+
|
|
524
|
+
if year is None or year == "":
|
|
525
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
526
|
+
if quarter is None or quarter == "":
|
|
527
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
528
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
529
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
530
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
531
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
532
|
+
year = str(year)
|
|
533
|
+
if not year.isdigit():
|
|
534
|
+
print("年份输入有误,请修改。")
|
|
535
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
536
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
537
|
+
return data
|
|
538
|
+
|
|
539
|
+
user_id = ""
|
|
540
|
+
try:
|
|
541
|
+
user_id = getattr(conx, "user_id")
|
|
542
|
+
except Exception:
|
|
543
|
+
print("you don't login.")
|
|
544
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
545
|
+
data.error_msg = "you don't login."
|
|
546
|
+
return data
|
|
547
|
+
|
|
548
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
549
|
+
"query_dupont_data", user_id, "1",
|
|
550
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
551
|
+
|
|
552
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
553
|
+
msg_header = msgheader.to_message_header(
|
|
554
|
+
cons.MESSAGE_TYPE_QUERYDUPONTDATA_REQUEST, len(msg_body))
|
|
555
|
+
|
|
556
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYDUPONTDATA_REQUEST
|
|
557
|
+
data.msg_body = msg_body
|
|
558
|
+
|
|
559
|
+
head_body = msg_header + msg_body
|
|
560
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
561
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
562
|
+
|
|
563
|
+
if receive_data is None or receive_data.strip() == "":
|
|
564
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
565
|
+
data.error_msg = "网络接收错误。"
|
|
566
|
+
return data
|
|
567
|
+
|
|
568
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
569
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
570
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
571
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
572
|
+
data.msg_body_length = header_arr[2]
|
|
573
|
+
data.error_code = body_arr[0]
|
|
574
|
+
data.error_msg = body_arr[1]
|
|
575
|
+
|
|
576
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
577
|
+
data.method = body_arr[2]
|
|
578
|
+
data.user_id = body_arr[3]
|
|
579
|
+
data.cur_page_num = body_arr[4]
|
|
580
|
+
data.per_page_count = body_arr[5]
|
|
581
|
+
data.setData(body_arr[6])
|
|
582
|
+
data.code = body_arr[7]
|
|
583
|
+
data.year = body_arr[8]
|
|
584
|
+
data.quarter = body_arr[9]
|
|
585
|
+
data.setFields(body_arr[10])
|
|
586
|
+
return data
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
def query_balance_data(code, year=None, quarter=None):
|
|
590
|
+
"""季频偿债能力
|
|
591
|
+
@param code: 证券代码,不可为空
|
|
592
|
+
@param year: 统计年份,为空时默认当前年
|
|
593
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
594
|
+
"""
|
|
595
|
+
data = rs.ResultData()
|
|
596
|
+
if code is None or code == "":
|
|
597
|
+
print("股票代码不能为空,请检查。")
|
|
598
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
599
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
600
|
+
return data
|
|
601
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
602
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
603
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
604
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
605
|
+
return data
|
|
606
|
+
code = code.lower()
|
|
607
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
608
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
609
|
+
|
|
610
|
+
if year is None or year == "":
|
|
611
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
612
|
+
if quarter is None or quarter == "":
|
|
613
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
614
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
615
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
616
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
617
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
618
|
+
year = str(year)
|
|
619
|
+
if not year.isdigit():
|
|
620
|
+
print("年份输入有误,请修改。")
|
|
621
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
622
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
623
|
+
return data
|
|
624
|
+
|
|
625
|
+
user_id = ""
|
|
626
|
+
try:
|
|
627
|
+
user_id = getattr(conx, "user_id")
|
|
628
|
+
except Exception:
|
|
629
|
+
print("you don't login.")
|
|
630
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
631
|
+
data.error_msg = "you don't login."
|
|
632
|
+
return data
|
|
633
|
+
|
|
634
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
635
|
+
"query_balance_data", user_id, "1",
|
|
636
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
637
|
+
|
|
638
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
639
|
+
msg_header = msgheader.to_message_header(
|
|
640
|
+
cons.MESSAGE_TYPE_QUERYBALANCEDATA_REQUEST, len(msg_body))
|
|
641
|
+
|
|
642
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYBALANCEDATA_REQUEST
|
|
643
|
+
data.msg_body = msg_body
|
|
644
|
+
|
|
645
|
+
head_body = msg_header + msg_body
|
|
646
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
647
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
648
|
+
|
|
649
|
+
if receive_data is None or receive_data.strip() == "":
|
|
650
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
651
|
+
data.error_msg = "网络接收错误。"
|
|
652
|
+
return data
|
|
653
|
+
|
|
654
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
655
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
656
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
657
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
658
|
+
data.msg_body_length = header_arr[2]
|
|
659
|
+
data.error_code = body_arr[0]
|
|
660
|
+
data.error_msg = body_arr[1]
|
|
661
|
+
|
|
662
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
663
|
+
data.method = body_arr[2]
|
|
664
|
+
data.user_id = body_arr[3]
|
|
665
|
+
data.cur_page_num = body_arr[4]
|
|
666
|
+
data.per_page_count = body_arr[5]
|
|
667
|
+
data.setData(body_arr[6])
|
|
668
|
+
data.code = body_arr[7]
|
|
669
|
+
data.year = body_arr[8]
|
|
670
|
+
data.quarter = body_arr[9]
|
|
671
|
+
data.setFields(body_arr[10])
|
|
672
|
+
return data
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def query_cash_flow_data(code, year=None, quarter=None):
|
|
676
|
+
"""季频现金流量
|
|
677
|
+
@param code: 证券代码,不可为空
|
|
678
|
+
@param year: 统计年份,为空时默认当前年
|
|
679
|
+
@param quarter: 统计季度,为空时默认当前季度
|
|
680
|
+
"""
|
|
681
|
+
data = rs.ResultData()
|
|
682
|
+
if code is None or code == "":
|
|
683
|
+
print("股票代码不能为空,请检查。")
|
|
684
|
+
data.error_msg = "股票代码不能为空,请检查。"
|
|
685
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
686
|
+
return data
|
|
687
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
688
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
689
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
690
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
691
|
+
return data
|
|
692
|
+
code = code.lower()
|
|
693
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
694
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
695
|
+
|
|
696
|
+
if year is None or year == "":
|
|
697
|
+
year = time.strftime("%Y", time.localtime()) # 当前年份
|
|
698
|
+
if quarter is None or quarter == "":
|
|
699
|
+
quarter = (int(time.strftime("%m", time.localtime())) + 2) // 3 # 当前季度
|
|
700
|
+
elif quarter not in [1, 2, 3, 4] and quarter not in ["1", "2", "3", "4"]:
|
|
701
|
+
print("季度填写错误,请检查。填写范围:1,2,3,4")
|
|
702
|
+
data.error_msg = "季度填写错误,请检查。填写范围:1,2,3,4"
|
|
703
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
704
|
+
year = str(year)
|
|
705
|
+
if not year.isdigit():
|
|
706
|
+
print("年份输入有误,请修改。")
|
|
707
|
+
data.error_msg = "年份输入有误,请修改。"
|
|
708
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
709
|
+
return data
|
|
710
|
+
|
|
711
|
+
user_id = ""
|
|
712
|
+
try:
|
|
713
|
+
user_id = getattr(conx, "user_id")
|
|
714
|
+
except Exception:
|
|
715
|
+
print("you don't login.")
|
|
716
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
717
|
+
data.error_msg = "you don't login."
|
|
718
|
+
return data
|
|
719
|
+
|
|
720
|
+
param = "%s,%s,%s,%s,%s,%s,%s" % (
|
|
721
|
+
"query_cash_flow_data", user_id, "1",
|
|
722
|
+
cons.BAOSTOCK_PER_PAGE_COUNT, code, year, quarter)
|
|
723
|
+
|
|
724
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
725
|
+
msg_header = msgheader.to_message_header(
|
|
726
|
+
cons.MESSAGE_TYPE_QUERYCASHFLOWDATA_REQUEST, len(msg_body))
|
|
727
|
+
|
|
728
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYCASHFLOWDATA_REQUEST
|
|
729
|
+
data.msg_body = msg_body
|
|
730
|
+
|
|
731
|
+
head_body = msg_header + msg_body
|
|
732
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
733
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
734
|
+
|
|
735
|
+
if receive_data is None or receive_data.strip() == "":
|
|
736
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
737
|
+
data.error_msg = "网络接收错误。"
|
|
738
|
+
return data
|
|
739
|
+
|
|
740
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
741
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
742
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
743
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
744
|
+
data.msg_body_length = header_arr[2]
|
|
745
|
+
data.error_code = body_arr[0]
|
|
746
|
+
data.error_msg = body_arr[1]
|
|
747
|
+
|
|
748
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
749
|
+
data.method = body_arr[2]
|
|
750
|
+
data.user_id = body_arr[3]
|
|
751
|
+
data.cur_page_num = body_arr[4]
|
|
752
|
+
data.per_page_count = body_arr[5]
|
|
753
|
+
data.setData(body_arr[6])
|
|
754
|
+
data.code = body_arr[7]
|
|
755
|
+
data.year = body_arr[8]
|
|
756
|
+
data.quarter = body_arr[9]
|
|
757
|
+
data.setFields(body_arr[10])
|
|
758
|
+
return data
|