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算法交易
掌握向量化回测
|
107
本章其余部分所述。有关
pandas
向量化基础知识和金融示例的更多信息,请参阅
Hilpisch
(
2018
,第
5
章)。
Numpy
为
Python
的数字计算世界带来了通用的向量化方法,而
pandas
允许对时序数据进行向量化。这对于实施金融算法和对算法交易策略进
行回测确实很有帮助。与标准的
Python
代码相比,比如利用
for
循环和
类似的常用方法来完成,通过使用这种方法,你可以期望代码更简洁,
执行速度更快,
4.2
基于简单移动平均线的策略
基于简单移动平均线(
SMA
)进行交易是一项具有数十年历史的策略,它起源于技
术股票分析领域。例如,布罗克(
Brock
)等(
1992
)的文章以系统的方式对这种策
略进行实证研究。他们写道:
“技术分析”一词是无数交易技术的总称……在本文中,我们探讨了两个最简
单且最受欢迎的技术规则:移动平均振荡和交易区间突破(阻力和支撑水平)。
在第一种方法中,买入和卖出信号是由两个移动平均线(一个长周期和一个短
周期)产生的。我们的研究表明,技术分析有助于预测股票变化。
4.2.1
入门基础
本节重点介绍两个基础的利用
SMA
进行交易回测的策略。下面的示例使用
EOD
数
据文件(
https://oreil.ly/AzE-p
)下
csv
文件中提供的欧元
/
美元汇率的日末(
EOD
)
收盘数据。数据集中的数据来自
Refinitiv Eikon Data API
,代表相应金融工具(
RIC
)
的日末值:
In [37]: raw = pd.read_csv('http://hilpisch.com/pyalgo_eikon_eod_data.csv', ...
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