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算法交易
204
|
第
6
章
2019-12-26 289.91 0.019646
2019-12-27 289.80 -0.000380
2019-12-30 291.52 0.005918
2019-12-31 293.65 0.007280
In [2]:
图 6-1:由 BacktestBase 类取回相应股票代码的数据图
随后的两部分介绍了一些类,用来回测仅做多和做空的交易策略。由于这些类依赖
了本节中介绍的基类,因此回测过程本身的实现非常简洁。
使用面向对象编程可以以
Python
类的形式构建基本的回测基础结构。此
类通过非冗余,易于维护的方式提供了对各种算法交易策略进行回测所
需的标准功能。还可以直接增强基类以便在默认情况下提供更多功能,
这些功能可以让在其上构建的许多其他类直接受益。
6.2
做多回测类
某些投资者的偏好或监管法规可能禁止将卖空作为交易策略的一部分。结果,仅允
许交易者或投资组合经理进入多头头寸或以现金或类似低风险资产(如货币市场账
构建基于事件回测的类
|
205
户)的形式存入资本。第
6.6.2
节展示了针对做多策略(称为
BacktestLongOnly
)
的回测类的代码。由于它依赖于
BacktestBase
类并从
BacktestBase
类继承,因此
用于实现基于
SMA
,动量和均值回归的三种策略的代码都非常简洁。 ...
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