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算法交易
198
|
第
6
章
测苹果公司股票的交易策略为例,该事件可能是苹果股票的新收盘价,也可能是利
率变化或者触发了止损线。基于事件的回测方法的优点通常如下:
增量式
与现实中的交易一样,回测是在新数据逐渐增加,逐笔报价的前提下进行的。
真实感建模
你可以完全自由地为由新的特定事件触发的那些流程建模。
路径依赖
跟踪条件,递归或其他与路径相关的统计信息(例如到目前为止看到的最高价
或最低价),都将包括在交易算法中,并且非常简单。
可重用性
回测不同类型的交易策略只需要一个相似的基本功能,可以通过面向对象的编
程来实现和统一这些功能。
接近交易
基于事件的回测系统的某些东西有时也可以用于交易策略的自动执行。
在下文中,通常用一个柱线来标识一个新事件,该柱线代表一个新数据。例如,事
件可以是日内交易策略的分时图,也可以是基于每日收盘价的交易策略的日线图。
本章组织如下。“回测基本类”介绍了基于事件的交易策略回测的基本类。“做多
回测类”
和“多空回测类”分别利用基类来实现做多和多空回测类。
本章的目的是了解基于事件的建模,创建更贴近现实的回测类,并提供基础的回测
框架作为进一步增强和改进的起点。
6.1
回测基础类
对于基于事件的回测,以
Python
类的形式构建基础结构时,必须满足以下几个要求:
获取和准备数据
基类应负责数据获取,尽可能地为回测本身做好准备。为了使讨论更加目标明确,
基类可以从
CSV
文件读取日末(
EOD
)数据。
构建基于事件回测的类
|
199
辅助函数和便利函数
它应提供一些辅助和便利的函数,使回测更加容易。下面的示例包含用于绘制 ...
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