{"id":13544951,"url":"https://github.com/aktau/gofinance","last_synced_at":"2025-05-07T20:35:10.716Z","repository":{"id":13317141,"uuid":"16003754","full_name":"aktau/gofinance","owner":"aktau","description":"Financial information retrieval and munging (stocks, ETFs, funds, currencies, ...). Libs and app written in golang. Uses multiple datasources: Yahoo Finance, Bloomberg, et cetera.","archived":false,"fork":false,"pushed_at":"2018-06-19T09:31:37.000Z","size":7831,"stargazers_count":238,"open_issues_count":0,"forks_count":60,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-10-10T17:24:10.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aktau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-17T15:47:39.000Z","updated_at":"2024-05-25T14:55:45.000Z","dependencies_parsed_at":"2022-09-11T22:50:46.599Z","dependency_job_id":null,"html_url":"https://github.com/aktau/gofinance","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktau%2Fgofinance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktau%2Fgofinance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktau%2Fgofinance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktau%2Fgofinance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aktau","download_url":"https://codeload.github.com/aktau/gofinance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221661139,"owners_count":16859489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T11:00:55.290Z","updated_at":"2024-10-27T10:13:44.065Z","avatar_url":"https://github.com/aktau.png","language":"Go","funding_links":[],"categories":["Go","Data \u0026 Market Intelligence"],"sub_categories":[],"readme":"Gofinance\n=========\n\nFinancial information retrieval and munging, will support multiple\nsources (Yahoo Finance, Bloomberg, ...). Written in Go, based in parts\non [richie rich](https://github.com/aantix/richie_rich).\n\nThe idea is to automate security analysis on a large scale. For example,\nit should be possible (in the future) to search for stock that has a\ngood dividend yield, along with a good track record of increasing\ndividend, good P/E-ratio, et cetera. This should be implemented as a\nseparate package that only relies on the **fquery** interfaces.\n\nGofinance is logically composed of a few submodules:\n\n- fquery: provides an interface for querying a financial source\n  (`fquery.Source`), but doesn't implement any Source itself.\n- yahoofinance: implements **fquery**. Queries **Yahoo Finance** for\n  financial data, .\n- bloomberg: implements **fquery**. Queries **Bloomberg** for financial data.\n  (NOTE: at the moment it doesn't fetch the same types of data as Yahoo\n  Finance, I'm working on a way to derive the missing pieces, and also\n  integrate the extra data that Bloomberg gives into fquery, such as 1\n  year return %)\n- sqlitecache: implements **fquery**. **Caches** the information returned from\n  any `fquery.Source` in a **SQLite** databse.\n- app: a sample application you can compile and run (go build), to see\n  what you can do with fquery and its modules.\n\n**NOTE**: This is still early days for gofinance, very rough around the\nedges. Pull requests welcome!\n\nScreenshot\n==========\n\nEverybody loves screenshots, even of console apps.\n\n![Fancy screenshot of gofinance in action](http://aktau.github.io/gofinance/images/screen-01.png)\n\nRequirements\n============\n\n- Golang 1.1 (I think, I'm developing on Golang 1.2, but not using any\n  features new to 1.2).\n\nHow to get it?\n==============\n\n## Installing Go (if you dont' have it yet)\n\nFirst, install Go 1.1+, on UNIX-like systems you can do this from the\ncommandline\n\n### OSX\n\nUsing homebrew\n\n```sh\n$ brew install go\n```\n\n### Linux/FreeBSD\n\nUsing your favourite package manager, for example\n\n```sh\n# debian/ubuntu\n$ apt-get install golang\n\n# fedora core\n$ yum install golang\n\n# arch\n$ pacman -S go\n\n# other distributions/UNIXes\n$ ...\n```\n\n### Windows\n\nOn windows you'll have to install the go binaries via a normal\ninstaller. Keep in mind that the windows support is a bit flaky at the\nmoment because gofinance uses colors in the terminal as indicators for\nnumbers et cetera. These give strange results in `cmd.exe`. That said,\nthe basic app should work fine.\n\n## Install the app\n\nIf you haven't already done so, setup $GOPATH and $PATH:\n\n```sh\n# setup a $GOPATH\n$ mkdir ~/go\n$ export GOPATH=/my/home/path/go\n\n# optional, add $GOPATH/bin to your $PATH so you don't have to navigate\n# to it to run go binaries\n$ export PATH=$PATH:$GOPATH/bin\n```\n\nAfter all that you can get the demonstration app (which will pull in all\nthe necessary libraries automatically.\n\n```sh\n$ go get github.com/aktau/gofinance/gofinance\n\n# run the app, if you've added $GOPATH/bin to the PATH\n$ gofinance\n```\n\nFeatures\n========\n\n- Parallel fetching of data (with goroutines)\n- (Optional) caching of results (so the sources don't block you),\n  configurable expiry time. This also allows for local pre-calculations that\n  are too expensive to run on every fetch.\n\nUsed libraries\n==============\n\n| Package | Description | License |\n| --- | --- | --- |\n| [code.google.com/p/go.net/html](code.google.com/p/go.net/html) | HTML parser | MIT |\n| [github.com/mattn/go-sqlite3](github.com/mattn/go-sqlite3)| Database driver for SQLite | MIT |\n| [github.com/coopernurse/gorp](github.com/coopernurse/gorp) | ORM(ish) library| MIT |\n| [github.com/mgutz/ansi](github.com/mgutz/ansi) | Ansi terminal colours | MIT |\n\nTodo\n====\n- look at (and possibly implement) some techniques from others packages:\n  - http://make.rafflecopter.com/side-project-jon-haskell.html\n  - [bateman](https://github.com/fearofcode/bateman)\n  - [tybee](https://github.com/yanatan16/tybee#design)\n  - [golang-spsa](https://github.com/yanatan16/golang-spsa)\n- classify the dividend level of stock, e.g.: aristocrat, ...\n- find a way to request echange rates (historical rates as well), to be\n  able to indicate when's a good time to buy foreign securities. (it\n  appears both Yahoo and Bloomberg have these as pseudo-securities:\n  - Yahoo: EURUSD=X -\u003e http://chart.finance.yahoo.com/z?p=m50%2Cm200\u0026q=l\u0026s=VFEM.AS\u0026t=2y\u0026c=VYM,EURUSD=X)\n  - Bloomberg: EURUSD:CUR -\u003e http://www.bloomberg.com/quote/EURUSD:CUR (already working)\n  - Alt: http://www.exchange-rates.org/history/EUR/USD/T\n  - StackExchange: http://quant.stackexchange.com/questions/141/what-data-sources-are-available-online\n- fallback to Yahoo Finance CSV when the YQL interface response with\n  things like \"too many instructions executed\".\n- morningstar: scrape morningstar (all versions) as a ternary source,\n  then we can be pretty sure that the app stays working for a while even\n  if a source changes its format. Pull requests can then be submitted to\n  fix the source. A couple of things Morningstar has that I haven't been\n  able to find in others:\n  - It has industry and regional data for funds/ETF's, which could\n    become very handy when factoring in currency risk and portfolio\n    exposure.\n  - It lists the funds' own benchmark index and a Morningstar assigned\n    one. We could make neat comparisons with those.\n- bloomberg: Funds/ETFs have a different layout than normal stocks on\n  Bloomberg, adapt to that.\n- Combine data from Yahoo Finance and Bloomberg. (this should be\n  implemented as a Source made out of multiple underlying Sources, like\n  the Cache). If Yahoo Finance doesn't have the data on a company,\n  Bloomberg usually has it. So there needs to be a function that\n  determines if a Quote is \"too incomplete\". In the same vein, things\n  like for example \"dividend yield\" can sometimes differ quite a bit\n  between YF and Bloomberg, we need to find a way to reconcile this.\n- Combine data #2: sometimes neither Bloomberg nor Yahoo have the\n  complete picture of a company. For example, Bloomberg usually has the\n  full dividend yield information and Yahoo often seems to lack it. But\n  Yahoo has more information in other departments, so this could be\n  merged. To do this, we would need a way to specify for each datasource\n  what it is intrinsically \"good\" at, such that when both Yahoo and\n  Bloomberg give dividend information, Bloombergs' is preferred, et\n  cetera.\n- Persist historical data locally (avoid getting blocked). This already\n  happens for quotes if you query through a cache like the SqliteCache.\n- Add an optional ncurses-like userface, for example with termon:\n  https://code.google.com/p/termon/\n- Plotting in the terminal, how to convert png -\u003e ascii? Can't find easy\n  libcaca bindings for now.\n- Somehow emulate the google finance stock screener:\n  https://www.google.com/finance?ei=8EDhUuCpO4eHwAOklwE#stockscreener\n- Calculate dividend yield based on the price you actually paid (in\n  aggregate) for stock you own. Why is this handy? For example: suppose\n  you paid $20 for a stock that pays out $1 in dividends each year. It's\n  dividend yield would be 5% (which is very good). If that stock rises\n  to $40 the next year and the dividend payouts stay the same, the\n  dividend yield would be 2.5% (which is still good but only half of the\n  last time). However, this is not the yield you will be getting if you\n  already own the stock (and bought it at $20). The yield would still be\n  5%, obviously. So, the yield as it stands is a good measure of what\n  you're buying, but not of what you already bought.\n- Calculate effective yields and tax drag. This is hard to do (collect\n  all the info), but once done it would be wonderful to determine how\n  much a fund/stock/ETF is really going to net you. An example: the US\n  levies a 30% tax on dividends as far as I know. This can be reduced to\n  15% if you or your broker make use of a double-tax treaty. Belgium has\n  a 25% dividend tax which is (as of 2014) wholly non-negotiable, you\n  always pay it, no matter where else you already paid taxes. In the\n  Netherlands it is always 15%. In Ireland it appears to be 20% but I\n  don't know if that counts for foreign companies who have their\n  \"domicile\" in Ireland. It's all very confusing. At any rate, the most\n  rosy tax climate I could personally get is first 15% (US) then 25%\n  (BE). I'm too much of a realist to assume I will get that, but one has\n  to take _a_ value. So to calculate the effective yield I would use\n  this formula: `yield * tax in source country * tax in receiving\n  country`. In the case of for example a company with a dividend yield\n  of 2.5%, that would become an effective yield of `2.5% * 0.85 * 0.75 =\n  1.6%`. Which is suddenly a whole lot less great. As such, one realizes\n  it takes quite a bit more dividend yield to beat a bank account by a\n  nice margin. In a slightly worse case, I would also have to pay taxes\n  in Holland, as that's where I usually buy shares (on the Amsterdam\n  Euronext), so that would become `2.5% * 0.85 * 0.85 * 0.75 = 1.35%`.\n  And that's how you hit rock bottom, even with an initially nice\n  dividend yield. It gets even worse, if you want to see how your\n  purchasing power will evolve, you have to take inflation into account.\n  So let's do that. The average inflation in Belgium for 2013 was 1.11%\n  (1.43% for Germany). That means that €1 in 2012 is worth `€1 / 1.0111\n  = 0.989` in 2013. And so the final formula becomes `2.5% * 0.85 * 0.85\n  * 0.75 - 1.11% = 0.24%`. And so, there's nothing left. Note that the\n  levied taxes are massively important here. In the optimal case, where\n  only Belgium and the US are paid (at the reduced US rate of 15%), we\n  get an effective rate of 0.48%, which is not good but already double\n  the other one. That said, it is often the case than when viewing yield\n  estimates, source tax has already been incorporated! Let's take VUSA\n  as an example, a Vanguard tracker for the S\u0026P 500, domiciled in\n  Ireland. The US-based variant of this is VOO.  When you look at the\n  yield difference between the two you'll notice that VOO has a yield of\n  2.09%, while VUSA has a yield of 1.63%. Why is this less? Because the\n  dividend withholding tax has already been deducted (that's 15% because\n  Ireland has a treaty with the US). Yet there's bound to be some extra\n  cost, as a 15% tax rate would lead to a VUSA yield of 2.09%\n  * 0.85 = 1.78%, but the reality says it's 1.63% (which corresponds to\n  a \"taxation\" of 23%). This sounds bad for the european investor. But,\n  there's a catch, the US yield is gross, so one has to deduct 30% WHT.\n  Which puts the advantage in the European camp. But, every country\n  wants another slice of the pie if you're in the EU. So you will in the\n  end receive 23% * whatever_your_country_wants%. In my case, Belgium,\n  that's 25%. So you lose again. Hopefully the EU will start acting up\n  against these practices.\n- Dividend payout history (and other indicators) analysis. Even if the\n  yield is good, it's possible that the company has just had a really\n  bad run, and thus its share price is really low. This _might_ mean\n  that it's going to be less succesful (bad), or that the market is just\n  in a slump (good). So companies that are just doing bad are to be\n  avoiding, more so because they are unlikely to keep up their high\n  dividend payments if they are on their way to the poor house. Some\n  extra parameters gofinance could use to provide tips:\n  - historical dividends (are they growing, for how long?)\n  - strong growth and earnings\n  - no heavy drops in share price (we can disentangle the \"losing\n    company\" case from the \"bear market\" case by comparing with the\n    general direction of an index, be the index as representative as\n    possible).  Put shortly, fundamentals. One needs to make sure that\n    the dividend is not going to be slashed and send the yield to\n    kingdom come.\n\nCopyright\n=========\n\nCopyright (c) 2014, The gofinance Authors. All rights reserved.\n\nSee the included AUTHORS file to see who the gofinance authors are.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faktau%2Fgofinance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faktau%2Fgofinance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faktau%2Fgofinance/lists"}