def calculateTradingReturn(actionHistory, tsReturn, delta=0):
    if ((type(tsReturn) == pd.core.frame.DataFrame) or (type(tsReturn) == pd.core.frame.Series)):
        rets = pd.Series(index=tsReturn.index)
    else:
        rets = [0 for i in range(len(tsReturn))]
    for t in range((len(tsReturn) - 1)):
        cost = (delta * abs((actionHistory[(t + 1)] - actionHistory[t])))
        rets[t] = (((1 + (actionHistory[t] * tsReturn[t])) * (1 - cost)) - 1)
    return rets
def calculateTradingReturn(actionHistory, tsReturn, delta=0):
    if ((type(tsReturn) == pd.core.frame.DataFrame) or (type(tsReturn) == pd.core.frame.Series)):
        rets = pd.Series(index=tsReturn.index)
    else:
        rets = [0 for i in range(len(tsReturn))]
    for t in range((len(tsReturn) - 1)):
        cost = (delta * abs((actionHistory[(t + 1)] - actionHistory[t])))
        rets[t] = (((1 + (actionHistory[t] * tsReturn[t])) * (1 - cost)) - 1)
    return rets