How to dynamically transpose array of data sorted by date & time and group them horizontally?

marklcrns

New Member
Joined
Aug 30, 2019
Messages
1
Please help me with my excel project. I have a stock trading spreadsheet with a database I export from my trading platform sorted vertically by execution date (regardless of whether Its a buy or a sell). I am trying to think of a way to dynamically transpose my database horizontally, grouped by their corresponding ticker symbol and sorted out from left to right by date (see desired transposed data below).


Spreadsheet structure:
- Each trading cycle has their own single row sorted by execution sequence.
- buying and selling trades should be logged in separate tables.
- can only have up to a total of 3 entries and 3 exits within a single trade
- can both have long (buying stock as an entry trade and selling to close) and shorting (selling stock as entry trade and buying to close).
*short trades should have negative shares, as shown in the image below, for both entries and exits (for later calculations convenience).


Challenges:
- after buying a stock, I might increment or decrement my shares of stock later on after buying and/or selling different stocks, or after buying or selling the stock thereof.
- after selling all my shares from a single stock, I might open a new position and buy the same stock multiple times immediately after or later on after many different trades from different stocks have been executed.
- buying and selling stock(s) may occur within the same day.


Raw data pulled from platform: https://i.imgur.com/6Gt94gm.jpg
6Gt94gm.jpg

*ignore the following header: Order Type, Pos effect and Spread.


Desired dynamically transposed data: https://i.imgur.com/Bs0G5VF.jpg
Bs0G5VF.jpg
This image is has been cut due to resolution. Please view the full image with the link above.

"Filled" header contains the entry prices and "Cover" contains the exit prices. "Shares" are the quantity.

I would deeply appreciate it if anyone would be of any help to my project. Thank you in advance.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
I think you can try Transform data with PowerQuery (Get&Transform)
 

Watch MrExcel Video

Forum statistics

Threads
1,132,912
Messages
5,655,914
Members
418,251
Latest member
aondrla

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top