Skip to content

Commit 1cd77db

Browse files
authored
corriger une erreur
1 parent 1194f36 commit 1cd77db

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

stock trading recursion.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# coding: utf-8
2+
3+
4+
# In[1]:
5+
16

27
#a simple day trading game
38
#day trader is only allowed to make at maximum two trades
@@ -12,6 +17,10 @@
1217
#strongly recommend you to take a look
1318
# https://github.com/je-suis-tm/recursion-and-dynamic-programming/blob/master/stock%20trading%20dynamic%20programming.jl
1419

20+
21+
# In[2]:
22+
23+
1524
#compute the maximum profit for long only strategy
1625
function compute_profit(prices)
1726

@@ -71,6 +80,10 @@ function compute_profit(prices)
7180

7281
end
7382

83+
84+
# In[3]:
85+
86+
7487
#there are two scenarios to maximize the profit
7588
#one trade or two trades
7689
#since we can execute two transactions
@@ -97,10 +110,26 @@ function stock_trading(prices,ind)
97110

98111
end
99112

113+
114+
# In[4]:
115+
116+
100117
stock_trading([10,22,5,75,65,80],1)
101118

119+
120+
# In[5]:
121+
122+
102123
stock_trading([2,30,15,10,8,25,80],1)
103124

125+
126+
# In[6]:
127+
128+
104129
stock_trading([100,30,15,10,8,25,80],1)
105130

131+
132+
# In[7]:
133+
134+
106135
stock_trading([90,70,35,11,5],1)

0 commit comments

Comments
 (0)