Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def weightedSum(inputList):
  2.     result = 0
  3.     totalAllocation = sum([strategy['allocate'] for strategy in inputList])
  4.     for strategy in inputList:
  5.        weightOfStrategy = strategy['allocate'] / totalAllocation
  6.        result += strategy['dailyReturn'] * weightOfStrategy
  7.     return result
  8.  
  9. altCoinsLS = { 'dailyReturn' : 0.46, 'allocate' : 1.94 }
  10. il_test = { 'dailyReturn' : 0.00, 'allocate' : 0.48 }
  11. TF_TD = { 'dailyReturn' : 0.39, 'allocate' : 0.01}
  12.  
  13. strategies = [altCoinsLS, il_test, TF_TD]
  14.  
  15. print(weightedSum(strategies))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement