From the course: Practical Python for Algorithmic Trading

Unlock the full course today

Join today to access over 23,800 courses taught by industry experts.

Simulate the investment strategy step by step

Simulate the investment strategy step by step - Python Tutorial

From the course: Practical Python for Algorithmic Trading

Simulate the investment strategy step by step

- [Instructor] In this data frame, we can see when the stock will go up or down. The logic goes like this. If we predict that the stock will go up, we will buy. And if we predict that the stock goes down, we will sell. To check these conditions, we need to access the values of the columns separately. So we create a forward loop for tomorrow direction and access the values individually, as we can see in these outputs, now to only show the values when the stock goes up, we will put the condition. If tomorrow direction is up, we print and now we see all of the values up. But if tomorrow direction is down, we will print tomorrow direction as well. And now we can see up and downs. Nevertheless, I want to see one or minus one whether we buy or sell the stock. So one and minus one. Now, since I want these values to be on a new column of the data frame, we need to create an empty list that accumulates the values. So instead of…

Contents