Skip to Content
Python金融实战
book

Python金融实战

by Posts & Telecom Press, Yuxing Yan
February 2024
Intermediate to advanced content levelIntermediate to advanced
347 pages
5h 19m
Chinese
Packt Publishing
Content preview from Python金融实战

第7章 用matplotlib模块绘制与金融相关的图形

图表等视觉表现方式越来越多地被用来解释许多复杂的金融概念、公式和交易策略。本章将讨论如何用matplotlib模块来创建不同类型的图形。此外,将在第9章使用此模块讨论著名的Black-Scholes-Merton期权模型和期权交易策略。matplotlib模块用来制作高质量的图形和图像,与第6章介绍的NumPy和SciPy模块密切相关,并且有多种输出格式,如PDF、Postscript、SVG和PNG等。本章将介绍以下内容。

  • 安装matplotlib模块的几种方式
  • 使用matplotlib模块的简单例子
  • 净现值(NPV)的图示、杜邦等式、股票收益率和直方图
  • 整体风险、市场风险和非系统风险
  • 股票之间的联动度和相关系数
  • 分散投资风险
  • 绘制交易量和价格变动的图形
  • 几只股票的回报率和风险坐标图
  • 使用matplotlib模块的复杂例子

安装matplotlib模块的第1个办法是使用ActivePython软件。首先安装ActivePython软件,然后安装matplotlib模块。在安装matplotlib模块的过程中,NumPy模块会自动安装,因为matplotlib模块依赖于NumPy和SciPy这两个模块。整个过程有如下4个步骤。

1.转到http://www.activestate.com/activepython/downloads

2.选择适合的可执行文件进行下载。

3.在Windows操作系统下,单击所有程序|附件,然后单击命令提示符,会看到图7-1所示的窗口。

图7-1

4.来到Python的安装目录C:\Python27下,按照图7-2所示输入 ...

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.
Start your free trial

You might also like

实时数据处理和分析指南

实时数据处理和分析指南

Posts & Telecom Press, Shilpi Saxena, Saurabh Gupta
数据科学实战手册(R+Python)(第2版)

数据科学实战手册(R+Python)(第2版)

Posts & Telecom Press, Prabhanjan Narayanachar Tattar, Tony Ojeda, Sean Patrick Murphy, Sean P Murphy, Benjamin Bengfort, Bengfort Benjamin, ABHIJIT DASGUPTA
Python应用开发指南

Python应用开发指南

Posts & Telecom Press, Ninad Sathaye
编写整洁的Python代码(第2版)

编写整洁的Python代码(第2版)

Posts & Telecom Press, Mariano Anaya

Publisher Resources

ISBN: 9781803230375