Little background as to what I'm trying to do. I work in Investments.
We have a rule that allows us to transfer shares owned in our general
account at no charge. Thus when we are rebalancing a series of General
account
portfolios, if the same security is being bought in one portfolio and
sold in another, it is advantageous for us not to incur transaction
costs, but rather to simply transfer the shares from one portfolio to
the other.
That said, I am trying to write some code that will produce a table
with these transfer transactions. My original list of transactions
looks like this
[tbl_Transactions]
Ticker Shares Type PortfolioNumber
GOOG 1000 Sell 100
GOOG 200 Buy 200
GOOG 500 Buy 300
GOOG 500 Buy 400
XOM 500 Buy 400
IBM 300 Sell 200
[tbl_Transfers] - I need it to contain only the transactions which are
opposite sides in the first table (please note the last share amount -
300 shares. I can't transfer more shares than are currently being
sold. Thus the remaining 200 shares in portfolio 400 will have to flow
through into another trade and be purchased normally through our
trading desk.
Ticker Shares Type PortfolioNumber
GOOG 1000 Sell 100
GOOG 200 Buy 200
GOOG 500 Buy 300
GOOG 300 Buy 400
Hopefully this makes sense. I feel like there has to be a way to do
this fairly easily with code. Thanks in advnace for the help!
Brian
|