Skip to content

Remove all OFX Home code #197

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,6 @@ its nickname instead:

$ ofxget prof amex

Or, if the server is known to OFX Home, then you can just use its database
ID (the end part of its `institution page on OFX Home`_):

.. code-block:: bash

$ ofxget prof --ofxhome 424

Any of these work just fine, dumping a load of markup on the screen telling us
what OFX services are available and some parameters for accessing them.

Expand All @@ -192,12 +185,6 @@ provide a server nickname.

$ ofxget prof myfi --write --org AMEX --fid 3101 --url https://online.americanexpress.com/myca/ofxdl/desktop/desktopDownload.do\?request_type\=nl_ofxdownload

If your server is up on OFX Home, this works as well:

.. code-block:: bash

ofxget prof myfi --ofxhome 424 --write

It's also easy to write a configuration file manually in a text editor - it's
just the command line options in simple INI format, with a server nicknames as
section headers. You can find a sample at
Expand Down Expand Up @@ -232,16 +219,6 @@ Our configuration file will look like this:
org: AMEX
fid: 3101

Alternatively, since AmEx has working parameters listed on OFX Home, you could
just use the OFX Home API to look them up for each request. Using the OFX Home
database id (at the end of the webpage URL), the config looks like this:

.. code-block:: ini

# American Express
[amex]
ofxhome: 424

With either configuration, we can now use the provider nickname to make our
connection more conveniently:

Expand Down Expand Up @@ -608,8 +585,6 @@ Other methods available:
* ``OFXClient.request_accounts()``- ACCTINFORQ
* ``OFXClient.request_tax1099()``- TAX1099RQ (still a WIP)

.. _OFX Home: http://www.ofxhome.com/
.. _institution page on OFX Home: http://www.ofxhome.com/index.php/institution/view/424
.. _OFX Blog: https://ofxblog.wordpress.com/
.. _ABA routing number: http://routingnumber.aba.com/default1.aspx
.. _getfidata.sh: https://web.archive.org/web/20070120102800/http://www.jongsma.org/gc/bankinfo/getfidata.sh.gz
Expand Down
1 change: 0 additions & 1 deletion docs/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ More open-source OFX code

.. _OFX spec: https://financialdataexchange.org/ofx
.. _Quicken data mapping guide: https://web.archive.org/web/20110908185057if_/http://fi.intuit.com/ofximplementation/dl/OFXDataMappingGuide.pdfi
.. _OFX Home: http://www.ofxhome.com/
.. _libofx: https://github.com/libofx/libofx
.. _ofxparse: https://github.com/jseutter/ofxparse
.. _csv2ofx: https://github.com/reubano/csv2ofx
8 changes: 0 additions & 8 deletions ofxtools/config/ofxget_example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ bankid = 056073502
checking = 1234567890
moneymrkt = 1234567890

# Since credit card accts don't have a routing #, they can be placed in
# any config section with proper url/org/fid
[amex]
# An example of referring to OFX Home for an API lookup, rather than manually
# specifying URL/ORG/FID.
ofxhome = 424
creditcard = 111122233344556, 222333445561111

# Brokerage accounts are specified by brokerid/investment
[ameritrade]
url = https://ofxs.ameritrade.com/cgi-bin/apps/OFX
Expand Down
168 changes: 0 additions & 168 deletions ofxtools/ofxhome.py

This file was deleted.

45 changes: 7 additions & 38 deletions ofxtools/scripts/ofxget.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


