{ "info": { "author": "Brenden Matthews", "author_email": "brenden@diddyinc.com", "bugtrack_url": null, "classifiers": [ "License :: Public Domain", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# optimal-buy-cbpro (formerly optimal-buy-gdax)\n\n[![Build Status](https://travis-ci.org/brndnmtthws/optimal-buy-cbpro.svg?branch=master)](https://travis-ci.org/brndnmtthws/optimal-buy-cbpro) [![Maintainability](https://api.codeclimate.com/v1/badges/541bae75a95dad098787/maintainability)](https://codeclimate.com/github/brndnmtthws/optimal-buy-cbpro/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/541bae75a95dad098787/test_coverage)](https://codeclimate.com/github/brndnmtthws/optimal-buy-cbpro/test_coverage) [![PyPI version](https://badge.fury.io/py/optimal-buy-cbpro.svg)](https://badge.fury.io/py/optimal-buy-cbpro)\n\nScheduled buying of BTC, ETH, and LTC from Coinbase Pro (formerly GDAX) optimally!\n\n![crypto](crypto.gif)\n\n# What is this?\n\nThis is a Python script you can use to automatically buy Bitcoin, Ethereum,\nLitecoin, and more using the Coinbase Pro API. By default, it buys these 3 currencies,\nweighted by market cap (as reported by\n[coinmarketcap.com](https://coinmarketcap.com/)), using a form of [dollar cost\naveraging](https://www.bogleheads.org/wiki/Dollar_cost_averaging) according to\nthe following logic (assuming default values):\n\n1. Check current balances of fiat (USD by default), BTC, ETH, and LTC\n1. If the fiat balance is above \\$25, buy BTC, ETH, and LTC weighted by market\n cap, as follows:\n - If there's enough fiat available, place 5 discounted limit orders at the\n current price minus 0.5% up to 4.5%, each order with 1/5th of the remaining\n amount to buy for each coin (see\n \"[Details on the orders placed](#details-on-the-orders-placed)\", below)\n - If there isn't enough USD available, place 1 buy order at 0.5% off the\n current price (see\n \"[Order Minimums](https://support.cbpro.com/customer/portal/articles/2725970-trading-rules)\")\n1. If the fiat account balance is below \\$25 (or whatever you specify), withdraw\n coins to desired addresses\n\nIn effect, this script mimmicks the behaviour of a market cap weighted index\nfund, but without the fees. It also only supports the coins that trade on Coinbase Pro\n(because that's the only exchange that has an API for ACH deposits AFAIK).\n\nYou can also use the same script to schedule deposits from your bank account\nperiodically, such as when you're paid. The parameters may be configured to suit\nyour preferences, such as which coins to buy, external balances, discount\nvalues, number of steps, etc.\n\nOrders, deposits, and withdrawals are tracked in a SQLite DB, and the withdrawn\nbalances are added to the balances on Coinbase Pro to make sure the weights are\nmaintained over time. The SQLite DB can be swapped out for any DB that\nSQLAlchemy supports.\n\nA note on the default parameters: it's likely you'll want to change\n`--starting-discount`, `--discount-step`, or `--order-count`. The more spread\nout the orders are (i.e., difference between the current price and the lowest\npriced order), the longer they will take to fill (if they fill), and the closer\nthe orders are, the more likely you are to miss out on bigger price drops. You\nshould consider your appetite for risk and how much you want to optimize for\ncatching those dips vs. not missing out on gains. There is no magic here. My\npersonal advice is to stick somewhat close to the defaults, and try to\ncontinuously deposit a little more fiat every week to spread the risk but also\ncatch some dips.\n\nIdeally, this script would help to make sure that when we dip\u2014\n\n![dip](buy-the-dip.gif)\n\n**we buy**.\n\n# USE AT OWN RISK\n\nDuh. Not my fault if you lose everything.\n\nUnless you place **absolute trust** in me, some guy from the Internet, I suggest\nyou clone the repo and build your own container to protect yourself from any\ntype of funny business.\n\n# How do I use it?\n\nThe package itself can be used as a Docker container, or by installing the\npip package with `pip install optimal-buy-cbpro`. Using the Docker container\nis recommended to avoid Python environment issues. Instructions for running\nwith Docker and systemd are as follows:\n\n1. Get yourself a hardware wallet, such as a\n [Ledger](https://www.ledgerwallet.com/) or [TREZOR](https://trezor.io/).\n1. Set up a Coinbase Pro account, and link your bank account\n1. Create a Coinbase Pro API key with view, trade, manage, transfer, and bypass-2fa\n permissions\n1. Determine the payment_method_id value by using the\n [Coinbase Pro API](https://docs.pro.coinbase.com/#payment-methods) (you can use your browser's\n developer toolbar,\n [here's a quick video showing how](https://youtu.be/NmSEBGbn7Mc))\n1. Get a machine somewhere (GCE, EC2, Digital Ocean) with Docker and systemd\n1. Copy systemd files over:\n\n $ sudo cp systemd/optimal-buy-cbpro-*.{service,timer} /etc/systemd/system\n\n1. Edit [`/etc/systemd/system/optimal-buy-cbpro-buy.service`](optimal-buy-cbpro-buy.service),\n [`/etc/systemd/system/optimal-buy-cbpro-buy.timer`](optimal-buy-cbpro-buy.timer),\n [`/etc/systemd/system/optimal-buy-cbpro-deposit.service`](optimal-buy-cbpro-deposit.service), and\n [`/etc/systemd/system/optimal-buy-cbpro-deposit.timer`](optimal-buy-cbpro-deposit.timer) to your liking. Make sure you:\n\n - Change the BTC, ETH, and LTC withdrawal addresses to deposit the coins\n into your wallet (use a Ledger or TREZOR)\n - Pop in the correct API keys\n - Check the deposit amount (start with something small, like \\$150, to make\n sure it actually works first)\n - Check the timer dates (it would be sensible to change the hh:mm so your\n script doesn't run the same time as everyone else's), make sure the deposit\n timer fires according to your deposit schedule (keeping in mind that ACH\n takes 2-5 business days to clear, typically)\n - Consider specifying your external balances in order to accurately\n calculate the weights and amounts to purchase\n\n1. Enable the systemd units:\n\n $ sudo systemctl enable optimal-buy-cbpro-buy.service\n $ sudo systemctl enable optimal-buy-cbpro-buy.timer\n $ sudo systemctl enable optimal-buy-cbpro-deposit.service\n $ sudo systemctl enable optimal-buy-cbpro-deposit.timer\n\n1. Start the systemd timers:\n $sudo systemctl start optimal-buy-cbpro-buy.timer$ sudo systemctl start optimal-buy-cbpro-deposit.timer\n\n1. Enjoy!\n\n# Configuration\n\n usage: optimal-buy-cbpro [-h] --mode MODE [--amount AMOUNT] --key KEY\n --b64secret B64SECRET --passphrase PASSPHRASE\n [--api-url API_URL]\n [--payment-method-id PAYMENT_METHOD_ID]\n [--starting-discount STARTING_DISCOUNT]\n [--discount-step DISCOUNT_STEP]\n [--order-count ORDER_COUNT]\n [--fiat-currency FIAT_CURRENCY]\n [--withdrawal-amount WITHDRAWAL_AMOUNT]\n [--db-engine DB_ENGINE] [--max-retries MAX_RETRIES]\n [--coins COINS] [--base-fee BASE_FEE]\n\n Buy coins!\n\n optional arguments:\n -h, --help show this help message and exit\n --mode MODE mode (deposit or buy)\n --amount AMOUNT amount to deposit\n --key KEY API key\n --b64secret B64SECRET\n API secret\n --passphrase PASSPHRASE\n API passphrase\n --api-url API_URL API URL (default: https://api.pro.coinbase.com)\n --payment-method-id PAYMENT_METHOD_ID\n Payment method ID for fiat deposits\n --starting-discount STARTING_DISCOUNT\n starting discount (default: 0.005)\n --discount-step DISCOUNT_STEP\n discount step between orders (default: 0.01)\n --order-count ORDER_COUNT\n number of orders (default: 5)\n --fiat-currency FIAT_CURRENCY\n Fiat currency (default: USD)\n --withdrawal-amount WITHDRAWAL_AMOUNT\n withdraw when fiat balance drops below this amount\n (default: 25)\n --db-engine DB_ENGINE\n SQLAlchemy DB engine (default:\n sqlite:///cbpro_history.db)\n --max-retries MAX_RETRIES\n Maximum number of times to retry if there are any\n failures, such as API issues (default: 3)\n --coins COINS Coins to trade, minimum trade size, withdrawal\n addresses and external balances. Accepts a JSON\n string.\n --base-fee BASE_FEE Default base fee to subtract from overall balance.\n\n Default coins are as follows:\n {\n \"BTC\":{\n \"name\":\"Bitcoin\",\n \"withdrawal_address\":null,\n \"external_balance\":0\n },\n \"ETH\":{\n \"name\":\"Ethereum\",\n \"withdrawal_address\":null,\n \"external_balance\":0\n },\n \"LTC\":{\n \"name\":\"Litecoin\",\n \"withdrawal_address\":null,\n \"external_balance\":0\n }\n }\n\n# Details on the orders placed\n\nBy default, there are 5 orders placed (for each currency) in steps of 1%,\nstarting at a 0.5% discount from the current price. To illustrate, if the\ncurrent price was $100 (per LTC, let's say), and you had$100 to buy, the orders\nwould look like this:\n\n| Order | Size | Price |\n| ----- | ---------- | ------ |\n| 1 | 0.2010 LTC | \\$99.5 |\n| 2 | 0.2030 LTC | \\$98.5 |\n| 3 | 0.2051 LTC | \\$97.5 |\n| 4 | 0.2072 LTC | \\$96.5 |\n| 5 | 0.2094 LTC | \\$95.5 |\n\nFurthermore, the amount of each currency to buy will be based on the current\nmarket cap weighting of each coin. For example, at the time of writing the\nweights are:\n\n| Coin | Market Cap (USD) | Weight |\n| ---- | ----------------- | ------ |\n| BTC | \\$195,824,365,435 | 0.791 |\n| ETH | \\$46,080,472,372 | 0.186 |\n| LTC | \\$5,592,776,540 | 0.023 |\n\nSo if your USD account had \\$1000, the amount purchased of each would\nbecome:\n\n| Coin | Weight | Amount Purchased |\n| ---- | ------ | ---------------- |\n| BTC | 0.791 | \\$791 |\n| ETH | 0.186 | \\$186 |\n| LTC | 0.023 | \\$23 |\n\n# Caveats/limitations\n\n- If you try to trade manually or using some other bot at the same time,\n you're probably going to have a bad time\n- You might have a few dollars (<\\$25, you can change this with\n `--withdrawal-amount`) sitting in your account at all times,\n even when all orders have been filled because it's not always possible to\n fill all orders and there may be small rounding errors (on the order of cents)\n- It makes a best effort with minimal complexity to use all of your fiat,\n but it may not be possible to fill all orders right away\n- It may take a few days for the market to drop enough for the buys to fill\n- If the market experiences a significant bull run, your orders won't be\n filled, but it will reset every 24h (using the default buy timer)\n\n# Tip jar\n\nIf you got some value out of this, please send some coins my way so I can\nretire from my day job:\n\n- BTC: 3EEAE1oKEMnmHGU5Qxibv9mBQyNnes8j8N", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brndnmtthws/optimal-buy-cbpro", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "optimal-buy-cbpro", "package_url": "https://pypi.org/project/optimal-buy-cbpro/", "platform": "", "project_url": "https://pypi.org/project/optimal-buy-cbpro/", "project_urls": { "Homepage": "https://github.com/brndnmtthws/optimal-buy-cbpro" }, "release_url": "https://pypi.org/project/optimal-buy-cbpro/1.1.20/", "requires_dist": null, "requires_python": ">=3.5", "summary": "Buy the coins, optimally!", "version": "1.1.20" }, "last_serial": 5010939, "releases": { "1.1.10": [ { "comment_text": "", "digests": { "md5": "994be3806fe1ff83f34b9c2a9080c6aa", "sha256": "eed59186b156c6a218f46d4ab8fc5130f16dcc89380915a7c669b0f1009320fe" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.10.tar.gz", "has_sig": false, "md5_digest": "994be3806fe1ff83f34b9c2a9080c6aa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16135, "upload_time": "2018-11-26T17:45:43", "url": "https://files.pythonhosted.org/packages/57/b7/5de059e955807b79f0cb549af03079a5e45b8d7337358117e3dde2c1c7d1/optimal_buy_cbpro-1.1.10.tar.gz" } ], "1.1.12": [ { "comment_text": "", "digests": { "md5": "80414511faaf5226e17e6390955b85f0", "sha256": "6b59c7deb47465a2d36cd4ffa1e3d1018cefed419dc6d713261a6945efe8f1e6" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.12.tar.gz", "has_sig": false, "md5_digest": "80414511faaf5226e17e6390955b85f0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16073, "upload_time": "2018-11-26T18:28:06", "url": "https://files.pythonhosted.org/packages/58/38/f84f67cb7780f6789364419b733285742883c070746aac3383e63e24b3be/optimal_buy_cbpro-1.1.12.tar.gz" } ], "1.1.13": [ { "comment_text": "", "digests": { "md5": "15f314c6bbe7b883e558fd3ef44cc6ba", "sha256": "ac095210a7d41132e337796537394a67970f6d6bf725a2f608d743f99365519a" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.13.tar.gz", "has_sig": false, "md5_digest": "15f314c6bbe7b883e558fd3ef44cc6ba", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16069, "upload_time": "2018-11-26T18:37:06", "url": "https://files.pythonhosted.org/packages/73/83/fd3b627aec848a6fbad6f554f170cb1939853251afc160e5f9e702c00007/optimal_buy_cbpro-1.1.13.tar.gz" } ], "1.1.14": [ { "comment_text": "", "digests": { "md5": "fce43d67f259d53b7f82da921c2758f2", "sha256": "eb9b61a0c620ae1902b661d7aade85640e3589c8eddd64ed751a3b1539e392aa" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.14.tar.gz", "has_sig": false, "md5_digest": "fce43d67f259d53b7f82da921c2758f2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16191, "upload_time": "2018-11-28T12:50:44", "url": "https://files.pythonhosted.org/packages/7a/45/94ec8353cd4a2591c19eccc25e52b156a84cc0ad1e06390c2eadeece5da4/optimal_buy_cbpro-1.1.14.tar.gz" } ], "1.1.15": [ { "comment_text": "", "digests": { "md5": "f79e2100b216b682c7b9b9f98ccbcbf4", "sha256": "9f777246964ad2fcaa9b9019168a0b6601993ff0a966ef45672cf8371c9f4a4a" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.15.tar.gz", "has_sig": false, "md5_digest": "f79e2100b216b682c7b9b9f98ccbcbf4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16249, "upload_time": "2018-11-28T13:17:03", "url": "https://files.pythonhosted.org/packages/16/35/1fb75999c7e4d766b4d47370d1498b9bc9be6f164ec12d4481469f4916ab/optimal_buy_cbpro-1.1.15.tar.gz" } ], "1.1.16": [ { "comment_text": "", "digests": { "md5": "3514fd263c899ea6890362fc7b0e1238", "sha256": "01bfb144caa05441d6fb63be2dfd346190aaea530478c3a6386386c348823352" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.16.tar.gz", "has_sig": false, "md5_digest": "3514fd263c899ea6890362fc7b0e1238", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16254, "upload_time": "2018-11-28T13:24:36", "url": "https://files.pythonhosted.org/packages/1c/58/d41117d572588f11c1a038cc8f91d44159873a9bc143a0cbe74a7fa41d97/optimal_buy_cbpro-1.1.16.tar.gz" } ], "1.1.17": [ { "comment_text": "", "digests": { "md5": "07efb9e1c631c5e9964ce2172ea1a15d", "sha256": "7aa7d5d888e5c9a3d5e767d95d5d74c41f77701b32e5ba823a9216e26fa75efa" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.17.tar.gz", "has_sig": false, "md5_digest": "07efb9e1c631c5e9964ce2172ea1a15d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16329, "upload_time": "2018-11-28T13:34:57", "url": "https://files.pythonhosted.org/packages/c3/93/8c8926c3e379175dad1d083d8177a2b34cbaf3e403ce5ac61c6309e25ce5/optimal_buy_cbpro-1.1.17.tar.gz" } ], "1.1.18": [ { "comment_text": "", "digests": { "md5": "07e5542765304f288598f99acb62616c", "sha256": "ca21b84910ad99e0785e63ecc5a520f7f2fb61e34599ea7cb1c7565b03677a46" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.18.tar.gz", "has_sig": false, "md5_digest": "07e5542765304f288598f99acb62616c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16693, "upload_time": "2019-01-15T18:17:35", "url": "https://files.pythonhosted.org/packages/d6/f8/58a84317425c925b1e49892ecefc2bf3fa881da50b8f1841f2a9d773f11d/optimal_buy_cbpro-1.1.18.tar.gz" } ], "1.1.19": [ { "comment_text": "", "digests": { "md5": "a3c765b83fba8988b809876bd63f3b30", "sha256": "7d272088ba32fad1d56b9ee2560f2a81f43a032e8a525c95e93cc5e3905f39c0" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.19.tar.gz", "has_sig": false, "md5_digest": "a3c765b83fba8988b809876bd63f3b30", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16585, "upload_time": "2019-01-24T17:47:34", "url": "https://files.pythonhosted.org/packages/35/34/42c8bb11e0bab1b24cb375e647413590f732e36e570028fdc1a0829b5d98/optimal_buy_cbpro-1.1.19.tar.gz" } ], "1.1.20": [ { "comment_text": "", "digests": { "md5": "0aa30c3f2cd4c7571f1830324e1d7a58", "sha256": "861e9b47f94a3553d61c25987772544378cd73aad3f92d1de6f19673f2a0160e" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.20.tar.gz", "has_sig": false, "md5_digest": "0aa30c3f2cd4c7571f1830324e1d7a58", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16191, "upload_time": "2019-03-31T23:19:31", "url": "https://files.pythonhosted.org/packages/05/b3/63147bd4bf973c773325ae55e4a2a090eb26cd9c784481775f6a6593f85a/optimal_buy_cbpro-1.1.20.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "c4299ba11e221b9edbb8e4e2c34cbd09", "sha256": "f0144e2677447e5491eb45b2f47e4e45780af1e50c4a060724d650863e499881" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.5.tar.gz", "has_sig": false, "md5_digest": "c4299ba11e221b9edbb8e4e2c34cbd09", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14348, "upload_time": "2018-11-26T15:36:46", "url": "https://files.pythonhosted.org/packages/a8/84/379aa6dd7061a7f32f222562749d3f5aa7d471644a8fc4175fb88f18a764/optimal_buy_cbpro-1.1.5.tar.gz" } ], "1.1.6": [ { "comment_text": "", "digests": { "md5": "552536987d8abd89714fc7c1a4842421", "sha256": "1201b4536292a62904b8eeeae1b365a1cd232888b9d66f8e225ec24e9df902bb" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.6.tar.gz", "has_sig": false, "md5_digest": "552536987d8abd89714fc7c1a4842421", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15931, "upload_time": "2018-11-26T15:59:42", "url": "https://files.pythonhosted.org/packages/73/58/ff115f0dd2c9a76e1070be13ffba4588649b99b0ec6100b44ec175da27c5/optimal_buy_cbpro-1.1.6.tar.gz" } ], "1.1.7": [ { "comment_text": "", "digests": { "md5": "28b58570c5ef58a53631479fe7f9f8ac", "sha256": "a62191a77d4e081272c5c3c2a21f694933f25c6ba78f235b2bc81228e7910d86" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.7.tar.gz", "has_sig": false, "md5_digest": "28b58570c5ef58a53631479fe7f9f8ac", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16082, "upload_time": "2018-11-26T16:25:16", "url": "https://files.pythonhosted.org/packages/8f/61/eab681171c3ab512d62e46cd493753ebfac416636b87440272dfc4e9d224/optimal_buy_cbpro-1.1.7.tar.gz" } ], "1.1.8": [ { "comment_text": "", "digests": { "md5": "04f885ee4244ca85fde9b806f0ccd6ad", "sha256": "909e7d3a42b4b957fb4920195e1a6851caac89a501300020a634f260f49ef375" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.8.tar.gz", "has_sig": false, "md5_digest": "04f885ee4244ca85fde9b806f0ccd6ad", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16054, "upload_time": "2018-11-26T16:31:52", "url": "https://files.pythonhosted.org/packages/85/47/df859b81d38da90d1068a72112bea9786a1466595e42661b9e47b6a31054/optimal_buy_cbpro-1.1.8.tar.gz" } ], "1.1.9": [ { "comment_text": "", "digests": { "md5": "9dc9a170dbb96f08ffc115f92621c230", "sha256": "74ad5e8adc51a939b9104a97db931fcf6f542bbb22842492cb2cb35f092adaac" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.9.tar.gz", "has_sig": false, "md5_digest": "9dc9a170dbb96f08ffc115f92621c230", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16094, "upload_time": "2018-11-26T17:34:00", "url": "https://files.pythonhosted.org/packages/bb/57/8ac124b20d4e2bac9e7d8e41b9cf0a788efa738e3e1fa770ce6cc9989cc7/optimal_buy_cbpro-1.1.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0aa30c3f2cd4c7571f1830324e1d7a58", "sha256": "861e9b47f94a3553d61c25987772544378cd73aad3f92d1de6f19673f2a0160e" }, "downloads": -1, "filename": "optimal_buy_cbpro-1.1.20.tar.gz", "has_sig": false, "md5_digest": "0aa30c3f2cd4c7571f1830324e1d7a58", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 16191, "upload_time": "2019-03-31T23:19:31", "url": "https://files.pythonhosted.org/packages/05/b3/63147bd4bf973c773325ae55e4a2a090eb26cd9c784481775f6a6593f85a/optimal_buy_cbpro-1.1.20.tar.gz" } ] }