在好例子网,分享、交流、成长!
您当前所在位置:首页Python 开发实例Python语言基础 → 2014 Python for Finance Analyze Big Financial Data

2014 Python for Finance Analyze Big Financial Data

Python语言基础

下载此实例
  • 开发语言:Python
  • 实例大小:10.49M
  • 下载次数:4
  • 浏览次数:47
  • 发布时间:2023-02-23
  • 实例类别:Python语言基础
  • 发 布 人:lingaf
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: python 应用 py

实例介绍

【实例简介】2014 Python for Finance Analyze Big Financial Data

【实例截图】

【核心代码】

Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Part I. Python and Finance
1. Why Python for Finance?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What Is Python? 3
Brief History of Python 5
The Python Ecosystem 6
Python User Spectrum 7
The Scientific Stack 8
Technology in Finance 9
Technology Spending 10
Technology as Enabler 10
Technology and Talent as Barriers to Entry 10
Ever-Increasing Speeds, Frequencies, Data Volumes 11
The Rise of Real-Time Analytics 12
Python for Finance 13
Finance and Python Syntax 14
Efficiency and Productivity Through Python 17
From Prototyping to Production 21
Conclusions 22
Further Reading 23
2. Infrastructure and Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Python Deployment 26
Anaconda 26
Python Quant Platform 32
Tools 34
Python 34
iii
IPython 35
Spyder 45
Conclusions 47
Further Reading 48
3. Introductory Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Implied Volatilities 50
Monte Carlo Simulation 59
Pure Python 61
Vectorization with NumPy 63
Full Vectorization with Log Euler Scheme 65
Graphical Analysis 67
Technical Analysis 68
Conclusions 74
Further Reading 75
Part II. Financial Analytics and Development
4. Data Types and Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Basic Data Types 80
Integers 80
Floats 81
Strings 84
Basic Data Structures 86
Tuples 87
Lists 88
Excursion: Control Structures 89
Excursion: Functional Programming 91
Dicts 92
Sets 94
NumPy Data Structures 95
Arrays with Python Lists 96
Regular NumPy Arrays 97
Structured Arrays 101
Vectorization of Code 102
Basic Vectorization 102
Memory Layout 105
Conclusions 106
Further Reading 107
iv | Table of Contents
5. Data Visualization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Two-Dimensional Plotting 109
One-Dimensional Data Set 110
Two-Dimensional Data Set 115
Other Plot Styles 121
Financial Plots 128
3D Plotting 132
Conclusions 135
Further Reading 135
6. Financial Time Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
pandas Basics 138
First Steps with DataFrame Class 138
Second Steps with DataFrame Class 142
Basic Analytics 146
Series Class 149
GroupBy Operations 150
Financial Data 151
Regression Analysis 157
High-Frequency Data 166
Conclusions 170
Further Reading 171
7. Input/Output Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Basic I/O with Python 174
Writing Objects to Disk 174
Reading and Writing Text Files 177
SQL Databases 179
Writing and Reading NumPy Arrays 181
I/O with pandas 183
SQL Database 184
From SQL to pandas 185
Data as CSV File 188
Data as Excel File 189
Fast I/O with PyTables 190
Working with Tables 190
Working with Compressed Tables 196
Working with Arrays 197
Out-of-Memory Computations 198
Conclusions 200
Further Reading 201
Table of Contents | v
8. Performance Python. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Python Paradigms and Performance 204
Memory Layout and Performance 207
Parallel Computing 209
The Monte Carlo Algorithm 209
The Sequential Calculation 210
The Parallel Calculation 211
Performance Comparison 214
multiprocessing 215
Dynamic Compiling 217
Introductory Example 217
Binomial Option Pricing 218
Static Compiling with Cython 223
Generation of Random Numbers on GPUs 226
Conclusions 230
Further Reading 231
9. Mathematical Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Approximation 234
Regression 234
Interpolation 245
Convex Optimization 249
Global Optimization 250
Local Optimization 251
Constrained Optimization 253
Integration 255
Numerical Integration 256
Integration by Simulation 257
Symbolic Computation 257
Basics 258
Equations 259
Integration 260
Differentiation 261
Conclusions 262
Further Reading 263
10. Stochastics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Random Numbers 266
Simulation 271
Random Variables 271
Stochastic Processes 274
Variance Reduction 287
vi | Table of Contents
Valuation 290
European Options 291
American Options 295
Risk Measures 298
Value-at-Risk 298
Credit Value Adjustments 302
Conclusions 305
Further Reading 305
11. Statistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Normality Tests 308
Benchmark Case 309
Real-World Data 317
Portfolio Optimization 322
The Data 323
The Basic Theory 324
Portfolio Optimizations 328
Efficient Frontier 330
Capital Market Line 332
Principal Component Analysis 335
The DAX Index and Its 30 Stocks 336
Applying PCA 337
Constructing a PCA Index 338
Bayesian Regression 341
Bayes’s Formula 341
PyMC3 342
Introductory Example 343
Real Data 347
Conclusions 355
Further Reading 355
12. Excel Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Basic Spreadsheet Interaction 358
Generating Workbooks (.xls) 359
Generating Workbooks (.xslx) 360
Reading from Workbooks 362
Using OpenPyxl 364
Using pandas for Reading and Writing 366
Scripting Excel with Python 369
Installing DataNitro 369
Working with DataNitro 370
xlwings 379
Table of Contents | vii
Conclusions 379
Further Reading 380
13. Object Orientation and Graphical User Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Object Orientation 381
Basics of Python Classes 382
Simple Short Rate Class 387
Cash Flow Series Class 391
Graphical User Interfaces 393
Short Rate Class with GUI 394
Updating of Values 396
Cash Flow Series Class with GUI 398
Conclusions 401
Further Reading 401
14. Web Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Web Basics 404
ftplib 405
httplib 407
urllib 408
Web Plotting 411
Static Plots 411
Interactive Plots 414
Real-Time Plots 417
Rapid Web Applications 424
Traders’ Chat Room 426
Data Modeling 426
The Python Code 427
Templating 434
Styling 440
Web Services 442
The Financial Model 443
The Implementation 445
Conclusions 451
Further Reading 452
Part III. Derivatives Analytics Library
15. Valuation Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Fundamental Theorem of Asset Pricing 455
A Simple Example 456
viii | Table of Contents
The General Results 457
Risk-Neutral Discounting 458
Modeling and Handling Dates 458
Constant Short Rate 460
Market Environments 462
Conclusions 465
Further Reading 466
16. Simulation of Financial Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Random Number Generation 468
Generic Simulation Class 470
Geometric Brownian Motion 473
The Simulation Class 474
A Use Case 476
Jump Diffusion 478
The Simulation Class 478
A Use Case 481
Square-Root Diffusion 482
The Simulation Class 483
A Use Case 485
Conclusions 486
Further Reading 487
17. Derivatives Valuation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Generic Valuation Class 489
European Exercise 493
The Valuation Class 494
A Use Case 496
American Exercise 500
Least-Squares Monte Carlo 501
The Valuation Class 502
A Use Case 504
Conclusions 507
Further Reading 509
18. Portfolio Valuation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
Derivatives Positions 512
The Class 512
A Use Case 514
Derivatives Portfolios 515
The Class 516
A Use Case 520
Table of Contents | ix
Conclusions 525
Further Reading 527
19. Volatility Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
The VSTOXX Data 530
VSTOXX Index Data 530
VSTOXX Futures Data 531
VSTOXX Options Data 533
Model Calibration 534
Relevant Market Data 535
Option Modeling 536
Calibration Procedure 538
American Options on the VSTOXX 542
Modeling Option Positions 543
The Options Portfolio 544
Conclusions 545
Further Reading 546
A. Selected Best Practices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
B. Call Option Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
C. Dates and Times. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575

标签: python 应用 py

实例下载地址

2014 Python for Finance Analyze Big Financial Data

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警