# local imports
from ofxtools import Client, header, Parser, utils, ofxhome, config, models
from ofxtools import Client, header, Parser, utils, config, models
from ofxtools.Client import (
OFXClient,
StmtRq,
Expand Down Expand Up @@ -206,9 +206,6 @@ def add_subparser(

if server:
parser.add_argument("--url", help="OFX server URL")
parser.add_argument(
"--ofxhome", metavar="ID#", help="FI id# on http://www.ofxhome.com/"
)
parser.add_argument(
"-w",
"--write",
Expand Down Expand Up @@ -849,7 +846,6 @@ def __init__(self, *args, **kwargs):
"verbose": 0,
"server": "",
"url": "",
"ofxhome": "",
"version": 203,
"org": "",
"fid": "",
Expand Down Expand Up @@ -898,13 +894,11 @@ def __init__(self, *args, **kwargs):
# "Configurable" means "will be read from / written to config file".
# Subdivided into -
# "Configurable server", i.e. parameters used establish an OFX connection
# (the kind of thing you'd pass to OFXClient.__init__(), which is
# how they're used by update_fi_cfg.py); and
# (the kind of thing you'd pass to OFXClient.__init__()); and
# "Configurable user", i.e. auth/account parameters that are completely
# user-specific and won't be shared by different users of the library.
configurable_srvr = (
"url",
"ofxhome",
"version",
"pretty",
"unclosedelements",
Expand Down Expand Up @@ -1081,13 +1075,6 @@ def merge_config(
merged: ArgsType = ChainMap(_args, user_cfg, DEFAULTS) # type: ignore
# logger.debug(f"CLI args merged with user configs and defaults: {extrargs(merged)}")

# Try to perform an OFX Home lookup if:
# - it's configured from the CLI
# - it's configured in ofxget.cfg
# - we don't have a URL
if "ofxhome" in _args or "ofxhome" in user_cfg or (not merged["url"]):
merge_from_ofxhome(merged)

if not (
merged.get("url", None)
or merged.get("dryrun", False)
Expand All @@ -1099,7 +1086,7 @@ def merge_config(
logger.error(err)
msg = (
f"{err} - please provide a server nickname, "
"or configure 'url' / 'ofxhome'\n"
"or configure 'url'\n"
)
print(msg)
command = merged["request"]
Expand All @@ -1113,33 +1100,13 @@ def merge_config(
merged["server"] = None
else:
logger.error(err)
msg = f"{err} - please configure 'url' or 'ofxhome' for server '{server}'"
msg = f"{err} - please configure 'url' for server '{server}'"
raise ValueError(msg)

logger.info(f"Merged args: {extrargs(merged)}")
return merged


def merge_from_ofxhome(args: ArgsType):
ofxhome_id = args["ofxhome"]
if ofxhome_id:
logger.info(f"Looking up OFX Home API for id#{ofxhome_id}")
lookup = ofxhome.lookup(ofxhome_id)
if lookup:
logger.debug(f"OFX Home lookup found {lookup}")
# Insert OFX Home lookup ahead of DEFAULTS but after
# CLI args and user configss
args.maps.insert(
-1,
{
"url": lookup.url,
"org": lookup.org,
"fid": lookup.fid,
"brokerid": lookup.brokerid,
},
)


def extrargs(args: ArgsType) -> dict:
"""Extract non-null args"""
return {k: v for k, v in args.items() if v not in NULL_ARGS}
Expand Down Expand Up @@ -1484,6 +1451,7 @@ def list_fis(args: ArgsType) -> None:
msg = f"Unknown server '{server}'"
raise ValueError(msg)
else:
# Note: ofxhome.com doesn't exist anymore, but we still use its IDs for name lookups.
ofxhome = USERCFG[server].get("ofxhome", "")
name = USERCFG["NAMES"].get(ofxhome, "")
config = [" = ".join(pair) for pair in USERCFG[server].items()]
Expand All @@ -1499,7 +1467,8 @@ def fi_index() -> Sequence[Tuple[str, str, str]]:
names = {id_: name for id_, name in USERCFG["NAMES"].items()}
cfg_default_sect = USERCFG.default_section # type: ignore
servers = [
(names.get(sct.get("ofxhome", None), ""), nick, sct.get("ofxhome", "--"))
# Note: ofxhome.com doesn't exist anymore, but we still use its IDs for name lookups.
(names.get(sct.get("ofxhome", ""), ""), nick, sct.get("ofxhome", "--"))
for nick, sct in USERCFG.items()
if nick not in (cfg_default_sect, "NAMES") and "url" in sct
]
Expand Down
Loading