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算法交易
100
|
第
4
章
本章的内容如下。“利用向量化”介绍了向量化作为制定和回测交易策略的有用技
术方法。“基于简单移动平均线的策略”是本章的核心,并在一定程度上深入介绍
了基于
SMA
的策略的矢量回测。“基于动量的策略”介绍并回测了基于股票时序
动量(“近期表现”)的交易策略。“基于均值回归的策略”结束了本章,介绍了
均值回归策略。“数据窥探和过度拟合”讨论了在算法交易策略的回测情况下数据
窥探和过度拟合的陷阱。
本章的主要目标是掌握向量化的方法,该方法可以通过
NumPy
和
pandas
有效且快速
的完成。为此,对提出的方法进行了一些简化的假设,以使讨论更好地集中在向量
化的主题上。
在以下情况下,应考虑向量化回测:
简单交易策略
向量化回测方法在算法交易策略建模方面显然存在局限性。但是,许多流行的
简单策略都可以用向量化的方式进行回测。
互动策略探索
向量化回测允许对交易策略及其特征进行灵活,交互式的探索。通常只需几行
代码即可得出第一个结果,并且可以轻松测试不同的参数组合。
可视化为主要目标
该方法非常适合于可视化所用数据,统计信息,交易信号和结果表现。通常,
只需几行
Python
代码就能生成足以吸引人同时又洞察深刻的图。
全面的回测程序
通常,向量化回测速度非常快,允许人们在短时间内测试多种参数组合。当速
度是关键时,应考虑该方法。
4.1
利用向量化
向量化或数组编程是指一种编程样式,它把对标量(即整数或浮点数)的操作转化
为向量,矩阵甚至多维数组。考虑一个整数向量
v
= (1
,
2
,
3
,
4
,
5)
T
,在
Python
中表示为列表对象 ...
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