@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,1024 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
获行业分类
|
|
4
|
+
@author: baostock.com
|
|
5
|
+
@group : baostock.com
|
|
6
|
+
@contact: baostock@163.com
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import zlib
|
|
10
|
+
import baostock.data.resultset as rs
|
|
11
|
+
import baostock.common.contants as cons
|
|
12
|
+
import baostock.util.stringutil as strUtil
|
|
13
|
+
import baostock.common.context as conx
|
|
14
|
+
import baostock.util.socketutil as sock
|
|
15
|
+
import baostock.data.messageheader as msgheader
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def query_stock_industry(code="", date=""):
|
|
19
|
+
"""获取行业分类
|
|
20
|
+
@param code:股票代码,默认为空。
|
|
21
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
22
|
+
"""
|
|
23
|
+
data = rs.ResultData()
|
|
24
|
+
|
|
25
|
+
if code is None or code == "":
|
|
26
|
+
code = ""
|
|
27
|
+
if code != "" and code is not None:
|
|
28
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
29
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
30
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
31
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
32
|
+
return data
|
|
33
|
+
code = code.lower()
|
|
34
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
35
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
36
|
+
|
|
37
|
+
if date is None or date == "":
|
|
38
|
+
date = ""
|
|
39
|
+
else:
|
|
40
|
+
if strUtil.is_valid_date(date):
|
|
41
|
+
pass
|
|
42
|
+
else:
|
|
43
|
+
print("日期格式不正确,请修改。")
|
|
44
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
45
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
46
|
+
return data
|
|
47
|
+
user_id = getattr(conx,"user_id")
|
|
48
|
+
try:
|
|
49
|
+
user_id = getattr(conx, "user_id")
|
|
50
|
+
except Exception:
|
|
51
|
+
print("you don't login.")
|
|
52
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
53
|
+
data.error_msg = "you don't login."
|
|
54
|
+
return data
|
|
55
|
+
|
|
56
|
+
param = "query_stock_industry," + str(user_id) + ",1," + \
|
|
57
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
58
|
+
"," + str(code) + "," + str(date)
|
|
59
|
+
|
|
60
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
61
|
+
msg_header = msgheader.to_message_header(
|
|
62
|
+
cons.MESSAGE_TYPE_QUERYSTOCKINDUSTRY_REQUEST, len(msg_body))
|
|
63
|
+
|
|
64
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTOCKINDUSTRY_REQUEST
|
|
65
|
+
data.msg_body = msg_body
|
|
66
|
+
|
|
67
|
+
head_body = msg_header + msg_body
|
|
68
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
69
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
70
|
+
|
|
71
|
+
if receive_data is None or receive_data.strip() == "":
|
|
72
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
73
|
+
data.error_msg = "网络接收错误。"
|
|
74
|
+
return data
|
|
75
|
+
|
|
76
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
77
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
78
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
79
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
80
|
+
data.msg_body_length = header_arr[2]
|
|
81
|
+
data.error_code = body_arr[0]
|
|
82
|
+
data.error_msg = body_arr[1]
|
|
83
|
+
|
|
84
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
85
|
+
data.method = body_arr[2]
|
|
86
|
+
data.user_id = body_arr[3]
|
|
87
|
+
data.cur_page_num = body_arr[4]
|
|
88
|
+
data.per_page_count = body_arr[5]
|
|
89
|
+
data.setData(body_arr[6])
|
|
90
|
+
data.code = body_arr[7]
|
|
91
|
+
data.date = body_arr[8]
|
|
92
|
+
data.setFields(body_arr[9])
|
|
93
|
+
|
|
94
|
+
return data
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def query_hs300_stocks(date=""):
|
|
98
|
+
"""获取沪深300成分股
|
|
99
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
100
|
+
"""
|
|
101
|
+
data = rs.ResultData()
|
|
102
|
+
|
|
103
|
+
if date is None or date == "":
|
|
104
|
+
date = ""
|
|
105
|
+
else:
|
|
106
|
+
if strUtil.is_valid_date(date):
|
|
107
|
+
pass
|
|
108
|
+
else:
|
|
109
|
+
print("日期格式不正确,请修改。")
|
|
110
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
111
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
112
|
+
return data
|
|
113
|
+
user_id = getattr(conx, "user_id")
|
|
114
|
+
try:
|
|
115
|
+
user_id = getattr(conx, "user_id")
|
|
116
|
+
except Exception:
|
|
117
|
+
print("you don't login.")
|
|
118
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
119
|
+
data.error_msg = "you don't login."
|
|
120
|
+
return data
|
|
121
|
+
|
|
122
|
+
param = "query_hs300_stocks," + str(user_id) + ",1," + \
|
|
123
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
124
|
+
"," + str(date)
|
|
125
|
+
|
|
126
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
127
|
+
msg_header = msgheader.to_message_header(
|
|
128
|
+
cons.MESSAGE_TYPE_QUERYHS300STOCKS_REQUEST, len(msg_body))
|
|
129
|
+
|
|
130
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYHS300STOCKS_REQUEST
|
|
131
|
+
data.msg_body = msg_body
|
|
132
|
+
|
|
133
|
+
head_body = msg_header + msg_body
|
|
134
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
135
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
136
|
+
|
|
137
|
+
if receive_data is None or receive_data.strip() == "":
|
|
138
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
139
|
+
data.error_msg = "网络接收错误。"
|
|
140
|
+
return data
|
|
141
|
+
|
|
142
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
143
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
144
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
145
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
146
|
+
data.msg_body_length = header_arr[2]
|
|
147
|
+
data.error_code = body_arr[0]
|
|
148
|
+
data.error_msg = body_arr[1]
|
|
149
|
+
|
|
150
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
151
|
+
data.method = body_arr[2]
|
|
152
|
+
data.user_id = body_arr[3]
|
|
153
|
+
data.cur_page_num = body_arr[4]
|
|
154
|
+
data.per_page_count = body_arr[5]
|
|
155
|
+
data.setData(body_arr[6])
|
|
156
|
+
data.date = body_arr[7]
|
|
157
|
+
data.setFields(body_arr[8])
|
|
158
|
+
|
|
159
|
+
return data
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def query_sz50_stocks(date=""):
|
|
163
|
+
"""获取上证50成分股
|
|
164
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
165
|
+
"""
|
|
166
|
+
data = rs.ResultData()
|
|
167
|
+
|
|
168
|
+
if date is None or date == "":
|
|
169
|
+
date = ""
|
|
170
|
+
else:
|
|
171
|
+
if strUtil.is_valid_date(date):
|
|
172
|
+
pass
|
|
173
|
+
else:
|
|
174
|
+
print("日期格式不正确,请修改。")
|
|
175
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
176
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
177
|
+
return data
|
|
178
|
+
user_id = getattr(conx, "user_id")
|
|
179
|
+
try:
|
|
180
|
+
user_id = getattr(conx, "user_id")
|
|
181
|
+
except Exception:
|
|
182
|
+
print("you don't login.")
|
|
183
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
184
|
+
data.error_msg = "you don't login."
|
|
185
|
+
return data
|
|
186
|
+
|
|
187
|
+
param = "query_sz50_stocks," + str(user_id) + ",1," + \
|
|
188
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
189
|
+
"," + str(date)
|
|
190
|
+
|
|
191
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
192
|
+
msg_header = msgheader.to_message_header(
|
|
193
|
+
cons.MESSAGE_TYPE_QUERYSZ50STOCKS_REQUEST, len(msg_body))
|
|
194
|
+
|
|
195
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSZ50STOCKS_REQUEST
|
|
196
|
+
data.msg_body = msg_body
|
|
197
|
+
|
|
198
|
+
head_body = msg_header + msg_body
|
|
199
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
200
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
201
|
+
|
|
202
|
+
if receive_data is None or receive_data.strip() == "":
|
|
203
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
204
|
+
data.error_msg = "网络接收错误。"
|
|
205
|
+
return data
|
|
206
|
+
|
|
207
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
208
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
209
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
210
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
211
|
+
data.msg_body_length = header_arr[2]
|
|
212
|
+
data.error_code = body_arr[0]
|
|
213
|
+
data.error_msg = body_arr[1]
|
|
214
|
+
|
|
215
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
216
|
+
data.method = body_arr[2]
|
|
217
|
+
data.user_id = body_arr[3]
|
|
218
|
+
data.cur_page_num = body_arr[4]
|
|
219
|
+
data.per_page_count = body_arr[5]
|
|
220
|
+
data.setData(body_arr[6])
|
|
221
|
+
data.date = body_arr[7]
|
|
222
|
+
data.setFields(body_arr[8])
|
|
223
|
+
|
|
224
|
+
return data
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def query_zz500_stocks(date=""):
|
|
228
|
+
"""获取中证500成分股
|
|
229
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
230
|
+
"""
|
|
231
|
+
data = rs.ResultData()
|
|
232
|
+
|
|
233
|
+
if date is None or date == "":
|
|
234
|
+
date = ""
|
|
235
|
+
else:
|
|
236
|
+
if strUtil.is_valid_date(date):
|
|
237
|
+
pass
|
|
238
|
+
else:
|
|
239
|
+
print("日期格式不正确,请修改。")
|
|
240
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
241
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
242
|
+
return data
|
|
243
|
+
user_id = getattr(conx, "user_id")
|
|
244
|
+
try:
|
|
245
|
+
user_id = getattr(conx, "user_id")
|
|
246
|
+
except Exception:
|
|
247
|
+
print("you don't login.")
|
|
248
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
249
|
+
data.error_msg = "you don't login."
|
|
250
|
+
return data
|
|
251
|
+
|
|
252
|
+
param = "query_zz500_stocks," + str(user_id) + ",1," + \
|
|
253
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
254
|
+
"," + str(date)
|
|
255
|
+
|
|
256
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
257
|
+
msg_header = msgheader.to_message_header(
|
|
258
|
+
cons.MESSAGE_TYPE_QUERYZZ500STOCKS_REQUEST, len(msg_body))
|
|
259
|
+
|
|
260
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYZZ500STOCKS_REQUEST
|
|
261
|
+
data.msg_body = msg_body
|
|
262
|
+
|
|
263
|
+
head_body = msg_header + msg_body
|
|
264
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
265
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
266
|
+
|
|
267
|
+
if receive_data is None or receive_data.strip() == "":
|
|
268
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
269
|
+
data.error_msg = "网络接收错误。"
|
|
270
|
+
return data
|
|
271
|
+
|
|
272
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
273
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
274
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
275
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
276
|
+
data.msg_body_length = header_arr[2]
|
|
277
|
+
data.error_code = body_arr[0]
|
|
278
|
+
data.error_msg = body_arr[1]
|
|
279
|
+
|
|
280
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
281
|
+
data.method = body_arr[2]
|
|
282
|
+
data.user_id = body_arr[3]
|
|
283
|
+
data.cur_page_num = body_arr[4]
|
|
284
|
+
data.per_page_count = body_arr[5]
|
|
285
|
+
data.setData(body_arr[6])
|
|
286
|
+
data.date = body_arr[7]
|
|
287
|
+
data.setFields(body_arr[8])
|
|
288
|
+
|
|
289
|
+
return data
|
|
290
|
+
|
|
291
|
+
def query_terminated_stocks(date=""):
|
|
292
|
+
"""获取终止上市股票列表
|
|
293
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
294
|
+
"""
|
|
295
|
+
data = rs.ResultData()
|
|
296
|
+
|
|
297
|
+
if date is None or date == "":
|
|
298
|
+
date = ""
|
|
299
|
+
else:
|
|
300
|
+
if strUtil.is_valid_date(date):
|
|
301
|
+
pass
|
|
302
|
+
else:
|
|
303
|
+
print("日期格式不正确,请修改。")
|
|
304
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
305
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
306
|
+
return data
|
|
307
|
+
user_id = getattr(conx, "user_id")
|
|
308
|
+
try:
|
|
309
|
+
user_id = getattr(conx, "user_id")
|
|
310
|
+
except Exception:
|
|
311
|
+
print("you don't login.")
|
|
312
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
313
|
+
data.error_msg = "you don't login."
|
|
314
|
+
return data
|
|
315
|
+
|
|
316
|
+
param = "query_terminated_stocks," + str(user_id) + ",1," + \
|
|
317
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
318
|
+
"," + str(date)
|
|
319
|
+
|
|
320
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
321
|
+
msg_header = msgheader.to_message_header(
|
|
322
|
+
cons.MESSAGE_TYPE_QUERYTERMINATEDSTOCKS_REQUEST, len(msg_body))
|
|
323
|
+
|
|
324
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYTERMINATEDSTOCKS_REQUEST
|
|
325
|
+
data.msg_body = msg_body
|
|
326
|
+
|
|
327
|
+
head_body = msg_header + msg_body
|
|
328
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
329
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
330
|
+
|
|
331
|
+
if receive_data is None or receive_data.strip() == "":
|
|
332
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
333
|
+
data.error_msg = "网络接收错误。"
|
|
334
|
+
return data
|
|
335
|
+
|
|
336
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
337
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
338
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
339
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
340
|
+
data.msg_body_length = header_arr[2]
|
|
341
|
+
data.error_code = body_arr[0]
|
|
342
|
+
data.error_msg = body_arr[1]
|
|
343
|
+
|
|
344
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
345
|
+
data.method = body_arr[2]
|
|
346
|
+
data.user_id = body_arr[3]
|
|
347
|
+
data.cur_page_num = body_arr[4]
|
|
348
|
+
data.per_page_count = body_arr[5]
|
|
349
|
+
data.setData(body_arr[6])
|
|
350
|
+
data.date = body_arr[7]
|
|
351
|
+
data.setFields(body_arr[8])
|
|
352
|
+
|
|
353
|
+
return data
|
|
354
|
+
|
|
355
|
+
def query_suspended_stocks(date=""):
|
|
356
|
+
"""获取暂停上市股票列表
|
|
357
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
358
|
+
"""
|
|
359
|
+
data = rs.ResultData()
|
|
360
|
+
|
|
361
|
+
if date is None or date == "":
|
|
362
|
+
date = ""
|
|
363
|
+
else:
|
|
364
|
+
if strUtil.is_valid_date(date):
|
|
365
|
+
pass
|
|
366
|
+
else:
|
|
367
|
+
print("日期格式不正确,请修改。")
|
|
368
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
369
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
370
|
+
return data
|
|
371
|
+
user_id = getattr(conx, "user_id")
|
|
372
|
+
try:
|
|
373
|
+
user_id = getattr(conx, "user_id")
|
|
374
|
+
except Exception:
|
|
375
|
+
print("you don't login.")
|
|
376
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
377
|
+
data.error_msg = "you don't login."
|
|
378
|
+
return data
|
|
379
|
+
|
|
380
|
+
param = "query_suspended_stocks," + str(user_id) + ",1," + \
|
|
381
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
382
|
+
"," + str(date)
|
|
383
|
+
|
|
384
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
385
|
+
msg_header = msgheader.to_message_header(
|
|
386
|
+
cons.MESSAGE_TYPE_QUERYSUSPENDEDSTOCKS_REQUEST, len(msg_body))
|
|
387
|
+
|
|
388
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSUSPENDEDSTOCKS_REQUEST
|
|
389
|
+
data.msg_body = msg_body
|
|
390
|
+
|
|
391
|
+
head_body = msg_header + msg_body
|
|
392
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
393
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
394
|
+
|
|
395
|
+
if receive_data is None or receive_data.strip() == "":
|
|
396
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
397
|
+
data.error_msg = "网络接收错误。"
|
|
398
|
+
return data
|
|
399
|
+
|
|
400
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
401
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
402
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
403
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
404
|
+
data.msg_body_length = header_arr[2]
|
|
405
|
+
data.error_code = body_arr[0]
|
|
406
|
+
data.error_msg = body_arr[1]
|
|
407
|
+
|
|
408
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
409
|
+
data.method = body_arr[2]
|
|
410
|
+
data.user_id = body_arr[3]
|
|
411
|
+
data.cur_page_num = body_arr[4]
|
|
412
|
+
data.per_page_count = body_arr[5]
|
|
413
|
+
data.setData(body_arr[6])
|
|
414
|
+
data.date = body_arr[7]
|
|
415
|
+
data.setFields(body_arr[8])
|
|
416
|
+
|
|
417
|
+
return data
|
|
418
|
+
|
|
419
|
+
def query_st_stocks(date=""):
|
|
420
|
+
"""获取ST股票列表
|
|
421
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
422
|
+
"""
|
|
423
|
+
data = rs.ResultData()
|
|
424
|
+
|
|
425
|
+
if date is None or date == "":
|
|
426
|
+
date = ""
|
|
427
|
+
else:
|
|
428
|
+
if strUtil.is_valid_date(date):
|
|
429
|
+
pass
|
|
430
|
+
else:
|
|
431
|
+
print("日期格式不正确,请修改。")
|
|
432
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
433
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
434
|
+
return data
|
|
435
|
+
user_id = getattr(conx, "user_id")
|
|
436
|
+
try:
|
|
437
|
+
user_id = getattr(conx, "user_id")
|
|
438
|
+
except Exception:
|
|
439
|
+
print("you don't login.")
|
|
440
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
441
|
+
data.error_msg = "you don't login."
|
|
442
|
+
return data
|
|
443
|
+
|
|
444
|
+
param = "query_st_stocks," + str(user_id) + ",1," + \
|
|
445
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
446
|
+
"," + str(date)
|
|
447
|
+
|
|
448
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
449
|
+
msg_header = msgheader.to_message_header(
|
|
450
|
+
cons.MESSAGE_TYPE_QUERYSTSTOCKS_REQUEST, len(msg_body))
|
|
451
|
+
|
|
452
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTSTOCKS_REQUEST
|
|
453
|
+
data.msg_body = msg_body
|
|
454
|
+
|
|
455
|
+
head_body = msg_header + msg_body
|
|
456
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
457
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
458
|
+
|
|
459
|
+
if receive_data is None or receive_data.strip() == "":
|
|
460
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
461
|
+
data.error_msg = "网络接收错误。"
|
|
462
|
+
return data
|
|
463
|
+
|
|
464
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
465
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
466
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
467
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
468
|
+
data.msg_body_length = header_arr[2]
|
|
469
|
+
data.error_code = body_arr[0]
|
|
470
|
+
data.error_msg = body_arr[1]
|
|
471
|
+
|
|
472
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
473
|
+
data.method = body_arr[2]
|
|
474
|
+
data.user_id = body_arr[3]
|
|
475
|
+
data.cur_page_num = body_arr[4]
|
|
476
|
+
data.per_page_count = body_arr[5]
|
|
477
|
+
data.setData(body_arr[6])
|
|
478
|
+
data.date = body_arr[7]
|
|
479
|
+
data.setFields(body_arr[8])
|
|
480
|
+
|
|
481
|
+
return data
|
|
482
|
+
|
|
483
|
+
def query_starst_stocks(date=""):
|
|
484
|
+
"""获取*ST股票列表
|
|
485
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
486
|
+
"""
|
|
487
|
+
data = rs.ResultData()
|
|
488
|
+
|
|
489
|
+
if date is None or date == "":
|
|
490
|
+
date = ""
|
|
491
|
+
else:
|
|
492
|
+
if strUtil.is_valid_date(date):
|
|
493
|
+
pass
|
|
494
|
+
else:
|
|
495
|
+
print("日期格式不正确,请修改。")
|
|
496
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
497
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
498
|
+
return data
|
|
499
|
+
user_id = getattr(conx, "user_id")
|
|
500
|
+
try:
|
|
501
|
+
user_id = getattr(conx, "user_id")
|
|
502
|
+
except Exception:
|
|
503
|
+
print("you don't login.")
|
|
504
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
505
|
+
data.error_msg = "you don't login."
|
|
506
|
+
return data
|
|
507
|
+
|
|
508
|
+
param = "query_starst_stocks," + str(user_id) + ",1," + \
|
|
509
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
510
|
+
"," + str(date)
|
|
511
|
+
|
|
512
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
513
|
+
msg_header = msgheader.to_message_header(
|
|
514
|
+
cons.MESSAGE_TYPE_QUERYSTARSTSTOCKS_REQUEST, len(msg_body))
|
|
515
|
+
|
|
516
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTARSTSTOCKS_REQUEST
|
|
517
|
+
data.msg_body = msg_body
|
|
518
|
+
|
|
519
|
+
head_body = msg_header + msg_body
|
|
520
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
521
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
522
|
+
|
|
523
|
+
if receive_data is None or receive_data.strip() == "":
|
|
524
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
525
|
+
data.error_msg = "网络接收错误。"
|
|
526
|
+
return data
|
|
527
|
+
|
|
528
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
529
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
530
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
531
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
532
|
+
data.msg_body_length = header_arr[2]
|
|
533
|
+
data.error_code = body_arr[0]
|
|
534
|
+
data.error_msg = body_arr[1]
|
|
535
|
+
|
|
536
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
537
|
+
data.method = body_arr[2]
|
|
538
|
+
data.user_id = body_arr[3]
|
|
539
|
+
data.cur_page_num = body_arr[4]
|
|
540
|
+
data.per_page_count = body_arr[5]
|
|
541
|
+
data.setData(body_arr[6])
|
|
542
|
+
data.date = body_arr[7]
|
|
543
|
+
data.setFields(body_arr[8])
|
|
544
|
+
|
|
545
|
+
return data
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
def query_stock_concept(code="", date=""):
|
|
549
|
+
"""获取概念分类
|
|
550
|
+
@param code:股票代码,默认为空。
|
|
551
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
552
|
+
"""
|
|
553
|
+
data = rs.ResultData()
|
|
554
|
+
|
|
555
|
+
if code is None or code == "":
|
|
556
|
+
code = ""
|
|
557
|
+
if code != "" and code is not None:
|
|
558
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
559
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
560
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
561
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
562
|
+
return data
|
|
563
|
+
code = code.lower()
|
|
564
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
565
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
566
|
+
|
|
567
|
+
if date is None or date == "":
|
|
568
|
+
date = ""
|
|
569
|
+
else:
|
|
570
|
+
if strUtil.is_valid_date(date):
|
|
571
|
+
pass
|
|
572
|
+
else:
|
|
573
|
+
print("日期格式不正确,请修改。")
|
|
574
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
575
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
576
|
+
return data
|
|
577
|
+
user_id = getattr(conx,"user_id")
|
|
578
|
+
try:
|
|
579
|
+
user_id = getattr(conx, "user_id")
|
|
580
|
+
except Exception:
|
|
581
|
+
print("you don't login.")
|
|
582
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
583
|
+
data.error_msg = "you don't login."
|
|
584
|
+
return data
|
|
585
|
+
|
|
586
|
+
param = "query_stock_concept," + str(user_id) + ",1," + \
|
|
587
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
588
|
+
"," + str(code) + "," + str(date)
|
|
589
|
+
|
|
590
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
591
|
+
msg_header = msgheader.to_message_header(
|
|
592
|
+
cons.MESSAGE_TYPE_QUERYSTOCKCONCEPT_REQUEST, len(msg_body))
|
|
593
|
+
|
|
594
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTOCKCONCEPT_REQUEST
|
|
595
|
+
data.msg_body = msg_body
|
|
596
|
+
|
|
597
|
+
head_body = msg_header + msg_body
|
|
598
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
599
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
600
|
+
|
|
601
|
+
if receive_data is None or receive_data.strip() == "":
|
|
602
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
603
|
+
data.error_msg = "网络接收错误。"
|
|
604
|
+
return data
|
|
605
|
+
|
|
606
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
607
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
608
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
609
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
610
|
+
data.msg_body_length = header_arr[2]
|
|
611
|
+
data.error_code = body_arr[0]
|
|
612
|
+
data.error_msg = body_arr[1]
|
|
613
|
+
|
|
614
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
615
|
+
data.method = body_arr[2]
|
|
616
|
+
data.user_id = body_arr[3]
|
|
617
|
+
data.cur_page_num = body_arr[4]
|
|
618
|
+
data.per_page_count = body_arr[5]
|
|
619
|
+
data.setData(body_arr[6])
|
|
620
|
+
data.code = body_arr[7]
|
|
621
|
+
data.date = body_arr[8]
|
|
622
|
+
data.setFields(body_arr[9])
|
|
623
|
+
|
|
624
|
+
return data
|
|
625
|
+
|
|
626
|
+
def query_stock_area(code="", date=""):
|
|
627
|
+
"""获取地域分类
|
|
628
|
+
@param code:股票代码,默认为空。
|
|
629
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
630
|
+
"""
|
|
631
|
+
data = rs.ResultData()
|
|
632
|
+
|
|
633
|
+
if code is None or code == "":
|
|
634
|
+
code = ""
|
|
635
|
+
if code != "" and code is not None:
|
|
636
|
+
if len(code) != cons.STOCK_CODE_LENGTH:
|
|
637
|
+
print("股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。")
|
|
638
|
+
data.error_msg = "股票代码应为" + str(cons.STOCK_CODE_LENGTH) + "位,请检查。格式示例:sh.600000。"
|
|
639
|
+
data.error_code = cons.BSERR_PARAM_ERR
|
|
640
|
+
return data
|
|
641
|
+
code = code.lower()
|
|
642
|
+
if (code.endswith("sh") or code.endswith("sz")):
|
|
643
|
+
code = code[7:9].lower() + "." + code[0:6]
|
|
644
|
+
|
|
645
|
+
if date is None or date == "":
|
|
646
|
+
date = ""
|
|
647
|
+
else:
|
|
648
|
+
if strUtil.is_valid_date(date):
|
|
649
|
+
pass
|
|
650
|
+
else:
|
|
651
|
+
print("日期格式不正确,请修改。")
|
|
652
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
653
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
654
|
+
return data
|
|
655
|
+
user_id = getattr(conx,"user_id")
|
|
656
|
+
try:
|
|
657
|
+
user_id = getattr(conx, "user_id")
|
|
658
|
+
except Exception:
|
|
659
|
+
print("you don't login.")
|
|
660
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
661
|
+
data.error_msg = "you don't login."
|
|
662
|
+
return data
|
|
663
|
+
|
|
664
|
+
param = "query_stock_area," + str(user_id) + ",1," + \
|
|
665
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
666
|
+
"," + str(code) + "," + str(date)
|
|
667
|
+
|
|
668
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
669
|
+
msg_header = msgheader.to_message_header(
|
|
670
|
+
cons.MESSAGE_TYPE_QUERYSTOCKAREA_REQUEST, len(msg_body))
|
|
671
|
+
|
|
672
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTOCKAREA_REQUEST
|
|
673
|
+
data.msg_body = msg_body
|
|
674
|
+
|
|
675
|
+
head_body = msg_header + msg_body
|
|
676
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
677
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
678
|
+
|
|
679
|
+
if receive_data is None or receive_data.strip() == "":
|
|
680
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
681
|
+
data.error_msg = "网络接收错误。"
|
|
682
|
+
return data
|
|
683
|
+
|
|
684
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
685
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
686
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
687
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
688
|
+
data.msg_body_length = header_arr[2]
|
|
689
|
+
data.error_code = body_arr[0]
|
|
690
|
+
data.error_msg = body_arr[1]
|
|
691
|
+
|
|
692
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
693
|
+
data.method = body_arr[2]
|
|
694
|
+
data.user_id = body_arr[3]
|
|
695
|
+
data.cur_page_num = body_arr[4]
|
|
696
|
+
data.per_page_count = body_arr[5]
|
|
697
|
+
data.setData(body_arr[6])
|
|
698
|
+
data.code = body_arr[7]
|
|
699
|
+
data.date = body_arr[8]
|
|
700
|
+
data.setFields(body_arr[9])
|
|
701
|
+
|
|
702
|
+
return data
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def query_ame_stocks(date=""):
|
|
706
|
+
"""获取中小板分类
|
|
707
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
708
|
+
"""
|
|
709
|
+
data = rs.ResultData()
|
|
710
|
+
|
|
711
|
+
if date is None or date == "":
|
|
712
|
+
date = ""
|
|
713
|
+
else:
|
|
714
|
+
if strUtil.is_valid_date(date):
|
|
715
|
+
pass
|
|
716
|
+
else:
|
|
717
|
+
print("日期格式不正确,请修改。")
|
|
718
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
719
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
720
|
+
return data
|
|
721
|
+
user_id = getattr(conx, "user_id")
|
|
722
|
+
try:
|
|
723
|
+
user_id = getattr(conx, "user_id")
|
|
724
|
+
except Exception:
|
|
725
|
+
print("you don't login.")
|
|
726
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
727
|
+
data.error_msg = "you don't login."
|
|
728
|
+
return data
|
|
729
|
+
|
|
730
|
+
param = "query_ame_stocks," + str(user_id) + ",1," + \
|
|
731
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
732
|
+
"," + str(date)
|
|
733
|
+
|
|
734
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
735
|
+
msg_header = msgheader.to_message_header(
|
|
736
|
+
cons.MESSAGE_TYPE_QUERYAMESTOCK_REQUEST, len(msg_body))
|
|
737
|
+
|
|
738
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYAMESTOCK_REQUEST
|
|
739
|
+
data.msg_body = msg_body
|
|
740
|
+
|
|
741
|
+
head_body = msg_header + msg_body
|
|
742
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
743
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
744
|
+
|
|
745
|
+
if receive_data is None or receive_data.strip() == "":
|
|
746
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
747
|
+
data.error_msg = "网络接收错误。"
|
|
748
|
+
return data
|
|
749
|
+
|
|
750
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
751
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
752
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
753
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
754
|
+
data.msg_body_length = header_arr[2]
|
|
755
|
+
data.error_code = body_arr[0]
|
|
756
|
+
data.error_msg = body_arr[1]
|
|
757
|
+
|
|
758
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
759
|
+
data.method = body_arr[2]
|
|
760
|
+
data.user_id = body_arr[3]
|
|
761
|
+
data.cur_page_num = body_arr[4]
|
|
762
|
+
data.per_page_count = body_arr[5]
|
|
763
|
+
data.setData(body_arr[6])
|
|
764
|
+
data.date = body_arr[7]
|
|
765
|
+
data.setFields(body_arr[8])
|
|
766
|
+
|
|
767
|
+
return data
|
|
768
|
+
|
|
769
|
+
def query_gem_stocks(date=""):
|
|
770
|
+
"""获取创业板分类
|
|
771
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
772
|
+
"""
|
|
773
|
+
data = rs.ResultData()
|
|
774
|
+
|
|
775
|
+
if date is None or date == "":
|
|
776
|
+
date = ""
|
|
777
|
+
else:
|
|
778
|
+
if strUtil.is_valid_date(date):
|
|
779
|
+
pass
|
|
780
|
+
else:
|
|
781
|
+
print("日期格式不正确,请修改。")
|
|
782
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
783
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
784
|
+
return data
|
|
785
|
+
user_id = getattr(conx, "user_id")
|
|
786
|
+
try:
|
|
787
|
+
user_id = getattr(conx, "user_id")
|
|
788
|
+
except Exception:
|
|
789
|
+
print("you don't login.")
|
|
790
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
791
|
+
data.error_msg = "you don't login."
|
|
792
|
+
return data
|
|
793
|
+
|
|
794
|
+
param = "query_gem_stocks," + str(user_id) + ",1," + \
|
|
795
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
796
|
+
"," + str(date)
|
|
797
|
+
|
|
798
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
799
|
+
msg_header = msgheader.to_message_header(
|
|
800
|
+
cons.MESSAGE_TYPE_QUERYGEMSTOCK_REQUEST, len(msg_body))
|
|
801
|
+
|
|
802
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYGEMSTOCK_REQUEST
|
|
803
|
+
data.msg_body = msg_body
|
|
804
|
+
|
|
805
|
+
head_body = msg_header + msg_body
|
|
806
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
807
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
808
|
+
|
|
809
|
+
if receive_data is None or receive_data.strip() == "":
|
|
810
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
811
|
+
data.error_msg = "网络接收错误。"
|
|
812
|
+
return data
|
|
813
|
+
|
|
814
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
815
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
816
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
817
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
818
|
+
data.msg_body_length = header_arr[2]
|
|
819
|
+
data.error_code = body_arr[0]
|
|
820
|
+
data.error_msg = body_arr[1]
|
|
821
|
+
|
|
822
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
823
|
+
data.method = body_arr[2]
|
|
824
|
+
data.user_id = body_arr[3]
|
|
825
|
+
data.cur_page_num = body_arr[4]
|
|
826
|
+
data.per_page_count = body_arr[5]
|
|
827
|
+
data.setData(body_arr[6])
|
|
828
|
+
data.date = body_arr[7]
|
|
829
|
+
data.setFields(body_arr[8])
|
|
830
|
+
|
|
831
|
+
return data
|
|
832
|
+
|
|
833
|
+
def query_shhk_stocks(date=""):
|
|
834
|
+
"""获取沪港通股票
|
|
835
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
836
|
+
"""
|
|
837
|
+
data = rs.ResultData()
|
|
838
|
+
|
|
839
|
+
if date is None or date == "":
|
|
840
|
+
date = ""
|
|
841
|
+
else:
|
|
842
|
+
if strUtil.is_valid_date(date):
|
|
843
|
+
pass
|
|
844
|
+
else:
|
|
845
|
+
print("日期格式不正确,请修改。")
|
|
846
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
847
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
848
|
+
return data
|
|
849
|
+
|
|
850
|
+
user_id = getattr(conx, "user_id")
|
|
851
|
+
try:
|
|
852
|
+
user_id = getattr(conx, "user_id")
|
|
853
|
+
except Exception:
|
|
854
|
+
print("you don't login.")
|
|
855
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
856
|
+
data.error_msg = "you don't login."
|
|
857
|
+
return data
|
|
858
|
+
|
|
859
|
+
param = "query_shhk_stocks," + str(user_id) + ",1," + \
|
|
860
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
861
|
+
"," + str(date)
|
|
862
|
+
|
|
863
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
864
|
+
msg_header = msgheader.to_message_header(
|
|
865
|
+
cons.MESSAGE_TYPE_QUERYSHHKSTOCK_REQUEST, len(msg_body))
|
|
866
|
+
|
|
867
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSHHKSTOCK_REQUEST
|
|
868
|
+
data.msg_body = msg_body
|
|
869
|
+
|
|
870
|
+
head_body = msg_header + msg_body
|
|
871
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
872
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
873
|
+
|
|
874
|
+
if receive_data is None or receive_data.strip() == "":
|
|
875
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
876
|
+
data.error_msg = "网络接收错误。"
|
|
877
|
+
return data
|
|
878
|
+
|
|
879
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
880
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
881
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
882
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
883
|
+
data.msg_body_length = header_arr[2]
|
|
884
|
+
data.error_code = body_arr[0]
|
|
885
|
+
data.error_msg = body_arr[1]
|
|
886
|
+
|
|
887
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
888
|
+
data.method = body_arr[2]
|
|
889
|
+
data.user_id = body_arr[3]
|
|
890
|
+
data.cur_page_num = body_arr[4]
|
|
891
|
+
data.per_page_count = body_arr[5]
|
|
892
|
+
data.setData(body_arr[6])
|
|
893
|
+
data.date = body_arr[7]
|
|
894
|
+
data.setFields(body_arr[8])
|
|
895
|
+
|
|
896
|
+
return data
|
|
897
|
+
|
|
898
|
+
def query_szhk_stocks(date=""):
|
|
899
|
+
"""获取深港通股票
|
|
900
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
901
|
+
"""
|
|
902
|
+
data = rs.ResultData()
|
|
903
|
+
|
|
904
|
+
if date is None or date == "":
|
|
905
|
+
date = ""
|
|
906
|
+
else:
|
|
907
|
+
if strUtil.is_valid_date(date):
|
|
908
|
+
pass
|
|
909
|
+
else:
|
|
910
|
+
print("日期格式不正确,请修改。")
|
|
911
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
912
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
913
|
+
return data
|
|
914
|
+
user_id = getattr(conx, "user_id")
|
|
915
|
+
try:
|
|
916
|
+
user_id = getattr(conx, "user_id")
|
|
917
|
+
except Exception:
|
|
918
|
+
print("you don't login.")
|
|
919
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
920
|
+
data.error_msg = "you don't login."
|
|
921
|
+
return data
|
|
922
|
+
|
|
923
|
+
param = "query_szhk_stocks," + str(user_id) + ",1," + \
|
|
924
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
925
|
+
"," + str(date)
|
|
926
|
+
|
|
927
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
928
|
+
msg_header = msgheader.to_message_header(
|
|
929
|
+
cons.MESSAGE_TYPE_QUERYSZHKSTOCK_REQUEST, len(msg_body))
|
|
930
|
+
|
|
931
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSZHKSTOCK_REQUEST
|
|
932
|
+
data.msg_body = msg_body
|
|
933
|
+
|
|
934
|
+
head_body = msg_header + msg_body
|
|
935
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
936
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
937
|
+
|
|
938
|
+
if receive_data is None or receive_data.strip() == "":
|
|
939
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
940
|
+
data.error_msg = "网络接收错误。"
|
|
941
|
+
return data
|
|
942
|
+
|
|
943
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
944
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
945
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
946
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
947
|
+
data.msg_body_length = header_arr[2]
|
|
948
|
+
data.error_code = body_arr[0]
|
|
949
|
+
data.error_msg = body_arr[1]
|
|
950
|
+
|
|
951
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
952
|
+
data.method = body_arr[2]
|
|
953
|
+
data.user_id = body_arr[3]
|
|
954
|
+
data.cur_page_num = body_arr[4]
|
|
955
|
+
data.per_page_count = body_arr[5]
|
|
956
|
+
data.setData(body_arr[6])
|
|
957
|
+
data.date = body_arr[7]
|
|
958
|
+
data.setFields(body_arr[8])
|
|
959
|
+
|
|
960
|
+
return data
|
|
961
|
+
|
|
962
|
+
def query_stocks_in_risk(date=""):
|
|
963
|
+
"""获取风险警示板分类
|
|
964
|
+
@param date:查询日期,默认为空。不为空时,格式 XXXX-XX-XX。
|
|
965
|
+
"""
|
|
966
|
+
data = rs.ResultData()
|
|
967
|
+
|
|
968
|
+
if date is None or date == "":
|
|
969
|
+
date = ""
|
|
970
|
+
else:
|
|
971
|
+
if strUtil.is_valid_date(date):
|
|
972
|
+
pass
|
|
973
|
+
else:
|
|
974
|
+
print("日期格式不正确,请修改。")
|
|
975
|
+
data.error_code = cons.BSERR_DATE_ERR
|
|
976
|
+
data.error_msg = "日期格式不正确,请修改。"
|
|
977
|
+
return data
|
|
978
|
+
user_id = getattr(conx, "user_id")
|
|
979
|
+
try:
|
|
980
|
+
user_id = getattr(conx, "user_id")
|
|
981
|
+
except Exception:
|
|
982
|
+
print("you don't login.")
|
|
983
|
+
data.error_code = cons.BSERR_NO_LOGIN
|
|
984
|
+
data.error_msg = "you don't login."
|
|
985
|
+
return data
|
|
986
|
+
|
|
987
|
+
param = "query_stocks_in_risk," + str(user_id) + ",1," + \
|
|
988
|
+
str(cons.BAOSTOCK_PER_PAGE_COUNT) + \
|
|
989
|
+
"," + str(date)
|
|
990
|
+
|
|
991
|
+
msg_body = strUtil.organize_msg_body(param)
|
|
992
|
+
msg_header = msgheader.to_message_header(
|
|
993
|
+
cons.MESSAGE_TYPE_QUERYSTOCKINRISK_REQUEST, len(msg_body))
|
|
994
|
+
|
|
995
|
+
data.msg_type = cons.MESSAGE_TYPE_QUERYSTOCKINRISK_REQUEST
|
|
996
|
+
data.msg_body = msg_body
|
|
997
|
+
|
|
998
|
+
head_body = msg_header + msg_body
|
|
999
|
+
crc32str = zlib.crc32(bytes(head_body, encoding='utf-8'))
|
|
1000
|
+
receive_data = sock.send_msg(head_body + cons.MESSAGE_SPLIT + str(crc32str))
|
|
1001
|
+
|
|
1002
|
+
if receive_data is None or receive_data.strip() == "":
|
|
1003
|
+
data.error_code = cons.BSERR_RECVSOCK_FAIL
|
|
1004
|
+
data.error_msg = "网络接收错误。"
|
|
1005
|
+
return data
|
|
1006
|
+
|
|
1007
|
+
msg_header = receive_data[0:cons.MESSAGE_HEADER_LENGTH]
|
|
1008
|
+
msg_body = receive_data[cons.MESSAGE_HEADER_LENGTH:-1]
|
|
1009
|
+
header_arr = msg_header.split(cons.MESSAGE_SPLIT)
|
|
1010
|
+
body_arr = msg_body.split(cons.MESSAGE_SPLIT)
|
|
1011
|
+
data.msg_body_length = header_arr[2]
|
|
1012
|
+
data.error_code = body_arr[0]
|
|
1013
|
+
data.error_msg = body_arr[1]
|
|
1014
|
+
|
|
1015
|
+
if cons.BSERR_SUCCESS == data.error_code:
|
|
1016
|
+
data.method = body_arr[2]
|
|
1017
|
+
data.user_id = body_arr[3]
|
|
1018
|
+
data.cur_page_num = body_arr[4]
|
|
1019
|
+
data.per_page_count = body_arr[5]
|
|
1020
|
+
data.setData(body_arr[6])
|
|
1021
|
+
data.date = body_arr[7]
|
|
1022
|
+
data.setFields(body_arr[8])
|
|
1023
|
+
|
|
1024
|
+
return data
|