问题
This code is implementing a fitness function for rsi indicators using genetic algorithms but i have no idea what are the output for every function
def strategy_return(trading_signal, asset_return):
strat_ret = np.array(trading_signal[0:-1]) * np.array(asset_return[1::])
strat_ret = np.insert(strat_ret, 0, np.nan)
return strat_ret
def _cumulative_return(ret):
cum_ret_list = [ret[0]]
n = ret.shape[0]
for i in range(1, n):
cum_ret = (1 + ret[i]) * (1 + cum_ret_list[-1]) - 1
cum_ret_list.append(cum_ret)
cum_ret_list.insert(0, np.nan)
return cum_ret_list
def fit_evaluation(strategy_return):
strat_cum_ret = _cumulative_return(strat_ret[1::])
return strat_cum_ret
来源:https://stackoverflow.com/questions/65580865/fitness-function-for-rsi-using-genetic-algorithms