I am trying to find the month-end balance amounts based on the "issues" held from the df_td list of activity.
Actually I am just looking to find the count of "issues" with a positive balance at the end of each month.
To do this I need to create the month-end balance based on each "issues" "action" and "shares" on activity less than the month-end date. So the total count of issues with a balance > 0 for each period.
The "action" is used to know if it is a buy or a sell, "+" or "-". So the balance is "+ shares" less "- shares" per each "issue."
Previously I used sql to do this but that seems like a serious waste.
What is best way to do this with Pandas?
df_td
action code comm credit date \
0 + P 0.00 0.00 2013-03-27
1 + P 0.00 0.00 2013-03-27
2 - S 19.00 86751.01 2013-04-08
3 + Z 2000.00 0.00 2013-04-09
4 - S 18.71 730.49 2013-04-10
issue \
FIDELITY REAL ESTATE INVESTMENT PORTFOLIO FUND
FIDELITY NJ MUNICIPAL INCOME FUND
FIDELITY REAL ESTATE INVESTMENT PORTFOLIO FUND
AMERICAN RLTY CAP HEALTHCARE TR INC
FIDELITY NJ MUNICIPAL INCOME FUND
price shares
0 34.4800 2462.958
1 0.2003 60.963
2 35.2300 2462.958
3 10.0000 2000.000
4 12.2900 60.960
sample of the month ends df_month
month
0 2013-03-31
1 2013-04-30
2 2013-05-31
3 2013-06-30
4 2013-07-31
so as I loop through the months, how would I get the "balance" of each issue in the df_td?
I hope this makes sense?
Thanks.