Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicated securities in accounts not being handled as expected #1

Open
sandsmichael opened this issue Mar 21, 2021 · 0 comments
Open

Comments

@sandsmichael
Copy link

sandsmichael commented Mar 21, 2021

Hello, great work on the project I like the idea.

assertion fails with duplicated securities in index:
assert(np.round(port.final_allocation.sum(),4)==1.0)
I am intentionally including a duplicated ticker across multiple portfolios but don't seem to be getting desired behaviour with "Correcting distribution for single-security accounts edge case" I see we use
acctsdf = port.groupby(['accountid','accounttype']).new_value_chg_n.sum()
to determine total value allocated to an individual security but I am unsure if there is more effective way?

       port.loc[index,'new_shares_n'] = port.new_shares_n - port.final_shares_chg_n
       port.loc[index,'new_value_n'] = port.new_value_n - port.new_value_chg_n
       port.loc[index,'final_shares_chg_n'] = 0
       port.loc[index,'new_value_chg_n'] = 0

       #remove from denominator
       port.loc[port.ticker == t,'value'] = port.loc[port.ticker == t,'value'] - port[index].value_orig.sum()

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant