Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if int(optSwitch) == 0:
- opt = n
- elif int(optSwitch) == 1:
- #from scipy.optimize import brute
- #if iOpt == 1: #Optimize returns
- from scipy.optimize import brute
- # The following fix has been introduced because brute is not accounting for the value n_max when optimizing
- n_max_new = n_max + n_incr
- opt = brute(returns_in_Fxn, ((n_min, n_max_new, n_incr),), finish=None)
- #opt = brute(returns_in_Fxn, ((n_min, n_max, n_incr),), finish=None)
- #opt = brute(returns_in_Fxn, ((n_min, n_max, n_incr),), full_output=True, finish=None)
- # The following fix has been introduced because brute is not accounting for the value n_max when optimizing
- #n_max_new = n_max + n_incr
- #opt = brute(returns_in_Fxn, ((n_min, n_max, n_incr),), full_output=True, finish=None)
- import xlwt
- wb = xlwt.Workbook()
- ws = wb.add_sheet('A Opt Sheet')
- ws.write(0,0,'optSwitch')
- ws.write(0,1, optSwitch)
- ws.write(1,0,'n_min')
- ws.write(1,1, n_min)
- ws.write(2,0,'n_max')
- ws.write(2,1, n_max)
- ws.write(3,0,'n_incr')
- ws.write(3,1, n_incr)
- #ws.write(4,0,'opt')
- #row = 5
- #for col, data in enumerate(opt):
- # ws.write(row, col, data)
- #ws.write(4,1, opt)
- #n_min = df_param.ix['n']['Min']
- #n_max = df_param.ix['n']['Max']
- #n_incr = df_param.ix['n']['increment']
- wb.save('/var/www/html/finpoc/public/xlsx/exampleOpt_'+fn_append+'.xls')
- #elif iOpt == 2: #Optimize PnL
- # opt = brute
- sys.stderr.write("======================= DEBUG ===================")
- sys.stdout = sys.stderr
- pprint(MA_array)
- return_vals = {"in": returns_in_Fxn_1(opt, True), "all": returns_all_Fxn((opt), True), "out": returns_out_Fxn((opt), True), "back_test": 1, "optimization_n": opt}
- return return_vals
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement