diff --git a/Bot.md b/Bot.md new file mode 100644 index 0000000..3d1e069 --- /dev/null +++ b/Bot.md @@ -0,0 +1,1432 @@ + + +``` +import pandas as pd +import redis +import pickle + +``` + + +``` +r=redis.Redis(port=6666) +#r=redis.Redis() +``` + + +``` + +i=0 + +f={} +for st in r.lrange("strat_list",0,100): + try: + #if st != 'MACROSS_2_20': + s=pd.DataFrame([pickle.loads(i) + for i in r.lrange('%s:positions'%st,0,100000)]) + + s.reset_index() + s.index=s.date + s=s.sort_index() + + s=s[s.status=="filled"]#.fillna(0) + + s.pnl.fillna(0,inplace=True) + s.side.fillna(method='ffill',inplace=True) + + f[st]=(s.pnl).cumsum() + print + print "profit/loss", st,((s[s.status=="filled"].pnl)).sum()#.abs() + + except Exception, e : + print st, e + pass#print e# '%s : P/L:%f PnL:%f %d transactions'%(st,0,0,0) + + +``` + + + profit/loss CCI 0.364493427108 + + profit/loss Volume_inbal 0.0311087466221 + + profit/loss VHMM_21_205 0.0892311999016 + + profit/loss VHMM_21_124 0.0269838540813 + + profit/loss VHMM_50_208 0.0777806134005 + + profit/loss MACROSS_2_20 0.247519265629 + + profit/loss MACROSS_21_15 0.0230190248993 + + + +``` +for k in f.keys(): + #if k != 'MACROSS_2_20': + f[k].plot(figsize=(15,8)) +legend( f.keys(), "best") + +``` + + + + + + + + + +![png](output_3_1.png) + + + +``` +st="Volume_inbal" +s=pd.DataFrame([pickle.loads(i) + for i in r.lrange('%s:positions'%st,0,100000)]) +s.reset_index() +s.index=s.date +s=s.sort_index() +``` + + +``` +%qtconsole +``` + + +``` +s[(s.status=='filled') & (s.index.duplicated() == True)] +``` + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dateexitfill_timeorder_typepnlpricesidestatus
date
2015-01-20 19:11:002015-01-20 19:11:00 02015-01-20 19:26:00 limit-0.000970 1298.50 1 filled
2015-01-20 19:48:002015-01-20 19:48:00 02015-01-21 02:06:00 limit 0.000000 1301.82 0 filled
2015-01-20 21:31:002015-01-20 21:31:00 02015-01-20 21:32:00 limit 0.000000 1298.63 1 filled
2015-01-20 21:39:002015-01-20 21:39:00 02015-01-20 21:40:00 limit 0.002974 1291.10 1 filled
2015-01-20 22:13:002015-01-20 22:13:00 02015-01-20 22:15:00 limit-0.000000 1286.29 0 filled
2015-01-20 22:19:002015-01-20 22:19:00 02015-01-20 22:22:00 limit 0.000000 1289.50 0 filled
2015-01-20 22:29:002015-01-20 22:29:00 02015-01-20 22:30:00 limit 0.000000 1289.60 1 filled
2015-01-20 22:31:002015-01-20 22:31:00 02015-01-20 22:34:00 limit 0.000000 1289.29 0 filled
2015-01-20 22:41:002015-01-20 22:41:00 02015-01-20 22:43:00 limit 0.000016 1288.32 1 filled
2015-01-20 22:49:002015-01-20 22:49:00 02015-01-20 22:50:00 limit 0.000536 1286.90 1 filled
2015-01-20 23:03:002015-01-20 23:03:00 02015-01-20 23:04:00 limit 0.000000 1292.69 0 filled
2015-01-20 23:08:002015-01-20 23:08:00 02015-01-20 23:09:00 limit 0.000000 1294.60 0 filled
2015-01-20 23:09:002015-01-20 23:09:00 02015-01-20 23:11:00 limit 0.000000 1295.14 0 filled
2015-01-20 23:24:002015-01-20 23:24:00 02015-01-20 23:30:00 limit 0.000000 1292.00 0 filled
2015-01-20 23:33:002015-01-20 23:33:00 02015-01-20 23:34:00 limit-0.000000 1292.98 0 filled
2015-01-20 23:33:002015-01-20 23:33:00 02015-01-20 23:35:00 limit-0.000008 1292.01 1 filled
2015-01-20 23:37:002015-01-20 23:37:00 02015-01-20 23:39:00 limit 0.000000 1292.14 0 filled
2015-01-20 23:39:002015-01-20 23:39:00 02015-01-20 23:40:00 limit 0.000000 1292.31 0 filled
2015-01-20 23:57:002015-01-20 23:57:00 02015-01-20 23:58:00 limit 0.000000 1292.36 0 filled
2015-01-20 23:57:002015-01-20 23:57:00 02015-01-21 00:39:00 limit 0.000333 1292.02 1 filled
2015-01-21 00:00:002015-01-21 00:00:00 02015-01-21 00:01:00 limit-0.000193 1293.91 1 filled
2015-01-21 00:01:002015-01-21 00:01:00 02015-01-21 00:02:00 limit-0.000000 1294.76 0 filled
2015-01-21 00:12:002015-01-21 00:12:00 02015-01-21 00:13:00 limit 0.000000 1294.85 1 filled
2015-01-21 00:26:002015-01-21 00:26:00 02015-01-21 00:28:00 limit-0.000000 1294.99 0 filled
2015-01-21 00:29:002015-01-21 00:29:00 02015-01-21 00:30:00 limit 0.000000 1295.00 0 filled
2015-01-21 00:30:002015-01-21 00:30:00 02015-01-21 00:31:00 limit 0.000000 1295.00 0 filled
2015-01-21 00:40:002015-01-21 00:40:00 02015-01-21 00:41:00 limit 0.000000 1292.80 0 filled
2015-01-21 00:41:002015-01-21 00:41:00 02015-01-21 00:43:00 limit 0.000000 1293.14 0 filled
2015-01-21 00:45:002015-01-21 00:45:00 02015-01-21 00:46:00 limit 0.000000 1293.91 0 filled
2015-01-21 00:50:002015-01-21 00:50:00 02015-01-21 01:01:00 limit-0.003326 1293.00 1 filled
2015-01-21 00:53:002015-01-21 00:53:00 02015-01-21 00:54:00 limit 0.000000 1293.48 1 filled
2015-01-21 00:56:002015-01-21 00:56:00 02015-01-21 00:58:00 limit 0.000054 1293.27 1 filled
2015-01-21 01:08:002015-01-21 01:08:00 02015-01-21 01:09:00 limit 0.000000 1290.00 0 filled
2015-01-21 01:10:002015-01-21 01:10:00 02015-01-21 01:32:00 limit 0.000000 1290.00 1 filled
2015-01-21 01:13:002015-01-21 01:13:00 02015-01-21 01:14:00 limit 0.000000 1291.92 0 filled
2015-01-21 01:30:002015-01-21 01:30:00 02015-01-21 01:33:00 limit-0.000000 1293.24 0 filled
2015-01-21 01:35:002015-01-21 01:35:00 02015-01-21 01:37:00 limit 0.000874 1292.25 1 filled
2015-01-21 02:05:002015-01-21 02:05:00 02015-01-21 02:08:00 limit 0.003692 1300.20 1 filled
2015-01-21 02:13:002015-01-21 02:13:00 02015-01-21 02:23:00 limit 0.000000 1309.90 1 filled
2015-01-21 02:30:002015-01-21 02:30:00 02015-01-21 02:31:00 limit-0.000000 1304.00 0 filled
2015-01-21 02:31:002015-01-21 02:31:00 02015-01-21 02:33:00 limit 0.000000 1303.78 0 filled
2015-01-21 02:35:002015-01-21 02:35:00 02015-01-21 02:37:00 limit 0.000038 1300.63 1 filled
2015-01-21 02:48:002015-01-21 02:48:00 02015-01-21 02:58:00 limit 0.000000 1301.00 1 filled
2015-01-21 03:02:002015-01-21 03:02:00 02015-01-21 03:10:00 limit 0.000000 1298.68 0 filled
2015-01-21 03:06:002015-01-21 03:06:00 02015-01-21 03:07:00 limit-0.000363 1295.59 1 filled
2015-01-21 03:18:002015-01-21 03:18:00 02015-01-21 03:19:00 limit 0.000000 1300.00 0 filled
+
+ + + + +``` +name='VHMM_50_208' +zz=pickle.loads(r.get('strategy:%s'%name)) +``` + + +``` +zz[zz.signal.diff()!=0] +``` + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
signalpricereturns
2015-01-21 19:21:00 0 1324.20 NaN
2015-01-21 23:25:00 1 1396.86-0.000136
2015-01-22 00:14:00 0 1403.35-0.000783
+
+ + + + +``` +ww.pnl.fillna(0,inplace=True) +``` + + +``` +ww.pnl.cumsum().plot() +``` + + + + + + + + + +![png](output_10_1.png) + + + +``` +s[s.index.duplicated()==True] +``` + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dateexitfill_timeorder_typepnlpricesidestatus
date
2015-01-20 19:11:002015-01-20 19:11:00 02015-01-20 19:26:00 limit-0.000970 1298.50 1 filled
2015-01-20 19:48:002015-01-20 19:48:00 02015-01-21 02:06:00 limit 0.000000 1301.82 0 filled
2015-01-20 21:29:002015-01-20 21:29:00 0 NaT limit 0.000000 1298.88 1 open
2015-01-20 21:31:002015-01-20 21:31:00 02015-01-20 21:32:00 limit 0.000000 1298.63 1 filled
2015-01-20 21:31:002015-01-20 21:31:00 0 NaT limit 0.000000 1298.87 0 open
2015-01-20 21:39:002015-01-20 21:39:00 02015-01-20 21:40:00 limit 0.002974 1291.10 1 filled
2015-01-20 21:49:002015-01-20 21:49:00 0 NaT limit 0.000000 1294.56 1 open
2015-01-20 22:13:002015-01-20 22:13:00 0 NaT limit 0.000000 1286.10 0 open
2015-01-20 22:13:002015-01-20 22:13:00 02015-01-20 22:15:00 limit-0.000000 1286.29 0 filled
2015-01-20 22:19:002015-01-20 22:19:00 0 NaT limit 0.000000 1288.92 0 open
2015-01-20 22:19:002015-01-20 22:19:00 02015-01-20 22:22:00 limit 0.000000 1289.50 0 filled
2015-01-20 22:29:002015-01-20 22:29:00 02015-01-20 22:30:00 limit 0.000000 1289.60 1 filled
2015-01-20 22:31:002015-01-20 22:31:00 02015-01-20 22:34:00 limit 0.000000 1289.29 0 filled
2015-01-20 22:41:002015-01-20 22:41:00 02015-01-20 22:43:00 limit 0.000016 1288.32 1 filled
2015-01-20 22:49:002015-01-20 22:49:00 02015-01-20 22:50:00 limit 0.000536 1286.90 1 filled
2015-01-20 23:03:002015-01-20 23:03:00 02015-01-20 23:04:00 limit 0.000000 1292.69 0 filled
2015-01-20 23:08:002015-01-20 23:08:00 02015-01-20 23:09:00 limit 0.000000 1294.60 0 filled
2015-01-20 23:09:002015-01-20 23:09:00 02015-01-20 23:11:00 limit 0.000000 1295.14 0 filled
2015-01-20 23:24:002015-01-20 23:24:00 02015-01-20 23:30:00 limit 0.000000 1292.00 0 filled
2015-01-20 23:33:002015-01-20 23:33:00 02015-01-20 23:34:00 limit-0.000000 1292.98 0 filled
2015-01-20 23:33:002015-01-20 23:33:00 02015-01-20 23:35:00 limit-0.000008 1292.01 1 filled
2015-01-20 23:37:002015-01-20 23:37:00 02015-01-20 23:39:00 limit 0.000000 1292.14 0 filled
2015-01-20 23:39:002015-01-20 23:39:00 02015-01-20 23:40:00 limit 0.000000 1292.31 0 filled
2015-01-20 23:57:002015-01-20 23:57:00 02015-01-20 23:58:00 limit 0.000000 1292.36 0 filled
2015-01-20 23:57:002015-01-20 23:57:00 02015-01-21 00:39:00 limit 0.000333 1292.02 1 filled
2015-01-21 00:00:002015-01-21 00:00:00 02015-01-21 00:01:00 limit-0.000193 1293.91 1 filled
2015-01-21 00:01:002015-01-21 00:01:00 02015-01-21 00:02:00 limit-0.000000 1294.76 0 filled
2015-01-21 00:01:002015-01-21 00:01:00 0 NaT limit 0.000000 1293.59 1 open
2015-01-21 00:12:002015-01-21 00:12:00 02015-01-21 00:13:00 limit 0.000000 1294.85 1 filled
2015-01-21 00:26:002015-01-21 00:26:00 02015-01-21 00:28:00 limit-0.000000 1294.99 0 filled
...........................
2015-01-21 00:30:002015-01-21 00:30:00 02015-01-21 00:31:00 limit 0.000000 1295.00 0 filled
2015-01-21 00:40:002015-01-21 00:40:00 02015-01-21 00:41:00 limit 0.000000 1292.80 0 filled
2015-01-21 00:41:002015-01-21 00:41:00 02015-01-21 00:43:00 limit 0.000000 1293.14 0 filled
2015-01-21 00:45:002015-01-21 00:45:00 02015-01-21 00:46:00 limit 0.000000 1293.91 0 filled
2015-01-21 00:50:002015-01-21 00:50:00 02015-01-21 01:01:00 limit-0.003326 1293.00 1 filled
2015-01-21 00:53:002015-01-21 00:53:00 02015-01-21 00:54:00 limit 0.000000 1293.48 1 filled
2015-01-21 00:56:002015-01-21 00:56:00 02015-01-21 00:58:00 limit 0.000054 1293.27 1 filled
2015-01-21 01:08:002015-01-21 01:08:00 02015-01-21 01:09:00 limit 0.000000 1290.00 0 filled
2015-01-21 01:10:002015-01-21 01:10:00 0 NaT limit 0.000000 1290.00 1 open
2015-01-21 01:10:002015-01-21 01:10:00 02015-01-21 01:32:00 limit 0.000000 1290.00 1 filled
2015-01-21 01:13:002015-01-21 01:13:00 02015-01-21 01:14:00 limit 0.000000 1291.92 0 filled
2015-01-21 01:22:002015-01-21 01:22:00 0 NaT limit 0.000000 1292.98 1 open
2015-01-21 01:30:002015-01-21 01:30:00 02015-01-21 01:33:00 limit-0.000000 1293.24 0 filled
2015-01-21 01:35:002015-01-21 01:35:00 02015-01-21 01:37:00 limit 0.000874 1292.25 1 filled
2015-01-21 01:57:002015-01-21 01:57:00 0 NaT limit 0.000000 1296.15 0 open
2015-01-21 02:03:002015-01-21 02:03:00 0 NaT limit 0.000000 1295.64 1 open
2015-01-21 02:05:002015-01-21 02:05:00 02015-01-21 02:08:00 limit 0.003692 1300.20 1 filled
2015-01-21 02:13:002015-01-21 02:13:00 02015-01-21 02:23:00 limit 0.000000 1309.90 1 filled
2015-01-21 02:14:002015-01-21 02:14:00 0 NaT limit 0.000000 1311.10 1 open
2015-01-21 02:30:002015-01-21 02:30:00 02015-01-21 02:31:00 limit-0.000000 1304.00 0 filled
2015-01-21 02:31:002015-01-21 02:31:00 0 NaT limit 0.000000 1303.51 0 open
2015-01-21 02:31:002015-01-21 02:31:00 02015-01-21 02:33:00 limit 0.000000 1303.78 0 filled
2015-01-21 02:35:002015-01-21 02:35:00 02015-01-21 02:37:00 limit 0.000038 1300.63 1 filled
2015-01-21 02:39:002015-01-21 02:39:00 0 NaT limit 0.000000 1299.96 1 open
2015-01-21 02:48:002015-01-21 02:48:00 02015-01-21 02:58:00 limit 0.000000 1301.00 1 filled
2015-01-21 02:52:002015-01-21 02:52:00 0 NaT limit 0.000000 1304.57 0 open
2015-01-21 03:02:002015-01-21 03:02:00 02015-01-21 03:10:00 limit 0.000000 1298.68 0 filled
2015-01-21 03:06:002015-01-21 03:06:00 02015-01-21 03:07:00 limit-0.000363 1295.59 1 filled
2015-01-21 03:09:002015-01-21 03:09:00 0 NaT limit 0.000000 1297.88 1 open
2015-01-21 03:18:002015-01-21 03:18:00 02015-01-21 03:19:00 limit 0.000000 1300.00 0 filled
+

61 rows × 8 columns

+
+ + + + +``` + +``` diff --git a/README.md b/README.md index 38d8e56..7627419 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -test du rendering vi jupyter/ipython +# test du rendering de notebook jupyter/ipython + +[ Test1 ](https://git.tetalab.org:8888/pg/ipymd_test/blob/master/Agent_random.md) +[ Test2 ](https://git.tetalab.org:8888/pg/ipymd_test/blob/master/Bot.md) + + diff --git a/output_10_1.png b/output_10_1.png new file mode 100644 index 0000000..2007421 Binary files /dev/null and b/output_10_1.png differ diff --git a/output_3_1.png b/output_3_1.png new file mode 100644 index 0000000..fae8b53 Binary files /dev/null and b/output_3_1.png differ