示例#1
0
        print " *** BACKTEST *** "
        #CONVERT DATA TO PICKLE
        #backTest = Backtest("historical/EUR_USD_Week3.csv",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
        #output = backTest.resample("1Min")
        #exit()

        #GROUP RESAMPLE TO PICKLE
        #groupResample(2015, 1, 6, "1H", "EUR_USD")
        #exit()

        # READ PICKLE INTO DATAFRAME (prices)
        #backtest =  Backtest("historical/EUR_USD_Week3.csv_1Min-OHLC.pkl",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
        backtest = Backtest("historical/EUR_USD_2015_1_through_12.pkl",
                            backtestSettings, leverage, backtestPositions)
        #backtest =  Backtest("historical/EUR_USD_2015_1_through_12.pkl",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
        prices = backtest.readPickle()

        # INSTANTIATE STRATEGY
        strategy = Strategy(backtestPositions, priceQueue, backtestSettings,
                            strategySettings)

        # LOOP THROUGH PRICES
        i = 0  # for displaying trades in a scatterplot
        for index, row in prices:

            # SKIP ERRORS IN PICKLE
            if np.isnan(row['Buy']) or np.isnan(row['Sell']):
                continue

            # 0.A: ADD CURRENT PRICE TO QUEUE
            priceQueue = strategy.doQueue(
示例#2
0
	if backtestIndicator and not liveIndicator:								# conduct backtest
		print " *** BACKTEST *** "
		#CONVERT DATA TO PICKLE
		#backTest = Backtest("historical/EUR_USD_Week3.csv",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
		#output = backTest.resample("1Min")
		#exit()

		#GROUP RESAMPLE TO PICKLE
		#groupResample(2015, 1, 6, "1H", "EUR_USD")
		#exit()

		# READ PICKLE INTO DATAFRAME (prices)
		#backtest =  Backtest("historical/EUR_USD_Week3.csv_1Min-OHLC.pkl",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
		backtest = Backtest("historical/EUR_USD_2015_1_through_12.pkl",backtestSettings,leverage,backtestPositions)
		#backtest =  Backtest("historical/EUR_USD_2015_1_through_12.pkl",backtestSettings,leverage,closeDictionary,backtestSettings['positions'])
		prices = backtest.readPickle()

		# INSTANTIATE STRATEGY
		strategy = Strategy(backtestPositions, priceQueue, backtestSettings, strategySettings)

		# LOOP THROUGH PRICES
		i = 0											# for displaying trades in a scatterplot
		for index, row in prices:

			# SKIP ERRORS IN PICKLE
			if np.isnan(row['Buy']) or np.isnan(row['Sell']):
				continue

			# 0.A: ADD CURRENT PRICE TO QUEUE
			priceQueue = strategy.doQueue(priceQueue,strategySettings["queuePeriod"],row)	# add current price to queue, along with stats
			longQueue = strategy.doQueue(longQueue,strategySettings["longQueuePeriod"],row)	# add current price to queue, along with stats