-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplot_performance.py
More file actions
40 lines (31 loc) · 984 Bytes
/
plot_performance.py
File metadata and controls
40 lines (31 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
# -*- coding: utf-8 -*-
# plot_performance.py
import os.path
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
if __name__ == "__main__":
data = pd.io.parsers.read_csv(
"equity.csv", header=0,
parse_dates=True, index_col=0
)
# Plot three charts: Equity curve,
# period returns, drawdowns
fig = plt.figure()
# Set the outer colour to white
fig.patch.set_facecolor('white')
# Plot the equity curve
ax1 = fig.add_subplot(311, ylabel='Portfolio value, %')
data['equity_curve'].plot(ax=ax1, color="blue", lw=2.)
plt.grid(True)
# Plot the returns
ax2 = fig.add_subplot(312, ylabel='Period returns, %')
data['returns'].plot(ax=ax2, color="black", lw=2.)
plt.grid(True)
# Plot the returns
ax3 = fig.add_subplot(313, ylabel='Drawdowns, %')
data['drawdown'].plot(ax=ax3, color="red", lw=2.)
plt.grid(True)
# Plot the figure
plt.show()