{ "info": { "author": "Matthew Rosendin, Farshad Miraftab", "author_email": "matthew.rosendin@gmail.com, fmiraftab@berkeley.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Lattice\n\n> A cryptocurrency portfolio analytics Python package\n\n![PyPI](https://img.shields.io/pypi/v/nine.svg) [![Maintainability](https://api.codeclimate.com/v1/badges/ab47790d1135959e03eb/maintainability)](https://codeclimate.com/repos/59efa550adedb802cc000014/maintainability)\n\n## Installation\n\nInstall with pip:\n\n```\n$ pip install lattice\n```\n\n## Usage\n\n**Backtesting trading strategies**\n\n```python\nfrom datetime import datetime\nfrom lattice.backtest import Portfolio\n\n# Create a portfolio on October 1st 2017 with $100k\ncreated_at = datetime(year=2017, month=10, day=1)\nportfolio = Portfolio(\n assets={'USD': 100000},\n created_at=created_at\n)\n\n# Make some trades\ntrade_date = datetime(2017, 10, 1)\nportfolio.trade_asset(39000, 'USD', 'BTC', trade_date)\nportfolio.trade_asset(39000, 'USD', 'ETH', trade_date)\nportfolio.trade_asset(22000, 'USD', 'LTC', trade_date)\n\n# Get the current value\ndate = datetime(2017, 10, 24)\nportfolio.get_value()\nportfolio.get_value(date) # at a given date\n\n# View the current portfolio\nportfolio.assets\n# => {'USD': 8515.5, 'BTC': 8.8335220838, 'ETH': 130.434782609, 'LTC': 423.07692307}\n\n# View the portfolio's history\nportfolio.history\n# => [{'amount': 100000, 'asset': 'USD', 'datetime': '2017-10-01 00:00:00'}, {'amount': -39000, 'asset': 'USD', 'datetime': '2017-10-01 00:00:00'}, {'amount': 8.8335220838, 'asset': 'BTC', 'datetime': '2017-10-01 00:00:00'}, {'amount': -39000, 'asset': 'USD', 'datetime': '2017-10-01 00:00:00'}, {'amount': 130.434782609, 'asset': 'ETH', 'datetime': '2017-10-01'00:00:00 }, {'amount': -22000, 'asset': 'USD', 'datetime': '2017-10-01 00:00:00'}, {'amount': 423.07692307, 'asset': 'LTC', 'datetime': '2017-10-01'00:00:00 }, {'amount': -1.5, 'asset': 'BTC', 'datetime': '2017-10-24 18:57:30.665241' }, {'amount': 8515.5, 'asset': 'USD', 'datetime': '2017-10-24 18:57:30.665241' }]\n\n# View the historical value data points\nportfolio.get_historical_value(datetime(2017, 10, 1))\n\n# Get portfolio value of all 10 portfolios for a portfolio created at the start of October\nfrom lattice.backtest import Portfolio\nfrom lattice.optimize import Allocator\n\ndef polyledger_portfolio_values(since):\n allocations = Allocator(coins=['BTC', 'LTC', 'ETH']).allocate()\n for index, allocation in allocations.iterrows():\n p = Portfolio({'USD': 10000}, since)\n for coin in allocation.keys():\n amount = (allocation[coin]/100) * 10000\n p.trade_asset(amount, 'USD', coin, since)\n print(p.get_value())\n\n# Compare to Bitwise\ndef bitwise_portfolio_value(since):\n p = Portfolio({'USD': 10000}, since)\n bitwise_alloc = {\n 'BTC': 0.6815, 'ETH': 0.1445, 'BCH': 0.0568, 'XRP': 0.0481, 'LTC': 0.0194,\n 'DASH': 0.0147, 'ZEC': 0.0141, 'XMR': 0.0077, 'ETC': 0.0069, 'NEO': 0.0062\n }\n for coin, fraction in bitwise_alloc.items():\n amount = fraction * 10000\n p.trade_asset(amount, 'USD', coin, since)\n print(p.get_value())\n\nsince = datetime(year=2017, month=10, day=1)\npolyledger_portfolio_values(since)\nbitwise_portfolio_value(since)\n```\n\n**Optimizing portfolio allocations**\n\n```python\nfrom lattice.optimize import Allocator\n\ncoins = ['BTC', 'ETH', 'LTC', 'XRP']\nallocator = Allocator(coins=coins)\nallocations = allocator.allocate()\nrisk_index = 5 # Risk indices are from 0 to 5\nallocations.loc[risk_index]\n```\n\n**Saving data to a CSV**\n\n```python\nfrom datetime import date\nfrom lattice.data import Manager\n\nstart = date(year=2017, month=1, day=1)\nend = date(year=2017, month=6, day=1)\ncoins = ['BTC', 'LTC', 'ETH']\nfilepath = '/Users/ari/Desktop/prices.csv'\n\nmanager = Manager(coins)\ndf = manager.get_historic_data(start, end)\ndf.to_csv(filepath)\n```\n\n## Development\n\n### Getting Started\n\n**Virtual Environment**\n\nThis project uses [virtualenv](http://pypi.python.org/pypi/virtualenv) to isolate the development environment from the rest of the local filesystem. You must create the virtual environment, activate it, and deactivate it when you finish working.\n\n* Create the virtual environment with `python3 -m venv venv`.\n* Activate the virtual environment from within the project directory with `$ source venv/bin/activate`.\n* Now you can install the project dependencies with `(venv) $ pip3 install -r requirements.txt`.\n* When you are done working in the virtual environment, you can deactivate it: `(env) $ deactivate`. See the [python guide](http://docs.python-guide.org/en/latest/dev/virtualenvs/) for more information.\n\n**Makefile**\n\nLattice comes with a Makefile which enables some useful commands. From the project root, run `make help` for a list of commands.\n\n**Testing**\n\nTo run the full test suite, use `make test`. To get a code coverage report, ensure [coverage](https://coverage.readthedocs.io/en/coverage-4.4.2/) is installed and run\n\n```\n$ coverage run --source lattice setup.py test\n```\n\nTo get the report,\n\n```\n$ coverage report -m\n```\n\n### Packaging and Distributing\n\n#### GitHub Release\n\nBefore tagging a release, ensure that `make test` and `make lint` pass without errors.\n\n```\n$ git tag -a MAJOR.MINOR.PATCH -m \"Description of release goes here\"\n$ git push --tags\n```\n\nAlthough not necessary, you should also update the version in `setup.py`.\n\n#### PyPi\n\nEnsure `wheel` and `twine` are installed. Then inside the directory,\n\n1. `make clean-build`\n1. `python setup.py sdist`\n1. `python setup.py bdist_wheel`\n1. `twine upload dist/*`\n\nSee the [Python documentation](https://packaging.python.org/tutorials/distributing-packages/) for more info.\n\n### Generating Documentation\n\nLattice uses [Sphinx](http://www.sphinx-doc.org/en/stable/) to generate documentation output to `./docs`.\n\nCommand to build documentation:\n\n```\n$ cd docs && make html\n```\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/polyledger/lattice/archive/v0.1-alpha.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/polyledger/lattice", "keywords": "cryptocurrency,prices,analytics,crypto,data,wallet,backtest,csv", "license": "", "maintainer": "", "maintainer_email": "", "name": "lattice", "package_url": "https://pypi.org/project/lattice/", "platform": "", "project_url": "https://pypi.org/project/lattice/", "project_urls": { "Download": "https://github.com/polyledger/lattice/archive/v0.1-alpha.tar.gz", "Homepage": "https://github.com/polyledger/lattice" }, "release_url": "https://pypi.org/project/lattice/1.0.0/", "requires_dist": [ "matplotlib", "numpy", "pandas", "python-dateutil", "requests", "scipy" ], "requires_python": "", "summary": "A cryptocurrency market data utility package", "version": "1.0.0" }, "last_serial": 4274341, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "c7852e52f25fabd3e371b2fa2b5a4754", "sha256": "c861e96c1aa06388689bdfa99fd04ffde7a66ca89e2d4ec4857b4ce6508cbb47" }, "downloads": -1, "filename": "lattice-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c7852e52f25fabd3e371b2fa2b5a4754", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 62114, "upload_time": "2018-09-15T04:06:49", "url": "https://files.pythonhosted.org/packages/d2/03/e7d5f218f1fee0d0f89300fa4fb0aba697af1602fc7b23c528ed2a07b807/lattice-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3778fd8c347c17b1d9b6c252d0df68ab", "sha256": "cbeaaacb7a7a25c7cc0faf6fbec052cc496edc7a388169ed196ec1227e3e73bd" }, "downloads": -1, "filename": "lattice-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3778fd8c347c17b1d9b6c252d0df68ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14646, "upload_time": "2018-09-15T04:06:52", "url": "https://files.pythonhosted.org/packages/34/ee/46b67b50dc6a9a6900f90fec76cec1ed3ffd1e707b6fac7d0d707db8e622/lattice-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c7852e52f25fabd3e371b2fa2b5a4754", "sha256": "c861e96c1aa06388689bdfa99fd04ffde7a66ca89e2d4ec4857b4ce6508cbb47" }, "downloads": -1, "filename": "lattice-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c7852e52f25fabd3e371b2fa2b5a4754", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 62114, "upload_time": "2018-09-15T04:06:49", "url": "https://files.pythonhosted.org/packages/d2/03/e7d5f218f1fee0d0f89300fa4fb0aba697af1602fc7b23c528ed2a07b807/lattice-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3778fd8c347c17b1d9b6c252d0df68ab", "sha256": "cbeaaacb7a7a25c7cc0faf6fbec052cc496edc7a388169ed196ec1227e3e73bd" }, "downloads": -1, "filename": "lattice-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3778fd8c347c17b1d9b6c252d0df68ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14646, "upload_time": "2018-09-15T04:06:52", "url": "https://files.pythonhosted.org/packages/34/ee/46b67b50dc6a9a6900f90fec76cec1ed3ffd1e707b6fac7d0d707db8e622/lattice-1.0.0.tar.gz" } ] }