Example #1
0
 def do_backtest(self, arg):
     paramFlag = input('Use current parameters? ([y]/n): ')
     if paramFlag is 'n':
     #   Change parameters here
         bbFunctions.choose_parameters()
     numLinesLog = bbFunctions.file_len(bbCfg.logFileName) 
     bbCfg.logFileNameBT = bbFunctions.getLogFileNameBT()
     try:
         numLinesLogBT = bbFunctions.file_len(bbCfg.logFileNameBT)
     except:
         numLinesLogBT = 0
     if numLinesLogBT != numLinesLog:
         bitbot.main('-b')
     d,r=bbPerformance.getReturns(bbCfg.logFileNameBT, None, '2014-01-08', None)
     bbPerformance.printSummary(r)
Example #2
0
 def do_performance(self, arg):
     startDate = input('Initial Date (YYYY-MM-DD): ')
     if len(startDate) is not 10:
         startDate = '2014-01-08'
     endDate   = input('End Date (YYYY-MM-DD): ')
     if len(endDate) is not 10:
         endDate = None
     chooseBT = input('Calculate performance for backtest? y/[n]: ')
     if chooseBT == 'y':
         bbCfg.logFileNameBT = bbFunctions.getLogFileNameBT() 
         d,r=bbPerformance.getReturns(bbCfg.logFileNameBT, None,
                                      startDate, endDate)
     else:
         d,r=bbPerformance.getReturns(bbCfg.logFileName, bbCfg.fundFileName,
                                      startDate, endDate)
     bbPerformance.printReturns(d, r)
     print('')
     bbPerformance.printSummary(r)
Example #3
0
 def do_calibrate(self, arg):
     reload(bbCfg)
     old_walkUp = bbCfg.walkUp
     old_tradeFactor = bbCfg.tradeFactor
     old_allinLimit = bbCfg.allinLimit
     old_backupFund = bbCfg.backupFund
     m = [0.9, 1.1]
     result = []
     numLinesLog = bbFunctions.file_len(bbCfg.logFileName)
     for i in range(len(m)**4):
         sys.stdout.write('|')
     sys.stdout.write('\n')
     for bbCfg.walkUp in [x * old_walkUp for x in m]:
         for bbCfg.tradeFactor in [x * old_tradeFactor for x in m]:
             for bbCfg.allinLimit in [x * old_allinLimit for x in m]:
                 for bbCfg.backupFund in [x * old_backupFund for x in m]:
                     bbCfg.logFileNameBT = bbFunctions.getLogFileNameBT()
                     try:
                         n = bbFunctions.file_len(bbCfg.logFileNameBT)
                     except:
                         n = 0
                     #bbFunctions.display_config()
                     sys.stdout.write('|')
                     sys.stdout.flush()
                     if n != numLinesLog:
                         bitbot.main('-b -q')
                     d,r=bbPerformance.getReturns(bbCfg.logFileNameBT, 
                                                  None, '2014-01-08', None)
                     result.append([
                             bbCfg.walkUp,
                             bbCfg.tradeFactor,
                             bbCfg.allinLimit,
                             bbCfg.backupFund,
                             100*bbPerformance.totalReturn(r[:,3])])
     print('')
     result = np.array(result)
     result = result[np.argsort(result[:, len(result[0])-1])]
     print(' '.join('{0:>10}'.format(x) for x in ['walkUp', 'tradeFactor', 'allinLimit', 'backupFund', 'Return']))
     for row in result[-10:]:
         print(' '.join('{0:10.4}'.format(x) for x in row))