def randomSimulate(self,timestep = 60, ntimes=60*24, n=100, min_ts = None):
 	cashReset = self.totalCash
 	btcReset = self.nBTC
     profits = {} 
     self.timestep = timestep
     if min_ts is None: 
         min_ts = min(self.actualPrices.keys())
     allowedTs = [i for i in self.actualPrices.keys() if i > (min_ts + (timestep + 1) * ntimes)]
     for j in xrange(n):
         self.totalCash = cashReset
         self.nBTC = btcReset
         start = random.choice(allowedTs) # is actually the end, need to check the beginning
         boughtAt = start - timestep
         while boughtAt not in self.actualPrices.keys(): 
             boughtAt -= timestep
         self.boughtAt = self.actualPrices[start - timestep]
         maxts = start - timestep
         mints = maxts - (timestep * ntimes)
         range_needed = range(mints, maxts, timestep)
         #pdb.set_trace()
         try: 
             price_subset = dataFetcher.aggregated_prices(self.actualPrices, maxts + 2 * timestep, (maxts - mints)/ timestep + 3,  timestep, 'hash')
         except Exception, e: 
             pdb.set_trace()
         #pdb.set_trace()
         prof = self.simulate(range(mints, maxts, timestep), price_subset)
         if prof is not None: 
             profits[start] = prof
         self.income = 0
         self.invested = 0
         print profits
maxnbtc = 10
cash = 10000
nbtc = 0
timestep = 3600
predictionMethod = 'neuralnet'
test = RuleBasedActionPicker(nBTC = nbtc, cash=cash, boughtAt = 0, maxnBTC = maxnbtc, buySellStep = 1, actualPrices = priceData, timestep = timestep, predictionMethod = 'neuralnet')
#profits = test.randomSimulate(timestep=3600,ntimes = 24 * 12   * 30, n=50, min_ts = 1387174080) # 1.0158806245527092
#print 'maxnbtc', maxnbtc, 'cash', cash, 'nbtc', nbtc, 'timestep', 3600, 'predictionMethod', predictionMethod, 'profit', profits[1]

#pdb.set_trace()


## test from dec 16 until present
ts_range = range(1387174080, max(priceData.keys()) - 7200 - 169740 - 540, timestep)
price_subset = dataFetcher.aggregated_prices(priceData, max(ts_range), len(ts_range) + 3 ,timestep, 'hash')
all_profit = test.simulate(ts_range, price_subset)
print 'maxnbtc', maxnbtc, 'cash', cash, 'nbtc', nbtc, 'timestep', 3600, 'predictionMethod', predictionMethod, 'profit', all_profit
pdb.set_trace()
#print all_profit[1]

maxnbtc = 100
cash = 1000
nbtc = 0
timestep = 3600
predictionMethod = 'neuralnet'
test = RuleBasedActionPicker(nBTC = nbtc, cash=cash, boughtAt = 0, maxnBTC = maxnbtc, buySellStep = 1, actualPrices = priceData, timestep = timestep, predictionMethod = 'neuralnet')
ts_range = range(1387174080, max(priceData.keys()) - 7200 - 169740 - 540, timestep)
price_subset = dataFetcher.aggregated_prices(priceData, max(ts_range), len(ts_range) + 3 ,timestep, 'hash')
all_profit = test.simulate(ts_range, price_subset)
print 'maxnbtc', maxnbtc, 'cash', cash, 'nbtc', nbtc, 'timestep', timestep, 'predictionMethod', predictionMethod, 'profit', all_profit
bought 1 bitcoin at 16
bought 1 bitcoin at 15
bought 1 bitcoin at 14
bought 1 bitcoin at 13
bought 1 bitcoin at 12
bought 1 bitcoin at 11
initialBTC: 3, nBTC: 10, invested: 98, income: 0, profit%: 0.547945205479
{15: {'profit': 0.54794520547945202, 'nBTC': 10, 'invested': 98, 'income': 0}}


# this DOES let me buy 

"""


"""
# sell some stuff
import pickle, dataFetcher
priceData = pickle.load(open('../data/bitcoin_prices.pickle'))
dataFetcher.aggregated_prices(priceData, max(priceData.keys()), (max(priceData.keys()) - min(priceData.keys())) / 60, 60, 'hash')

minPerDay = 24 * 60
maxDay = max(priceData.keys()) - 60 
minDay = maxDay - (24 * 60 * 60)
priceRange = [i for i in priceData.keys() if i >= minDay and i <= maxDay 
csptest = BuySellCSPTest(nBTC = 3, boughtAt = 300, maxnBTC = 10, buySellStep = 1, actualPrices = priceData, timestep = 60, predictionMethod = 'perfect')
csptest.simulate(priceRange, priceData)

# do not sell :(
csptest = BuySellCSPTest(nBTC =3, boughtAt = 300,