Commits

dan mackinlay committed cd24138

ad in CARA traders

Comments (0)

Files changed (1)

risky_business/privateers.py

    
 end"""
 
+class CRRATrader(Trader):
+    """encapsulate trader logic"""
+    
+    def utility_of_lottery(self, lottery):
+        return crra_utility_of_lottery(self.genome, lottery, self.wealth)
+
+def crra_utility_of_prize(rho, prize, wealth):
+    if (wealth+prize)<0: return wealth+prize
+    return ((wealth + (prize)) ** (1 - rho )) / (1 - rho )
+
+def crra_utility_of_lottery(genome, lottery, wealth):
+    [rho] = genome
+    return crra_utility_of_prize(rho, lottery['lower'], wealth) *\
+       lottery['lowerweight'] +\
+           crra_utility_of_prize(rho, lottery['upper'], wealth) *\
+       (1.0-lottery['lowerweight'])