from dateutil.relativedelta import relativedelta
import glob
import numpy as np
import pandas as pd
import os
import plotly.offline; import cufflinks
import pafx.oanda
import pafx.vex
plotly.offline.init_notebook_mode(connected=False)
cufflinks.go_offline()
%load_ext autoreload
%autoreload 2
def plot_pnl(base_dir, desc):
pnl_vecs = []
for path in sorted(glob.glob(base_dir)):
pnl_df = pd.read_csv(path, index_col='TIME', parse_dates=True)
pnl_vec = pnl_df.sum(axis=1)
pnl_vec.name = path.split('_')[-1][:-4] # also remove the .csv
pnl_vecs.append(pnl_vec)
pnl_df = pd.concat(pnl_vecs, axis=1)
pnl_df.sum().cumsum().iplot(title=desc)
return pnl_df['0.9500']
best_pnl_vec_map = {}
for pnl_dir in sorted(glob.glob(pafx.get_data_dir() + '/vex_*')):
desc = pnl_dir.split('/')[-1]
best_pnl_vec = plot_pnl(pnl_dir + '/test_pnl*.csv', desc)
best_pnl_vec_map[desc] = best_pnl_vec
pd.DataFrame(best_pnl_vec_map).cumsum().iplot(title='Best')
print("Done!")