Download data
Run:
appcfg.py download_data --url=http://binary-trading.appspot.com/remoteapi --filename=runs.csv --kind="Run" --config_file=config.yaml
In [189]:
import numpy as np
import pandas as pd
%matplotlib inline
from matplotlib import pyplot as plt
In [190]:
df = pd.read_csv('runs.csv')
print df.columns
Win/loss ratio
In [191]:
df['is_win'].hist()
Out[191]:
In [203]:
print df[df['step'] > 8]
df['profit'].cumsum().plot()
Out[203]:
In [193]:
df['roi'] = df['profit'] / df['stake']
#print df[df['profit'] > 20]
#print df[df['roi'] < -1]
print df[['payout', 'stake', 'profit', 'roi']].tail()
In [194]:
tf_roi = df[['roi']].groupby(df['time_frame']) # .sort('roi', ascending=False)
#tf_roi
#tf_roi.plot()
#tf_roi.plot(subplots=True)
# tf_roi.plot(secondary_y=('roi', 'count'))
tf_roi.mean().plot(kind='bar', subplots=True, grid=False, yerr=tf_roi.std())
#tf_roi.plot(kind='kde', subplots=True, grid=False)
#tf_roi.boxplot()
tf_roi.count().plot(kind='bar', subplots=True, grid=False)
Out[194]:
In [195]:
grouped = df.groupby('trade_base')
grouped['roi'].mean().plot(kind='barh', yerr=grouped['roi'].std())
Out[195]:
In [196]:
grouped = df.groupby(['trade_base', 'trade_aim'])
#for name, group in grouped:
# print(name)
# print(group['roi'].tail())
#print grouped['roi'].mean()
#print grouped['roi'].std()
grouped['roi'].mean().plot(kind='bar', yerr=grouped['roi'].std())
Out[196]:
In [197]:
grouped['step'].mean().plot(kind='bar', yerr=grouped['step'].std())
Out[197]:
ROI by step
Goal:
In [198]:
grouped = df.groupby(['step'])
grouped['roi'].mean().plot(kind='bar', grid=False, yerr=grouped['roi'].std())
Out[198]:
Count by step
Goal:
In [199]:
vals = df['step'].value_counts()
print vals
#print vals.index.values
#print vals.values
coeffs = np.polyfit(vals.index.values, vals.values, 2)
poly = np.poly1d(coeffs)
print poly
vals.plot(kind='bar')
#plt.plot(vals.index.values, [0.5**(x+1) for x in vals.index.values])
Out[199]:
In [200]:
df_last = df[df['is_win'] == True]
vals = df_last['step'].value_counts()
print vals
vals.plot(kind='bar')
Out[200]:
Stake by step
Goal:
In [201]:
grouped = df.groupby(['step'])
grouped['stake'].mean().plot(kind='bar', yerr=grouped['stake'].std())
Out[201]:
Stake of total stake by step
In [202]:
grouped = df.groupby(['step'])
grouped['stake_net'].mean().plot(kind='bar', yerr=grouped['stake_net'].std())
Out[202]:
In [ ]: