Skip to content

Commit

Permalink
added adg plot
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord committed Jun 23, 2021
1 parent 4596f9e commit bcd8fb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def gain_conv(x):
shrts.pnl.cumsum().plot()
plt.savefig(f"{result['plots_dirpath']}pnl_cumsum_shrt.png")

plt.clf()
fdf.adg.plot()
plt.savefig(f"{result['plots_dirpath']}adg.png")

print('plotting backtest whole and in chunks...')
n_parts = max(3, int(round_up(result['n_days'] / 14, 1.0)))
for z in range(n_parts):
Expand Down
3 changes: 2 additions & 1 deletion pure_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ def analyze_fills(fills: list, bc: dict, first_ts: float, last_ts: float) -> (pd
if fdf.empty:
return fdf, get_empty_analysis(bc)
fdf.columns = ['trade_id', 'timestamp', 'pnl', 'fee_paid', 'balance', 'equity', 'pbr', 'qty', 'price', 'psize', 'pprice', 'type']
fdf = fdf.set_index('trade_id')
adgs = (fdf.equity / bc['starting_balance']) ** (1 / ((fdf.timestamp - first_ts) / (1000 * 60 * 60 * 24)))
fdf = fdf.join(adgs.rename('adg')).set_index('trade_id')

longs = fdf[fdf.type.str.contains('long')]
shrts = fdf[fdf.type.str.contains('shrt')]
Expand Down

0 comments on commit bcd8fb6

Please sign in to comment.