shidenggui / easyquant Goto Github PK
View Code? Open in Web Editor NEW股票量化框架,支持行情获取以及交易
股票量化框架,支持行情获取以及交易
Traceback (most recent call last):
File "test.py", line 100, in
m = easyquant.MainEngine(broker_data, account_data, quotation_engines=[quotation_engine], log_handler=log_data)
File "D:\easyquant\easyquant\main_engine.py", line 44, in init
self.user.prepare(need_data)
File "C:\Python36\lib\site-packages\easytrader\webtrader.py", line 73, in prepare
self.autologin()
File "C:\Python36\lib\site-packages\easytrader\webtrader.py", line 84, in autologin
if self.login():
File "C:\Python36\lib\site-packages\easytrader\gftrader.py", line 78, in login
login_status, result = self.post_login_data(verify_code)
File "C:\Python36\lib\site-packages\easytrader\gftrader.py", line 96, in post_login_data
self.__set_trade_need_info()
File "C:\Python36\lib\site-packages\easytrader\gftrader.py", line 155, in __set_trade_need_info
jsholder = eval(jsholder[0])
IndexError: list index out of range
strategy 行情事件不触发
代码都改成'sz000001'的格式,这样能避免将来扩展时很多问题
另外, 建议easyquant和easyhistory公用一套代码表
增加对交易系统的时间控制,可以在指定交易时间启动
第三种设置的选项为同时在屏幕输出和记录到文件中
环境 python 3.5
IDE PYCHARM
log如下:
[2016-02-24 11:05:59.442630] DEBUG: helpers.py: java detect result: java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
[2016-02-24 11:05:59.910963] DEBUG: helpers.py: recognize output: file=E:\Trader\easyquant\vcode
code=C4bj
[2016-02-24 11:06:03.348539] INFO: main_engine.py: 加载策略: 策略1
[2016-02-24 11:06:03.350540] INFO: main_engine.py: 加载策略完毕
启动主引擎
Process finished with exit code 0
最新版本 py test.py
sina的行情不工作
最近看到京东出了一个kuant站:http://quant.jd.com/;看了一下它的文档,觉得它的框架不错,食灯鬼大神可以借鉴一下。
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000000009364080>
self.quotation_engines.append(quotation_engine(self.event_engine, self.clock_engine))
这里的quotation_engine是一个str的类型。运行到这里直接错误退出。
错误类型:
TypeError: 'str' object is not callable
原以为这里的 quotation_engine(....)应该是在quotation_engine.py里面定义的quotation_engine类。
但是没有找到。就在quotation_engine.py里面重新继承了一个quotation_engine才通过。
不知道哪里出了问题。
现在 CTRL C 不能终止程序了?
为什么触发不了_shutdown(self, sig, frame)
环境 :Windows10 python3.6.12
easyquant的engine在非交易日关闭后重新启动时,会出现ClockMomentHandler在下一个交易日的00:00:00执行买卖的问题。
是因为ClockMomentHandler的init函数在第一次设置下次运行时间next_time的时候,对于is_trading_date为True和False都用当天的日期来设置next_time,但是对于is_trading_date为True,是需要交易日才执行定时任务。
修改方式:在创建ClockMomentHandler时,在init函数中设置next_time的时候,如果engine重启当天是非交易日,取下一交易日的日期来设置next_time。
#70
支持导出到文件或者相关的数据库
作者您好,我在ubuntu上安装了easyquant,库都已经安装好了,我是使用雪球登录的,但是在运行test.py的时候,报错了markup未定义,不知道您在调试的时候是否也有这个问题?或者您可以指点一下方向?感谢您。
————————————————————————————————————————————
brian@ubuntu:~/py/easyquant$ python3 test.py
easyquant 测试 DEMO
请输入你使用的券商:
1: 华泰 2: 佣金宝 3: 银河 4: 雪球模拟组合 5: 广发
:4
请输入你的帐号配置文件路径(直接回车使用 xq.json)
:
请输入使用行情引擎 1: sina 2: leverfun 十档 行情(目前只选择了 162411, 000002)
:1
请输入行情推送间隔(s)
:10
请输入 log 记录方式: 1: 显示在屏幕 2: 记录到指定文件
: 1
[2016-06-27 21:32:21.421482] DEBUG: xqtrader.py: login status: SUCCESS
[2016-06-27 21:32:21.467099] INFO: 测试: 启动主引擎
[2016-06-27 21:32:21.474106] INFO: 测试: 加载策略: 策略2_Demo
Traceback (most recent call last):
File "test.py", line 57, in
m.load_strategy()
File "/home/brian/py/easyquant/easyquant/main_engine.py", line 86, in load_strategy
self.strategy_list.append(strategy_class(log_handler=self.log, main_engine=self))
File "/home/brian/py/easyquant/easyquant/strategy/strategyTemplate.py", line 19, in init
self.init()
File "/home/brian/py/easyquant/strategies/策略1_Demo.py", line 16, in init
self.clock_engine.register_moment(clock_type, moment)
File "/home/brian/py/easyquant/easyquant/push_engine/clock_engine.py", line 233, in register_moment
return self._register_moment(clock_type, moment, makeup=markup)
NameError: name 'markup' is not defined
brian@ubuntu:~/py/easyquant$ python3 -m pip install markup
Requirement already satisfied (use --upgrade to upgrade): markup in /usr/local/lib/python3.5/dist-packages
with open(ACCOUNT_OBJECT_FILE, 'wb') as f:
dill.dump(self.user, f)
佣金宝和雪球账号执行到上一行时出现错误:
TypeError: Cannot serialize socket object
能否添加技术指标的运算?
用pip install或进入其文件夹内用python setup.py都不能安装!
环境:win7
import easytrader
user = easytrader.use('yh_client')
user.prepare(user='123456',password='678900')
报错:
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'NoneType' object has no attribute 'prepare'
可以保存相关数据并导出到数据库(mongodb、mysql、postgresql)等
请问怎么获取广发 加密的客户号 和 加密的密码
报错显示未实现
dateutil(s) miss 's'?
请问大佬有计划在主引擎加入直连同花顺客户端的打算吗?
可在本地记录信息,用于策略测试
Jun 15, 2016 commit的clock_engine中moment事件无法触发,May 22, 2016的clock_engine版本正常。
目前看来Jun 15, 2016的clock_engine存在下面问题:
if self.is_trading_date and not etime.is_trade_date(self.clock_engine.now_dt):中,etime.is_trade_date前多了个not,导致交易日is_active变为False。应该去掉这个not。
你好,
20190430,刚才发现使用quotation = easyquotation.use('sina')后,股票代码仍然没有 :
000876新希望,使用tencent时候有。
不同数据来源,有没有其他主要区别,能不能介绍一下。
谢谢
from easyquant import StrategyTemplate
import tushare as ts
import datetime
ts.set_token('*******************************')
class Strategy(StrategyTemplate):
def strategy(self, event):
#------------------------时间---------------------------------------
today = datetime.date.today().strftime("%Y%m%d")
mt = ts.Master()
yesterday = mt.TradeCal(exchangeCD='XSHG', beginDate=today, endDate=today, field='prevTradeDate')
yesterday = yesterday['prevTradeDate'].values
yesterday = yesterday[0][0:4] + yesterday[0][5:7] + yesterday[0][8:10]
#---------------------股票池获取-------------------------------------
eq = ts.Equity()
stockList = eq.Equ(equTypeCD='A', listStatusCD='L', field='ticker')
print(stockList[0:2])
return
当在strategy中调用tushare的接口时,出现bug,貌似与多线程有关。
可以将相关的持仓以及交易信息导出到 mongodb
File "D:\programs\python\easyquant-master\easyquant\easydealutils\time.py", li
ne 51, in calc_next_trade_time_delta_seconds
next_trade_start = now_time.replace(day=now_time.day + 1, hour=9, minute=15,
second=0)
ValueError: day is out of range for month
day=now_time.day + 1 不能用数字计算,应该改成日期运算
线程一直在增加,最后内存耗尽。
Threads: 168 total, 0 running, 168 sleeping, 0 stopped, 0 zombie
%Cpu(s): 8.3 us, 0.3 sy, 0.0 ni, 91.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1016244 total, 297844 free, 201716 used, 516684 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 625336 avail Mem
更新了,还是不行啊
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.