Skip to Content
Python算法交易
book

Python算法交易

by Yves Hilpisch
November 2022
Intermediate to advanced
392 pages
10h 8m
Chinese
China Electric Power Press Ltd.
Content preview from Python算法交易
通过机器学习预测市场动向
|
155
In [45]: hits = np.sign(data['return'] *
data['prediction']).value_counts()
In [46]: hits
Out[46]: 1.0 1301
-1.0 1191
0.0 13
dtype: int64
In [47]: hits.values[0] / sum(hits)
Out[47]: 0.5193612774451097
这直接使用要预测的数据“
return
”列的符号来进行回归。
另外,对于预测步骤仅符号是相关的。
5.1.6
基于回归策略的向量化回测
到目前为止,仅使用命中率并不能充分说明使用线性回归的交易策略的经济潜力。
众所周知,在给定的时间段内,市场上十个最佳和最差的日子会极大地影响投资的
整体表现。
注
2
在理想的世界中,多空交易者当然会尝试从适当的市场时机指数的基
础上,分别通过做多和做空来选择最佳和最差的日子而受益。与当前情况相比,这
意味着除了命中率之外,市场时机的质量也很重要。因此,按照第
4
章中的方法进
行回测可以更好地了解用于预测的回归值。
给定已经可用的数据,向量化回测可归结为两行
Python
代码,包括可视化。这是由
于以下事实:预测值已经反映了市场头寸(多头或空头)。图
5-6
展示了在当前假设下,
该策略的表现明显优于市场(尤其是忽略交易成本):
In [48]: data.head()
Out[48]: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
图解大模型 : 生成式AI 原理与实战

图解大模型 : 生成式AI 原理与实战

Jay Alammar, Maarten Grootendorst

Publisher Resources

ISBN: 9787519869694