Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def weightedSum(inputList):
- result = 0
- totalAllocation = sum([strategy['allocate'] for strategy in inputList])
- for strategy in inputList:
- weightOfStrategy = strategy['allocate'] / totalAllocation
- result += strategy['dailyReturn'] * weightOfStrategy
- return result
- altCoinsLS = { 'dailyReturn' : 0.46, 'allocate' : 1.94 }
- il_test = { 'dailyReturn' : 0.00, 'allocate' : 0.48 }
- TF_TD = { 'dailyReturn' : 0.39, 'allocate' : 0.01}
- strategies = [altCoinsLS, il_test, TF_TD]
- print(weightedSum(strategies))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement