Hello,
below you find my current code but it does not really work.
I want to generate the variables buyprice and sellprice which includes the price so I can compare for what price an investor bought a stock and for which price he sold it. First, I want that j goes through the numbers 1 to the last observation in my data set (I want to achieve this by using count). The variable u is a counter variable which counts if the two conditions are fulfilled. Put differently, the variable u increases if the value of the stock is bigger than zero and if in two subsequent lines we have the same investor (my data set is sorted by investor). In the next step another loop starts using the counter variable u as a starting point. Then variable a increases if the conditions are fulfilled and then the two variables buyprice and sellprice are generated including the buy price of a stock and the sell price of the very same stock.
But if I run the code I got the error message "invalid syntax".
Maybe someone can help me with this issue.
Thanks!
below you find my current code but it does not really work.
I want to generate the variables buyprice and sellprice which includes the price so I can compare for what price an investor bought a stock and for which price he sold it. First, I want that j goes through the numbers 1 to the last observation in my data set (I want to achieve this by using count). The variable u is a counter variable which counts if the two conditions are fulfilled. Put differently, the variable u increases if the value of the stock is bigger than zero and if in two subsequent lines we have the same investor (my data set is sorted by investor). In the next step another loop starts using the counter variable u as a starting point. Then variable a increases if the conditions are fulfilled and then the two variables buyprice and sellprice are generated including the buy price of a stock and the sell price of the very same stock.
But if I run the code I got the error message "invalid syntax".
Maybe someone can help me with this issue.
Thanks!
Comment