BillJones984
New Member
- Joined
- Jul 3, 2018
- Messages
- 1
Hi and thanks in advance for the help!
I need to convert stock buy and sell requests into matched offsetting trade transactions. The Buys and Sells here are the inputs and the trades are the outputs.
Answers in PQ are preferred but VBA or Excel are fine too.
[TABLE="width: 1363"]
<tbody>[TR]
[TD="colspan: 7, align: center"]Inputs[/TD]
[TD][/TD]
[TD="colspan: 8, align: center"]Outputs[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3, align: center"]Buy[/TD]
[TD][/TD]
[TD="colspan: 3, align: center"]Sell[/TD]
[TD][/TD]
[TD="colspan: 6, align: center"]Trades[/TD]
[TD][/TD]
[TD]Comments[/TD]
[/TR]
[TR]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]$ Price[/TD]
[TD][/TD]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]$ Price[/TD]
[TD][/TD]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]Buy $[/TD]
[TD][/TD]
[TD]Stock[/TD]
[TD]Sell $[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]1500[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]SBUX[/TD]
[TD="align: right"]1900[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]TSLA[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]TSLA[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]REGN[/TD]
[TD="align: right"]1100[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]AMZN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]AMZN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]TMUS[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]MSFT[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]MSFT[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]VOD[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Need to sell $100 here so REGN is depleted[/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]600[/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]SIRI[/TD]
[TD="align: right"]400[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]SBUX[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Remaining ADBE is purchased with proceeds from SBUX[/TD]
[/TR]
[TR]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]800[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]1400[/TD]
[TD][/TD]
[TD]SBUX[/TD]
[TD="align: right"]1400[/TD]
[TD][/TD]
[TD]SBUX depleted[/TD]
[/TR]
[TR]
[TD]Sally[/TD]
[TD]AMZN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]TMUS[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Remaining SBUX purchased with proceeds from TMUS[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]AMZN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]SIRI[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]SIRI[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]VOD[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Total Buys[/TD]
[TD]Jim[/TD]
[TD="align: right"]3100[/TD]
[TD][/TD]
[TD]Total Sells[/TD]
[TD]Jim[/TD]
[TD="align: right"]3100[/TD]
[TD][/TD]
[TD="colspan: 2"]Net Trades[/TD]
[TD]Jim[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Sally[/TD]
[TD="align: right"]900[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD="align: right"]900[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I need to convert stock buy and sell requests into matched offsetting trade transactions. The Buys and Sells here are the inputs and the trades are the outputs.
Answers in PQ are preferred but VBA or Excel are fine too.
[TABLE="width: 1363"]
<tbody>[TR]
[TD="colspan: 7, align: center"]Inputs[/TD]
[TD][/TD]
[TD="colspan: 8, align: center"]Outputs[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3, align: center"]Buy[/TD]
[TD][/TD]
[TD="colspan: 3, align: center"]Sell[/TD]
[TD][/TD]
[TD="colspan: 6, align: center"]Trades[/TD]
[TD][/TD]
[TD]Comments[/TD]
[/TR]
[TR]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]$ Price[/TD]
[TD][/TD]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]$ Price[/TD]
[TD][/TD]
[TD]Account[/TD]
[TD]Stock[/TD]
[TD]Buy $[/TD]
[TD][/TD]
[TD]Stock[/TD]
[TD]Sell $[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]1500[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]SBUX[/TD]
[TD="align: right"]1900[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]TSLA[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]TSLA[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]REGN[/TD]
[TD="align: right"]1100[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]AMZN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]AMZN[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]TMUS[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]MSFT[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]MSFT[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]VOD[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]REGN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Need to sell $100 here so REGN is depleted[/TD]
[/TR]
[TR]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]600[/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]SIRI[/TD]
[TD="align: right"]400[/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]ADBE[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]SBUX[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]Remaining ADBE is purchased with proceeds from SBUX[/TD]
[/TR]
[TR]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]800[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]1400[/TD]
[TD][/TD]
[TD]SBUX[/TD]
[TD="align: right"]1400[/TD]
[TD][/TD]
[TD]SBUX depleted[/TD]
[/TR]
[TR]
[TD]Sally[/TD]
[TD]AMZN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Jim[/TD]
[TD]BIDU[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]TMUS[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]Remaining SBUX purchased with proceeds from TMUS[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]AMZN[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD]SIRI[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD]SIRI[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD]FB[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD]VOD[/TD]
[TD="align: right"]500[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Total Buys[/TD]
[TD]Jim[/TD]
[TD="align: right"]3100[/TD]
[TD][/TD]
[TD]Total Sells[/TD]
[TD]Jim[/TD]
[TD="align: right"]3100[/TD]
[TD][/TD]
[TD="colspan: 2"]Net Trades[/TD]
[TD]Jim[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Sally[/TD]
[TD="align: right"]900[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD="align: right"]900[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sally[/TD]
[TD][/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]