请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  源码分享 帖子:3352778 新帖:53

Python3版本引擎上线

我是游客发表于:5 月 9 日 17:17回复(1)

由于Python社区将在2020年停止Python2.7的支持,我们新上线了Python3引擎。新的Python3引擎使用与研究模块Python3内核相同的环境,大家终于可以在回测中使用心心念念的TensorFlow了~
新创建的策略将默认使用Python3引擎创建,用户已有策略仍然使用Python2引擎。在未来我们将逐步停止对Python2引擎的更新,所有的新特性也将只在Python3引擎上线,所以强烈建议大家将已有策略迁移到Python3引擎上。

注意

已知问题:Python3环境下使用pickle保存的对象无法在Python2环境下解析;Python3环境下解析Python2中pickle保存的对象,请参考:pickle - Unpickling a python 2 object with python 3 - Stack Overflow。

Python3与Python2常见的区别:

  • Python3中严格区分byte与str。
  • print从Python2中的关键字转变为了函数,意味着以下写法:
    print "hello world"将在Python3中报错。
  • /在Python2返回结果向下取整,在Python3中将直接返回结果不进行任何取舍,需要Python2中的行为时请使用//
  • 修改了一些语法。metaclass,raise、map、filter以及dict的items/keys/values方法返回迭代对象而不是列表,描述符协议,保存类属性定义顺序,存关键字参数顺序。
  • 去掉了一些语法。cmp、<>(也就是!=)、xrange(其实就是range)、不再有经典类。

简单粗暴的Python2->Python3迁移办法:

在文件头引入six模块:
from six import *
更多six的用法详见:https://pythonhosted.org/six

Python2环境与Python3环境的区别:

Python3环境新增第三方库:

Name                         Version
---------------------------  --------------------
tinynetrc                    1.3.0
numdifftools                 0.9.20
chainer                      5.1.0
astor                        0.7.1
pytdx                        1.67
uncertainties                3.0.3
pathspec                     0.5.9
qgrid                        1.1.1
keras-applications           1.0.6
multiprocess                 0.70.7
async-timeout                3.0.1
intervaltree                 3.0.2
easyquotation                0.5.12
tensorflow                   1.12.0
python-highcharts            0.4.2
aiohttp                      3.5.0
selenium                     3.141.0
keras-preprocessing          1.0.5
chardet                      3.0.4
jupyterlab                   0.35.4
idna                         2.8
asn1crypto                   0.24.0
lml                          0.0.2
torch                        1.0.0
pyquery                      1.4.0
google-pasta                 0.1.3
msgpack                      0.6.0
trading-calendars            1.7.0
tabulate                     0.8.2
tf-nightly                   1.13.0.dev20190217
docutils                     0.14
minepy                       1.2.2
cvxpy                        1.0.11
scs                          2.0.2
bkcharts                     0.2
joblib                       0.12.5
pipdate                      0.3.1
pymc3                        3.6
importlib-metadata           0.8
yarl                         1.3.0
parso                        0.3.4
dukpy                        0.2.2
cryptography                 2.5
termcolor                    1.1.0
mkl-fft                      1.0.6
osqp                         0.5.0
fire                         0.1.3
ecos                         2.0.7.post1
pydot-ng                     2.0.0
asteval                      0.9.13
macropy3                     1.1.0b2
lru-dict                     1.1.6
future                       0.17.1
structure                    0.1.dev16
pyecharts                    0.5.11
thriftpy2                    0.4.0
python-editor                1.0.3
rpy2                         2.9.5
idna-ssl                     1.1.0
tb-nightly                   1.13.0a20190217
backcall                     0.1.0
pyecharts-jupyter-installer  0.0.3
jupyter-pip                  0.3.1
gast                         0.2.0
mpmath                       1.1.0
lightgbm                     2.2.2
websocket-client             0.54.0
alembic                      1.0.7
mkl-random                   1.0.1
easyutils                    0.1.7
keras                        2.2.4
twilio                       6.22.0
olefile                      0.46
nb-jq-ext                    0.6.7
wxpy                         0.3.9.8
geographiclib                1.49
javascripthon                0.10
filelock                     3.0.10
gym                          0.10.9
ffn                          0.3.4
jupyter-echarts-pypkg        0.1.2
pydot                        1.4.1
s3transfer                   0.2.0
python-oauth2                1.1.0
zipp                         0.3.3
fushare                      1.1.12
tqdm                         4.28.1
sortedcontainers             2.1.0
kiwisolver                   1.0.1
botocore                     1.12.96
ruamel-yaml                  0.15.37
absl-py                      0.6.1
pyopenssl                    18.0.0
torchvision                  0.2.1
pytest-metadata              1.7.0
jupyterhub                   0.8.1
multidict                    4.5.2
jmespath                     0.9.3
algopy                       0.5.7
singledispatch               3.4.0.3
conda                        4.5.4
dask                         1.1.1
mako                         1.0.7
readline                     6.2.4.1
mxnet                        1.3.1
pyjwt                        1.7.1
urllib3                      1.24.1
cffi                         1.11.5
pysocks                      1.6.8
tf-estimator-nightly         1.14.0.dev2019021701
jedi                         0.13.2
pyecharts-snapshot           0.1.10
pyecharts-javascripthon      0.0.6
jupyterlab-server            0.2.0
pyflux                       0.4.15
boto3                        1.9.96
pyglet                       1.3.2
pycparser                    2.18
bs4                          0.0.1
cssselect                    1.0.3
pamela                       0.3.0
tensorboard                  1.12.1
grpcio                       1.17.1
autograd                     1.2
multipledispatch             0.6.0
h5py                         2.9.0
typing-extensions            3.7.2

Python3环境移除的第三方库:

