In [1]:
import pandas as pd
from beakerx import *
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
In [2]:
# import prices from csv file using pandas
prices=pd.read_csv("data/price.csv", index_col=0, header=0, parse_dates=True)
In [3]:
# plot using beakerx
SimpleTimePlot(prices, prices.keys())
In [4]:
from pyutil.performance.drawdown import drawdown
In [5]:
SimpleTimePlot(prices.pct_change().apply(drawdown), prices.keys())
In [6]:
from pyutil.performance.month import monthlytable
In [7]:
TableDisplay(100*monthlytable(prices["A"].pct_change()))
In [8]:
from pyutil.performance.var import cvar, var
In [9]:
prices.pct_change().apply(var, alpha=0.95)
Out[9]:
In [10]:
prices.pct_change().apply(var, alpha=0.99)
Out[10]:
In [11]:
prices.pct_change().apply(cvar, alpha=0.95)
Out[11]:
In [12]:
from pyutil.performance.periods import period_returns
In [13]:
period_returns(prices["A"].pct_change(), today=prices["A"].dropna().index[-1])
Out[13]:
In [14]:
TableDisplay(prices.pct_change().apply(lambda x: period_returns(x, today=x.dropna().index[-1])))
In [ ]: