Background: In mplfinance, I want to be able to plot multiple trade markers in the same bar. Currently to my understanding you can add only 1 (or 1 buy and 1 sell) to the same bar. I cannot have 2 more trades on the same side in the same bar unless I create another series.
Here is an example:
d = {'TradeDate': ['2018-10-15 06:00:00',
'2018-10-29 03:00:00',
'2018-10-29 03:00:00',
'2018-10-29 06:00:00',
'2018-11-15 05:00:00',
'2018-11-15 05:00:00',
'2018-11-15 05:00:00'],
'Price': [1.1596,
1.1433,
1.13926,
1.14015,
1.1413,
1.1400,
1.1403]}
df = pd.DataFrame(data=d)
df
TradeDate Price
0 2018-10-15 06:00:00 1.15960
1 2018-10-29 03:00:00 1.14330
2 2018-10-29 03:00:00 1.13926
3 2018-10-29 06:00:00 1.14015
4 2018-11-15 05:00:00 1.14130
5 2018-11-15 05:00:00 1.14000
6 2018-11-15 05:00:00 1.14030
As you can see there are multiple trades for 2 datetimes. Now I would like to apply a rule that says "If there is more than 1 trade(here: Price) per date, create a new column for the additional price, keep doing so until all prices for the same TradeDate (datetime) have been distributed across columns, and all datetimes are unique". So the more prices for the same date, the more extra columns are needed.
The end result would look like this (I finagled this data manually):
TradeDate Price Price2 Price3
0 2018-10-15 06:00:00 1.15960 NaN NaN
1 2018-10-29 03:00:00 1.14330 1.13926 NaN
3 2018-10-29 06:00:00 1.14015 NaN NaN
4 2018-11-15 05:00:00 1.14130 1.14000 1.1403