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算法交易
82
|
第
3
章
这将获取
html
代码格式的新闻文本。
在
Jupyter Notebook
中,展示
HTML
代码……
……渲染
HTML
以便更好地阅读。
到此为止,我们介绍完了
Refinitiv Eikon
数据
API
的
Python
封装包。
3.4
高效存储金融数据
在算法交易中,管理数据集最重要的场景之一是“一次获取,多次使用”。或者从
输入输出(
IO
)角度来看,它是“一次写入,多次读取”。在第一种情况下,可能
会从
Web
服务中获取数据,然后根据数据集的临时内存副本将其用于多次回测一个
策略。在第二种情况下,连续接收到的实时数据被写入磁盘,随后又结合回测程序
多次用于某些操作(例如聚合)。
本节假定,无论从哪个源获取数据(从
CSV
文件,
Web
服务等),用于存储数据的
内存数据结构都是
pandas DataFrame
对象。
为了使数据集在大小方面有意义,本节通过使用伪随机数生成样本金融数据集。第
78
页的“
Python
脚本”为
Python
模块提供了一个名
为
generate_sam ple_data()
的函数,该函数可以完成这个任务。
原则上,此函数以任意大小的表格形式生成样本金融数据集(当然,可用内存会成
为一个限制):
In [60]: from sample_data import generate_sample_data
In [61]: print(generate_sample_data(rows=5, cols=4))
No0 No1 No2 No3
2021-01-01 ...
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