@@ -43,24 +43,28 @@ def Decide(self, f1, f2, f3, f4):
4343 """ This is where the script decides to Buy, Sell, or Hold; Desgin your algorithm logic here.
4444
4545 Arguments (keep these or design your own):
46- f1, f2, f3, f4: moving averages over different time periods
46+ f1, f2, f3, f4: moving averages of the stock price over different time periods
47+
4748 """
4849
49-
50- # here is the skeleton of an algorithm; fill in the logic for calculating the probability of profit and expected return
51-
5250 # ~~~~ Modify code below to implement your own trading Algorithm ~~~~
5351
54-
52+ #TODO: design an algorithm that modifies these values based on the price data
53+ prob_profit = 0.501 # probability of profit (eg, 50.1%)
54+ expected_return = 1.2 # expected return (eg. 120%)
55+ modifier = 0.2 # value from 0-1; higher values make a more aggressive bet
56+
57+ # Calculates the optimal position (and subsequent number of shares) based on the above parameters
5558 position = self .OptimalPosition (expected_return , prob_profit , modifier )
5659 shares = abs (int (position / priceo ))
57-
60+
61+ # Buy or Sell shares based on the results of the algorithm
5862 if position > 0 :
5963 self .Order (Decisions .buy , shares )
6064 else :
6165 self .Order (Decisions .sell , shares )
62-
63- # ~~~~ End of trading algorithm ~~~~
66+
67+ # ~~~~ End of trading algorithm ~~~~
6468
6569 def Order (self , decision , n = - 1 ):
6670 """ Executes a buy/sell order of n shares, or a buy/sell max order if no input for n.
0 commit comments