{"id":13487930,"url":"https://github.com/GraySilver/wencai","last_synced_at":"2025-03-27T23:32:09.415Z","repository":{"id":37811256,"uuid":"112180026","full_name":"GraySilver/wencai","owner":"GraySilver","description":"This is a wencai crawler.（i问财的策略回测接口的Pythonic工具包）","archived":false,"fork":false,"pushed_at":"2022-10-16T15:27:38.000Z","size":181,"stargazers_count":287,"open_issues_count":16,"forks_count":119,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-10-30T23:36:11.399Z","etag":null,"topics":["crawler","finance","pandas","quant","quantitative-finance","tushare","wencai"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GraySilver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-27T10:08:30.000Z","updated_at":"2024-10-27T00:02:45.000Z","dependencies_parsed_at":"2023-01-19T14:01:50.376Z","dependency_job_id":null,"html_url":"https://github.com/GraySilver/wencai","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraySilver%2Fwencai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraySilver%2Fwencai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraySilver%2Fwencai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraySilver%2Fwencai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GraySilver","download_url":"https://codeload.github.com/GraySilver/wencai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245944020,"owners_count":20697945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crawler","finance","pandas","quant","quantitative-finance","tushare","wencai"],"created_at":"2024-07-31T18:01:06.651Z","updated_at":"2025-03-27T23:32:04.384Z","avatar_url":"https://github.com/GraySilver.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# wencai\n\n[![PyPi Version](https://img.shields.io/pypi/v/wencai.svg)](https://pypi.org/project/wencai/)[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)[![Linux](https://travis-ci.com/GraySilver/wencai.svg?branch=master)](https://travis-ci.org/GraySilver/wencai) \n\nwencai是i问财的策略回测接口的Pythonic工具包，满足量化爱好者和数据分析师在量化方面的需求。\n\n[i问财](http://www.iwencai.net/)是同花顺旗下专业的机器人智能选股问答平台,致力于为投资者提供宏观数据、新闻资讯、A股、港美股、新三板、基金等各类理财方案。\n\n![](https://graysliver.oss-cn-shenzhen.aliyuncs.com/iwcpage.jpg)\n\n![](https://graysliver.oss-cn-shenzhen.aliyuncs.com/iwc_strategy.JPG)\n\n### Latest Version\n\n```\nwencai==0.2.6\n```\n\n### Dependencies\n\n- Python 2.x/3.x（当前测试使用Python3.5.5）\n- requests\u003e=2.14.2\n- beautifulsoup4\u003e=4.5.1\n- PyExecJS\u003e=1.5.1\n\n### Installation\n\n- 方式1：pip install wencai\n- 方式2：git clone 此github项目，然后进入根目录后进行```python setup.py install```\n- 方式3：访问\u003chttps://pypi.python.org/pypi/wencai\u003e下载安装\n\n### Upgrade\n\n```shell\npip install wencai --upgrade\n```\n\n### API\n\n具体API接口请点击这里：[Wiki](https://github.com/GraySilver/wencai/blob/master/API.md)\n\n### Quick Start\n\n**Example 1**. 获取回测分析\n\n```python\nimport wencai as wc\n\n# 若需中文字段则cn_col=True,chromedriver路径不在根目录下需指定execute_path\nwc.set_variable(cn_col=True)\n\nstrategy = wc.get_scrape_report(query='上证指数上穿10日均线',\n                                 start_date='2019-10-01',\n                                 end_date='2019-10-19',\n                                 period='1,2,3,4',\n                                 benchmark='hs000300')\n\nprint(strategy.backtest_data)\n```\n\n\u003e 平均区间涨跌幅       盈亏比  次日开盘平均涨跌幅  持有期    次日高开概率  同期基准  基准上涨概率     最大涨跌幅     最小涨跌幅      上涨概率\n\u003e\n\u003e 0  0.000452  1.049851   0.000191    1  0.389201     0       0  0.101504 -0.100000  0.467942\n\u003e\n\u003e 1  0.002819  1.248264   0.000552    2  0.396705     0       0  0.210123 -0.108460  0.494297\n\u003e\n\u003e 2  0.005292  1.425027   0.001694    3  0.425254     0       0  0.330961 -0.117544  0.526851\n\u003e\n\u003e 3  0.005753  1.406133   0.002266    4  0.435000     0       0  0.377018 -0.124862  0.508333\n\n\n\n**Example 2**.获取策略\n\n```python\nimport wencai as wc\n\n# 若需中文字段则cn_col=True,chromedriver路径不在根目录下需指定execute_path\nwc.set_variable(cn_col=True)\n\ntransaction = wc..get_strategy(query='非停牌；非st；今日振幅小于5%；量比小于1；涨跌幅大于-5%小于1%；流通市值小于20亿；市盈率大于25小于80；主力控盘比例从大到小',\n                               start_date='2018-10-09',\n                               end_date='2019-07-16',\n                               period='1',\n                               fall_income=1,\n                               lower_income=5,\n                               upper_income=9,\n                               day_buy_stock_num=1,\n                               stock_hold=2)\n\nprint(transaction.history_pick(trade_date='2019-07-16', hold_num=1))\n```\n\n\u003e 涨跌幅  当日收盘价（元)   dde大单净量（%） 股本规模    股票代码 股票市场  股票名称         换手率\n\u003e\n\u003e 0  -0.10152284      9.84  -0.11978362  小盘股  002599   SZ  盛通股份  0.63294771\n\n**Example 3**.获取事件评测\n\n```python\nimport wencai as wc\n\n# 若需中文字段则cn_col=True,chromedriver路径不在根目录下需指定execute_path\nwc.set_variable(cn_col=True)\n\nreport = wc.get_event_evaluate(end_date='2019-07-16', \n                               index_code=\"1a0001\", \n                               period='1', \n                               query=\"上证指数上穿10日均线\",\n                               start_date=\"2016-05-16\")\nprint(report.event_list)\nprint(report.report_data)\n```\n\n\u003e {'最大上涨概率': 9.506849315068482e-05, '最优平均涨跌幅': 0.5753424657534246, '历史发生次数': 73}\n\n\u003e次日涨跌幅      事件日期  涉及标的\n\u003e\n\u003e0   -0.02580  20190705  上证指数\n\u003e\n\u003e1    0.00088  20190617  上证指数\n\u003e\n\u003e2   -0.00558  20190611  上证指数\n\u003e\n\u003e3    0.00165  20190528  上证指数\n\u003e\n\u003e4   -0.00491  20190521  上证指数\n\u003e\n\u003e5    0.00580  20190515  上证指数\n\n**Example 4**.一键搜索(目前仅能获取首页内容)\n\n```python\nimport wencai as wc\n\nresult = wc.search(query=\"当前热股\")\nprint(result)\n```\n\n\u003e  开盘价           成交量      振幅     收盘价     最低价     最新价     最高价       股票代码  股票简称\n\u003e\n\u003e 0     7.21   85040786.00  19.556    8.43    7.18    8.43    8.59  300320.SZ  海达股份\n\u003e\n\u003e 1     3.67   77019302.00  10.354    4.04    3.66    4.04    4.04  000420.SZ  吉林化纤\n\u003e\n\u003e 2    12.23   59261312.00  11.318   13.61   12.21   13.61   13.61  002386.SZ  天原股份\n\u003e\n\u003e 3    11.10   44611374.00   7.050   11.86   11.10   11.86   11.86  000848.SZ  承德露露\n\u003e\n\u003e 4     9.30   29671324.00  11.915   10.34    9.22   10.34   10.34  605167.SH   利柏特\n\u003e\n\u003e 5    24.55   12190900.00   6.571   26.11   24.55   26.11   26.11  002895.SZ  川恒股份\n\u003e\n\u003e 6    35.36   35961355.00  14.455   38.57   34.77   38.57   39.88  300087.SZ  荃银高科\n\u003e\n\u003e 7    20.15   12087816.00  11.204   22.08   20.11   22.08   22.39  603855.SH  华荣股份\n\u003e\n\u003e 8    21.00   13255236.00  20.170   23.02   20.70   23.02   24.98  300602.SZ   飞荣达\n\u003e\n\u003e 9    23.41   19325582.00  10.612   25.24   23.21   25.24   25.69  002741.SZ  光华科技\n\n**Example 5**.使用代理机制\n\n```python\nimport wencai as wc\n\n# 多个代理池\nproxies = [{'http': 'http://localhost:1087', 'https': 'http://localhost:1087'},\n          {'http': 'http://localhost:1088', 'https': 'http://localhost:1088'}]\n\n# 单个代理池\nproxies = {'http': 'http://localhost:1087', 'https': 'http://localhost:1087'}\n\nwc.set_variable(cn_col=True, proxies=proxies)\n\nr = wc.search('当前热股')\nprint(r)\n\n```\n\n### Change Logs\n\n### 0.2.6 2021/09/11\n\n- 修复pip包无hexin.js问题\n\n### 0.2.5 2021/08/13\n\n- 更新Cookies机制；\n- 新增分时数据接口。\n- 新增一键搜索(目前仅能获取首页内容)\n- 新增代理机制\n\n### 0.2.2 2021/04/08\n\n- 正常测试接口是否可用；\n- 优化报错会直接返回接口结果；\n- cookies缓存带有时效性。\n\n### 0.2.0 2021/01/07\n\n- 正常测试接口是否可用；\n- 补充说明调用逻辑。\n\n### 0.2.0 2019/10/19\n\n- 重构问财接口调用逻辑；\n- 新增chromedriver调用接口；\n- 新增【事件评测】接口；\n\n### 0.1.5 2018/3/5\n\n- 修正：调用问财策略接口失败问题\n\n### 0.1.3 2017/11/27\n\n- 创建第一个版本\n\n### Others\n此工具包不得用于任何商业目的，仅可用于爱好量化交易者分享学习和技术讨论。\n\nWelcome to Star and Follow~\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraySilver%2Fwencai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGraySilver%2Fwencai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraySilver%2Fwencai/lists"}