Coder Social home page Coder Social logo

sarvjeets / lakshmi Goto Github PK

View Code? Open in Web Editor NEW
127.0 127.0 7.0 2.39 MB

Investing library and command-line interface inspired by the Bogleheads philosophy

License: MIT License

Python 90.79% HTML 8.42% Shell 0.79%
asset-allocation bogleheads command-line-tool commandline finance investing portfolio python

lakshmi's People

Contributors

bolapara avatar dependabot[bot] avatar pre-commit-ci[bot] avatar rapidleft avatar sarvjeets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lakshmi's Issues

Init fails

macOS - M1 Max
installed with pip
Python 3.9.12

lak --help returns help correctly.

lak init fails after a couple of seconds... printing Aborted! and attempting to open a editor to editor-{RANDOM}.txt

I'm not a python developer but I have to run a few other python CLI tools from time to time.

Feature: Rebalanced based on a band and within Accounts for portfolio

Hi,

I setup my yaml file and everything is working. I was wondering if you could add an option in rebalance to also show suggestions for re-balancing within accounts to obtain the desired % for the portfolio as a whole. The account rebalance could use this strategy. https://www.bogleheads.org/wiki/Tax-efficient_fund_placement#Assigning_asset_classes_to_different_accounts.

A caveat would you the dollar limits of what is in each account when using the assignment strategy

command:
lak analyze rebalance -strategy

display:
Class | Actual% | Desired% | Account | Value | Difference

Some assets do not have long names on YT finance

When looking up the BTC-USD asset, I get the following traceback:

Traceback (most recent call last): File "/home/josh/.local/bin/lak", line 8, in <module> sys.exit(lak()) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1690, in invoke rv.append(sub_ctx.command.invoke(sub_ctx)) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/lak.py", line 272, in assets output = portfolio.assets( File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/lakshmi.py", line 636, in assets + [asset.name(), asset.adjusted_value()]) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 174, in new_func value = call_func(class_obj, func) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 138, in call_func return func(class_obj) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/assets.py", line 489, in name raise NotFoundError( lakshmi.assets.NotFoundError: Cannot retrieve ticker ("BTC-USD") from Yahoo Finance

I found that this asset does not actually have a longName field in the ticker object provided by YT API. There are a few other name fields so I've got a PR coming shortly to try to fall back to some other naming fields if the longName field does not exist.

Feature: handle zero ratio in `analyze allocate --rebalance`

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.

lakshmi.assets.NotFoundError: Cannot retrieve ticker ("VTI") from Yahoo Finance

Hi,

I haven't used lak for awhile. I tried today and received this error: lakshmi.assets.NotFoundError: Cannot retrieve ticker ("VTI") from Yahoo Finance. I used the already setup portfolio for testing.

Below is the command I ran and the output.

mhenke@mhenke-Inspiron-15-3567:~$ lak --debug -r list assets total aa al performance
Traceback (most recent call last):
File "/home/mhenke/.local/bin/lak", line 8, in
sys.exit(lak())
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 1690, in invoke
rv.append(sub_ctx.command.invoke(sub_ctx))
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/mhenke/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/lak.py", line 328, in assets
output = portfolio.assets(
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/lakshmi.py", line 712, in assets
+ [asset.name(), asset.adjusted_value()])
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/assets.py", line 176, in adjusted_value
return max(0, self.value() + self.get_what_if())
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/assets.py", line 428, in value
return self.shares() * self.price()
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 211, in new_func
value = _call_func(class_obj, func)
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 178, in _call_func
return func(class_obj)
File "/home/mhenke/.local/lib/python3.8/site-packages/lakshmi/assets.py", line 539, in price
raise NotFoundError(
lakshmi.assets.NotFoundError: Cannot retrieve ticker ("VTI") from Yahoo Finance

add option to use different portfolio file

As a user, I would like to easily switch between different portfolio.yaml. For example, I have portfolio_mh.yaml which has my portfolio and portfolio_sh.yaml which has my wife's.

command might be:

  • lak --file portfolio_mh.yaml -r list assets total aa al
  • lak --file portfolio_sh.yaml -r list assets total aa al

lak analyze rebalance - missing custom class

I added a class called US_Ext for extended market since my 401k plan doesn't have a total market fund but has a s&p 500 and extended market. When I run rebalance, it seems to miss the US_Ext class.

lak analyze rebalance
Class Actual% Desired% Value Difference


US 83% 59% $189,381.65 -$53,901.82
Bonds 2% 10% $4,820.86 +$18,126.26
Intl 3% 18% $7,061.55 +$34,243.28

lak list aa shows the US_Ext class

ERROR: Could not find a version that satisfies the requirement lakshmi

mhenke@mhenke-Inspiron-15-3567:$ python --version
Python 3.8.10
mhenke@mhenke-Inspiron-15-3567:$ pip install lakshmi
ERROR: Could not find a version that satisfies the requirement lakshmi (from versions: none)
ERROR: No matching distribution found for lakshmi

pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Add tests for lak module

Add some simple tests for lak module. The module doesn't have complicated logic, but tests will make refactoring of library easier.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.