Skip to content

Commit

Permalink
using the right high before the shake
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfunley committed Jan 26, 2016
1 parent 27126ad commit ce2eed2
Show file tree
Hide file tree
Showing 2 changed files with 2,145 additions and 2,139 deletions.
15 changes: 9 additions & 6 deletions analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import os
import sys

check_against_high_price = False
check_against_high_price = True

float_cols = ('recent_high', 'last_price', 'first_shaken_price', 'alltime_high',)
float_cols = ('recent_high', 'last_price', 'first_shaken_price', 'alltime_high',
'preshake_high',)


def parse_date(s):
Expand All @@ -19,8 +20,10 @@ def read_data():
for d in DictReader(open('shaken-stocks.csv'), delimiter=';'):
for c in float_cols:
d[c] = float(d[c])

d['first_shaken_at'] = parse_date(d['first_shaken_at'])
data.append(d)

return data


Expand All @@ -45,7 +48,7 @@ def log_exceptional(d, r):
print >>sys.stderr, '%-10s %-40s %.2f' % (d['symbol'], d['name'], r)


def categorize(recovery, market_return, high):
def categorize(symbol, last, recovery, market_return, high):
if recovery < -90:
return 'wiped out'
if recovery < 0:
Expand All @@ -57,7 +60,7 @@ def categorize(recovery, market_return, high):
return 'beaten by market'

if check_against_high_price:
if recovery < high:
if last < high:
return 'recovered below high price'

if recovery > 1000:
Expand All @@ -73,9 +76,9 @@ def categorize(recovery, market_return, high):
last = d['last_price']
recovery = (last - sp) / sp * 100
market_return = sp500_return(d['first_shaken_at'])
high = d['alltime_high']
high = d['preshake_high']

categories[categorize(recovery, market_return, high)] += 1
categories[categorize(d['symbol'], last, recovery, market_return, high)] += 1


n = len(data)
Expand Down
Loading

0 comments on commit ce2eed2

Please sign in to comment.