I have a stock dataset. Where my potential buy call is executed based on some conditions.
In my application there can only be one open position, therefore there will be a lot less expected buys.
If I want to sell a stock I need to buy it first. After that my stock needs to gain or lose 10 pips to execute a sell as shown in a dummy dataset.
After my expected sales are defined I can determine expected buys as well (as I said there can only be one open position).
My expected output is expected_sell and expected_buy.
import pandas as pd
d = {'buy': [0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1], 'close': [-2, 5, -8, 6, 15, -1, 15, -6, 16, -4, 2, 11, 12]}
df = pd.DataFrame(data=d)
df['expected_sell'] = [0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1]
df['expected_buy'] = [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0]
![enter image description here](https://i.stack.imgur.com/zmsjR.png)