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

Feature: handle zero ratio in analyze allocate --rebalance #48

Closed
rapidleft opened this issue Jul 5, 2022 · 2 comments
Closed

Feature: handle zero ratio in analyze allocate --rebalance #48

rapidleft opened this issue Jul 5, 2022 · 2 comments

Comments

@rapidleft
Copy link
Contributor

It can be convenient to set an asset class allocation ratio to 0, for example to exit a position of a certain fund or market segment.

It seems like most lak commands handle this just fine, however lak analyze allocate --rebalance does not allow this.

$ lak analyze allocate --account MyBrokerage --rebalance
<...>
AssertionError: Desired ratio of asset class MyZeroAsset cannot be zero.

I think this should work. The MyZeroAsset asset should be rebalanced to 0 and the funds moved to other assets.

A hacky work around is to set the ratio to to almost zero e.g. 0.00000000000001.

@sarvjeets
Copy link
Owner

sarvjeets commented Jul 6, 2022

You are right, allocate doesn't work with 0 ratio.

The issue is that the "relative" ratio doesn't work around 0 as any deviation from 0 => infinite error.

In addition to the hack mentioned above, you can also do lak whatif asset -a MyZeroAsset -$current_balance to zero out the asset before running lak analyze allocate (lak analyze allocate --account MyBrokerage --rebalance --exclude_assets MyZeroAsset). Would this be a better solution (hack)?

I do see that this is inconvenient.

@sarvjeets
Copy link
Owner

rapidleft: Not sure if you are still working on this, do you mind if I try to fix this issue?

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

Successfully merging a pull request may close this issue.

2 participants