本文整理匯總了Python中tester.Tester.print_results方法的典型用法代碼示例。如果您正苦於以下問題:Python Tester.print_results方法的具體用法?Python Tester.print_results怎麽用?Python Tester.print_results使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tester.Tester
的用法示例。
在下文中一共展示了Tester.print_results方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open
# 需要導入模塊: from tester import Tester [as 別名]
# 或者: from tester.Tester import print_results [as 別名]
with open(INPUT_FILE, 'rb') as csvfile:
reader = csv.DictReader(csvfile)
last_candle = None
for price in reader:
new_candle = PriceCandle(int(price['Date']), float(price['Close']), last_candle)
history.append(new_candle)
last_candle = new_candle
first_price = history[0].closing_value
last_price = history[-1].closing_value
bh_profit = 100*(last_price - first_price*(1+config['fees']/100)) / first_price
print "Compare to B&H profit [%.2f to %.2f]: %.2f%%" % (first_price, last_price, bh_profit)
if config['single_test']:
backtest = Tester(config, history)
backtest.print_results()
else:
with open(OUTPUT_FILE, 'wb') as csvfile:
header_row = ['long_EMA']
for index in range(1, MAX_EMA_SIZE):
header_row.append(index)
writer = csv.writer(csvfile)
writer.writerow(header_row)
for long_EMA in range(1, MAX_EMA_SIZE):
config['long_EMA'] = long_EMA
profit_row = [long_EMA]
for short_EMA in range(1, long_EMA):
config['short_EMA'] = short_EMA
backtest = Tester(config, history)
profit = backtest.print_results()
profit_row.append(profit)