<jupyter_start><jupyter_text>H1 Download dataRun:appcfg.py download_data --url=http://binary-trading.appspot.com/remoteapi --filename=runs.csv --kind="Run" --config_file=config.yaml  Import dependencies---<jupyter_code>import numpy as np
import pandas as pd
%matplotlib inline
from matplotlib import pyplot as plt<jupyter_output><empty_output><jupyter_text>Load Data---<jupyter_code>df = pd.read_csv('runs.csv')
print df.columns<jupyter_output>Index([u'payout', u'time_frame', u'ended_at', u'is_win', u'probability', u'profit', u'stake_parent', u'created_at', u'stake', u'parent_run', u'updated_at', u'binary_ref', u'trade_base', u'currency', u'step', u'profit_parent', u'key', u'trade_aim', u'is_finished', u'profit_net', u'stake_net'], dtype='object')<jupyter_text>Profitability Win/loss ratio<jupyter_code>df['is_win'].hist()<jupyter_output><empty_output><jupyter_text>Actual profitShows the cumulative profit<jupyter_code>print df[df['step'] > 8]
df['profit'].cumsum().plot()<jupyter_output>payout  time_frame             ended_at is_win  probability  profit  \
296    510.95           5  2015-03-25T05:20:12   True          NaN  254.95   
1419   916.72          10  2015-03-27T12:26:27   True     0.656217  315.15   
2264  1051.54          40  2015-03-31T09:56:12  False     0.563780 -592.84   
2270  1000.71          40  2015-03-31T10:16:10   True     0.568695  431.61   
2278   802.62          40  2015-03-31T10:36:32   True     0.524369  381.75   

      stake_parent           created_at   stake                  parent_run  \
296            NaN  2015-03-25T05:15:13  256.00  2015-03-25 04:30:13.439040   
1419        170.03  2015-03-27T12:16:30  601.57  2015-03-27 12:06:09.834710   
2264        273.11  2015-03-31T09:16:14  592.84  2015-03-31 08:35:30.057900   
2270        252.37  2015-03-31T09:36:12  569.10  2015-03-31 08:55:47.755710   
2278        219.74  2015-03-31T09:56:34  420.87  2015-03-31 09:16:09.880530   

        ...      trade_base  currency step profit_parent[...]<jupyter_text>ROI---<jupyter_code>df['roi'] = df['profit'] / df['stake']
#print df[df['profit'] > 20]
#print df[df['roi'] < -1]
print df[['payout', 'stake', 'profit', 'roi']].tail()<jupyter_output>payout  stake  profit  roi
2718    1.00   0.56     NaN  NaN
2719    1.00   0.56     NaN  NaN
2720   65.92  43.33     NaN  NaN
2721    1.00   0.56     NaN  NaN
2722    1.00   0.56     NaN  NaN<jupyter_text>Time Frames<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>Trade Base<jupyter_code>grouped = df.groupby('trade_base')
grouped['roi'].mean().plot(kind='barh', yerr=grouped['roi'].std())<jupyter_output><empty_output><jupyter_text>Trade Base & AimGoal:- Want to see the ROI per selection- Want to see the avg steps per selection (reduce risk)<jupyter_code>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())
grouped['step'].mean().plot(kind='bar', yerr=grouped['step'].std())<jupyter_output><empty_output><jupyter_text>Step ROI by stepGoal:- confirm visualisation should be useless<jupyter_code>grouped = df.groupby(['step'])
grouped['roi'].mean().plot(kind='bar', grid=False, yerr=grouped['roi'].std())<jupyter_output><empty_output><jupyter_text>Count by stepGoal:- to establish probability of ruin<jupyter_code>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])
df_last = df[df['is_win'] == True]
vals = df_last['step'].value_counts()
print vals
vals.plot(kind='bar')<jupyter_output>1    821
2    325
3    170
4     81
5     30
6     11
7      9
9      4
8      4
dtype: int64<jupyter_text>Stake by stepGoal: - show the volatility per step- used in bankroll management<jupyter_code>grouped = df.groupby(['step'])
grouped['stake'].mean().plot(kind='bar', yerr=grouped['stake'].std())<jupyter_output><empty_output><jupyter_text>Stake of total stake by step<jupyter_code>grouped = df.groupby(['step'])
grouped['stake_net'].mean().plot(kind='bar', yerr=grouped['stake_net'].std())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.163338997451147, 'fraction_numerical': 0.10683942225998301, 'mean_word_length': 4.387871853546911, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '637589', 'license': 'MIT', 'n_tokens_mistral': 2172, 'n_tokens_neox': 1866, 'n_words': 328, 'path': '18_theoryofruns/app/bulkloader/.ipynb_checkpoints/Analysis-checkpoint.ipynb', 'repo_name': 'Tjorriemorrie/trading', 'size': '4708'}