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算法交易
252
|
第
8
章
这是一个重要的里程碑:我们可以连接到
Oanda API
获取历史数据,以编程的方式
下订单,以及更多的可以做的事情。
使用
configparser
模块的好处在于,它简化了账户凭据的存储和管理。
在算法交易中,有很多需要管理的账户。例如:云实例或服务器,数据
服务提供商,在线交易平台等。
弊端在于,账户信息以纯文本形式存储,这会有相当大的安全风险,特
别是多个账户的信息存储在单个文件中。因此,在进入生产环境时,你
应采用例如文件加密的方法来确保凭据安全。
8.3
获取历史数据
使用
Oanda
平台的主要好处是可以通过
RESTful API
的方式访问所有
Oanda
金融工
具的完整历史价格记录。这里的完整历史记录指的是不同的差价合约本身
-
而不是
其定价背后的金融工具。
8.3.1
查询可交易的金融工具
给定一个账户,如果要查询可交易的金融工具有哪些,请使用
.get_instruments()
方法。但它仅从
API
获取显示名称和技术名称。还可通过
API
获取更多详细信息,
例如最小头寸大小。
In [3]: api.get_instruments()[:15]
Out[3]: [('AUD/CAD', 'AUD_CAD'),
('AUD/CHF', 'AUD_CHF'),
('AUD/HKD', 'AUD_HKD'),
('AUD/JPY', 'AUD_JPY'),
('AUD/NZD', 'AUD_NZD'),
('AUD/SGD', 'AUD_SGD'), ...
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