Name                 Version
-------------------  --------------
pyevolve             0.6rc1
supervisor-twiddler  1.0.0
uwsgi                2.0.15
supervisor           3.1.3
functools32          3.2.3.post2
beautifulsoup        3.2.1
meliae               =0.4.0.final.0
enum34               1.0.4
subprocess32         3.5.3
configparser         3.7.1

Python3引擎中版本发生变化的第三方库:

注意Pandas和Numpy的版本变化较大

Name               Python3       Python2
-----------------  ------------  -------
apipkg             1.5           1.4
arch               4.7.0         3.1
atomicwrites       1.2.1         1.1.5
attrs              18.2.0        18.1.0
beautifulsoup4     4.6.3         4.5.1
bleach             3.0.2         3.1.0
bokeh              1.0.2         0.9.3
boto               2.49.0        2.38.0
bottleneck         1.2.0         1.0.0
cached-property    1.5.1         1.3.0
certifi            2018.11.29    14.5.14
click              7.0           6.6
cloudpickle        0.6.1         0.1.0
colorama           0.4.1         0.3.3
coverage           4.5.2         3.7.1
croniter           0.3.26        0.3.19
cython             0.29.2        0.23.4
deap               1.2.2         1.0.2
decorator          4.3.0         4.0.11
dill               0.2.8.2       0.2.5
diskcache          3.1.1         2.3.0
dtw                1.3           1.2
empyrical          0.5.0         0.2.2
entrypoints        0.2.3         0.3
execnet            1.5.0         1.4.1
gensim             3.6.0         0.12.2
geopy              1.18.0        1.11.0
gevent             1.3.7         1.0.1
gevent-websocket   0.10.1        0.9.3
graphviz           0.8.4         0.4.10
greenlet           0.4.15        0.4.14
httpretty          0.9.6         0.8.6
interruptingcow    0.8           0.7
ipython            7.2.0         5.8.0
ipython-genutils   0.2.0         0.1.0
itchat             1.2.32        1.3.7
itsdangerous       1.1.0         0.24
jdcal              1.4           1.3
jieba              0.39          0.37
llvmlite           0.26.0        0.6.0
lmfit              0.9.12        0.9.5
logbook            1.4.1         0.12.5
lxml               4.2.5         4.2.3
markupsafe         1.1.0         0.23
matplotlib         3.0.2         2.0.2
mistune            0.8.4         0.8.1
more-itertools     4.3.0         4.2.0
mysqlclient        1.3.14        1.3.13
netifaces          0.10.7        0.10.4
networkx           2.2           1.11
nltk               3.4           3.3
notebook           =5.4.1-jq     5.4.1
numba              0.41.0        0.20.0
numexpr            2.6.8         2.6.1
numpy              1.14.6        1.9.3
objgraph           3.4.0         2.0.1
openpyxl           2.5.12        2.5.9
packaging          18.0          16.8
pandas             0.23.4        0.16.2
pandas-datareader  0.7.0         0.2.1
path.py            11.5.0        8.1.2
pathlib2           2.3.3         2.3.2
patsy              0.5.1         0.4.1
pbr                5.1.1         1.8.1
peppercorn         0.6           0.5
pexpect            4.6.0         4.0.1
pickleshare        0.7.5         0.5
pika               0.12.0        0.10.0
pillow             5.3.0         3.4.1
plotly             3.4.2         3.3.0
pluggy             0.8.0         0.6.0
ply                3.11          3.10
prompt-toolkit     2.0.7         1.0.15
protobuf           3.6.1         3.2.0
psutil             5.4.8         5.1.3
psycopg2           2.7.6.1       2.7.4
psycopg2-binary    2.7.6.1       2.7.4
ptyprocess         0.6.0         0.5
pyasn1             0.4.1         0.1.9
pybrain            0.3.3         0.3
pycosat            0.6.3         0.6.1
pyee               5.0.0         1.0.1
pyflakes           2.0.0         1.5.0
pyfolio            0.9.0         0.7.0
pygments           2.3.1         2.2.0
pyparsing          2.3.0         2.2.0
pytesseract        0.2.6         0.1.6
pytest             4.0.2         3.6.2
pytest-cov         2.6.0         2.5.1
pytest-html        1.19.0        1.3.1
pytest-timeout     1.3.3         1.2.0
pytest-xdist       1.25.0        1.20.0
python-dateutil    2.7.5         2.6.0
python-hessian     1.1.0         1.0.2
pytz               2018.7        2017.2
pywavelets         1.0.1         0.4.0
pyyaml             3.13          3.12
pyzmq              17.1.2        16.0.2
raven              6.10.0        6.1.0
redis              3.0.1         2.10.6
requests           2.21.0        2.9.1
rsa                4.0           3.4.2
scikit-image       0.14.1        0.11.3
scikit-learn       0.19.2        0.18.1
scipy              1.2.0         0.16.0
seaborn            0.9.0         0.7.1
setuptools-scm     3.1.0         3.0.4
simplejson         3.16.0        3.8.0
six                1.12.0        1.10.0
smart-open         1.7.1         1.3.0
sqlalchemy         1.2.15        1.2.11
statsmodels        0.9.0         0.8.0
sympy              1.3           0.7.6.1
ta-lib             0.4.17        0.4.9
tables             3.4.4         3.2.2
theano             1.0.3         0.9.0
thrift-connector   0.24          0.23
toolz              0.9.0         0.7.4
tornado            4.5.3         4.2.1
tushare            1.2.18        0.8.2
ujson              1.35          1.33
xgboost            0.81          0.72.1
xlrd               1.2.0         1.0.0
xlwt               1.3.0         1.1.2
zipline            1.3.0         0.9.0

全部回复

0/140

达人推荐

量化课程

    移动端课程