blankly


Nameblankly JSON
Version 1.18.25b0 PyPI version JSON
download
home_pagehttps://github.com/Blankly-Finance/Blankly
SummaryRapidly build, backtest & deploy trading bots
upload_time2023-07-23 15:30:12
maintainer
docs_urlNone
authorblankly
requires_python
licenselgpl-3.0
keywords crypto stocks quantitative finance exchanges bot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

<br />

<div align="center">
   <img style="margin: 0 auto; padding-bottom: 15px; padding-top: 30px" width=70%" src="https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/blankly-github-logo.png?alt=media&token=8f436cd2-3d28-432c-867a-afef780f4260">
</div>
<br />

<div align="center">
  <b>πŸ’¨  Rapidly build and deploy quantitative models for stocks, crypto, and forex  πŸš€</b>
</div>
<br />


<p align="center">
   <a target="_blank" href="https://sonarcloud.io/dashboard?id=Blankly-Finance_Blankly"><img src="https://sonarcloud.io/api/project_badges/measure?project=Blankly-Finance_Blankly&metric=sqale_rating"></a>
   <a target="_blank" href="https://sonarcloud.io/dashboard?id=Blankly-Finance_Blankly"><img src="https://sonarcloud.io/api/project_badges/measure?project=Blankly-Finance_Blankly&metric=alert_status"></a>
   <a target="_blank" href="https://github.com/Blankly-Finance/Blankly/actions/workflows/test.yml"><img src="https://github.com/Blankly-Finance/Blankly/actions/workflows/test.yml/badge.svg?branch=main"></a> <br>
   <a target="_blank" href="https://pepy.tech/project/blankly"><img src="https://pepy.tech/badge/blankly/month"></a>
   <a target="_blank" href="https://github.com/Blankly-Finance/Blankly/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/blankly?color=gree"></a>
   <a target="_blank" href="https://github.com/Blankly-Finance/Blankly/stargazers"><img src="https://img.shields.io/github/stars/blankly-finance/blankly?style=social"></a>
   <a target="_blank" href="https://discord.gg/XWcmy7Y9bb"><img src="https://img.shields.io/discord/821563936297451530.svg?color=7289da&label=Blankly%20Discord&logo=discord&style=flat"></a>
   <a target="_blank" href="https://reddit.com/r/blankly"><img src="https://badgen.net/reddit/subscribers/r/blankly"></a>
</p>
<p align="center">
    <a target="_blank" href="https://docs.blankly.finance">View Docs</a>
    Β·
    <a target="_blank" href="https://blankly.finance">Our Website</a>
    Β·
    <a target="_blank" href="https://blankly.substack.com">Join Our Newsletter</a>
    Β·
    <a href="#quickstart">Getting Started</a>
  </p>

---

## Why Blankly? 

Blankly is an ecosystem for algotraders enabling anyone to build, monetize and scale their trading algorithms for stocks, crypto, futures or forex. The same code can be backtested, paper traded, sandbox tested and run live by simply changing a single line. Develop locally then deploy, iterate and share using the blankly platform.

The blankly package is designed to be **extremely precise** in both simulation and live trading. **The engineering considerations for highly accurate simulation are described [here](blankly/BACKTESTING_ENGINEERING.md)**

Getting started is easy - just `pip install blankly` and `blankly init`.

Check out our [website](https://blankly.finance) and our [docs](https://docs.blankly.finance).

<div align="center">
<a target="_blank" href="https://youtu.be/pcm0h63rhUU"><img src="https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2Fbuild_a_bot_readme_thumbnail.jpg?alt=media&token=a9dd030a-805c-447f-a970-2bc8e1815662" style="border-radius:10px; width: 50%"></a>
</div>

---------

### Trade Stocks, Crypto, Futures, and Forex

```python
from blankly import Alpaca, CoinbasePro

stocks = Alpaca()
crypto = CoinbasePro()
futures = BinanceFutures()

# Easily perform the same actions across exchanges & asset types
stocks.interface.market_order('AAPL', 'buy', 1)
crypto.interface.market_order('BTC-USD', 'buy', 1)
# Full futures feature set
futures.interface.get_hedge_mode()
```

### Backtest your trades, events, websockets, and custom data

```python
import blankly
"""
This example shows how backtest over tweets
"""

class TwitterBot(blankly.Model):
    def main(self, args):
        while self.has_data:
            self.backtester.value_account()
            self.sleep('1h')

    def event(self, type_: str, data: str):
        # Now check if it's a tweet about Tesla
        if 'tsla' in data.lower() or 'gme' in data.lower():
            # Buy, sell or evaluate your portfolio
            pass


if __name__ == "__main__":
    exchange = blankly.Alpaca()
    model = TwitterBot(exchange)

    # Add the tweets json here
    model.backtester.add_custom_events(blankly.data.JsonEventReader('./tweets.json'))
    # Now add some underlying prices at 1 month
    model.backtester.add_prices('TSLA', '1h', start_date='3/20/22', stop_date='4/15/22')

    # Backtest or run live
    print(model.backtest(args=None, initial_values={'USD': 10000}))

```

**Check out alternative data examples [here](https://docs.blankly.finance/examples/model-framework)**

#### Accurate Backtest Holdings

<div align="center">
    <a><img src="https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2FScreen%20Shot%202022-04-17%20at%202.37.58%20PM.png?alt=media&token=d5738617-e197-4da2-850d-8fbbfda05275" style="border-radius:10px"></a>
</div>


### Go Live in One Line

Seamlessly run your model live!

```python
# Just turn this
strategy.backtest(to='1y')
# Into this
strategy.start()
```

Dates, times, and scheduling adjust on the backend to make the experience instant.

## Quickstart

### Installation

1. First install Blankly using `pip`. Blankly is hosted on [PyPi](https://pypi.org/project/Blankly/).

```bash
$ pip install blankly
```

2. Next, just run:
```bash
$ blankly init
```
This will initialize your working directory.

The command will create the files `keys.json`, `settings.json`, `backtest.json`, `blankly.json` and an example script called `bot.py`.

If you don't want to use our `init` command, you can find the same files in the `examples` folder under [`settings.json`](https://github.com/Blankly-Finance/Blankly/blob/main/examples/settings.json) and [`keys_example.json`](https://github.com/Blankly-Finance/Blankly/blob/main/examples/keys_example.json)

3. From there, **insert your API keys** from your exchange into the generated `keys.json` file or take advantage of the CLI keys prompt.

More information can be found on our [docs](https://docs.blankly.finance)

### Directory format

The working directory format should have *at least* these files:
```
project/
   |-bot.py
   |-keys.json
   |-settings.json
```

#### Additional Info

Make sure you're using a supported version of python. The module is currently tested on these versions:

- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10

For more info, and ways to do more advanced things, check out our [getting started docs](https://docs.blankly.finance).

## Supported Exchanges

| Exchange            | Live Trading | Websockets | Paper Trading | Backtesting |
| ------------------- |--------------| ---------- |--------------| ----------- |
| Coinbase Pro        | 🟒           | 🟒          | 🟒           | 🟒           |
| Binance             | 🟒           | 🟒          | 🟒           | 🟒           |
| Alpaca              | 🟒           | 🟒          | 🟒           | 🟒           |
| OANDA               | 🟒           |  | 🟒           | 🟒           |
| FTX                 | 🟒           | 🟒          | 🟒           | 🟒           |
| KuCoin              | 🟒           | 🟒        | 🟒           | 🟒           |
| Binance Futures | 🟒 | 🟒 | 🟒 | 🟒 |
| FTX Futures | 🟑 | 🟑 | 🟒 | 🟒 |
| Okx | 🟒 | 🟒 | 🟒 | 🟒 |
| Kraken              | 🟑           | 🟑          | 🟑           | 🟑           |
| Keyless Backtesting |              |            |              | 🟒           |
| TD Ameritrade       | πŸ”΄           | πŸ”΄          | πŸ”΄           | πŸ”΄           |
| Webull              | πŸ”΄           | πŸ”΄          | πŸ”΄           | πŸ”΄           |
| Robinhood           | πŸ”΄           | πŸ”΄          | πŸ”΄           | πŸ”΄           |


🟒  = working

🟑  = in development, some or most features are working

πŸ”΄  = planned but not yet in development

## RSI Example

We have a pre-built cookbook examples that implement strategies such as RSI, MACD, and the Golden Cross found in our [examples](https://docs.blankly.finance/examples/golden-cross).

Other Info

### Subscribe to our news!
https://blankly.substack.com/p/coming-soon

### Bugs

Please report any bugs or issues on the GitHub's Issues page.

### Disclaimer 

Trading is risky. We are not responsible for losses incurred using this software, software fitness for any particular purpose, or responsibility for any issues or bugs.
This is free software.

### Contributing

If you would like to support the project, pull requests are welcome.

### Licensing 

**Blankly** is distributed under the [**LGPL License**](https://www.gnu.org/licenses/lgpl-3.0.en.html). See the [LICENSE](/LICENSE) for more details.

New updates every day πŸ’ͺ.

<div align="center">
    <img src="https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2Fblanklybots.png?alt=media&token=005728b0-5f49-476d-968a-07fe0683ca09" style="border-radius:10px; width: 30%">
</div>
Art by DALLΒ·E 2 - "Robots playfully trading stocks synthwave"

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Blankly-Finance/Blankly",
    "name": "blankly",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Crypto,Stocks,Quantitative Finance,Exchanges,Bot",
    "author": "blankly",
    "author_email": "contact@blankly.finance",
    "download_url": "https://files.pythonhosted.org/packages/73/fb/a856f5aaae13280c5d6d0ddd6fd331513f63edc099b15d850e405524a88f/blankly-1.18.25b0.tar.gz",
    "platform": null,
    "description": "\n\n<br />\n\n<div align=\"center\">\n   <img style=\"margin: 0 auto; padding-bottom: 15px; padding-top: 30px\" width=70%\" src=\"https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/blankly-github-logo.png?alt=media&token=8f436cd2-3d28-432c-867a-afef780f4260\">\n</div>\n<br />\n\n<div align=\"center\">\n  <b>\ud83d\udca8  Rapidly build and deploy quantitative models for stocks, crypto, and forex  \ud83d\ude80</b>\n</div>\n<br />\n\n\n<p align=\"center\">\n   <a target=\"_blank\" href=\"https://sonarcloud.io/dashboard?id=Blankly-Finance_Blankly\"><img src=\"https://sonarcloud.io/api/project_badges/measure?project=Blankly-Finance_Blankly&metric=sqale_rating\"></a>\n   <a target=\"_blank\" href=\"https://sonarcloud.io/dashboard?id=Blankly-Finance_Blankly\"><img src=\"https://sonarcloud.io/api/project_badges/measure?project=Blankly-Finance_Blankly&metric=alert_status\"></a>\n   <a target=\"_blank\" href=\"https://github.com/Blankly-Finance/Blankly/actions/workflows/test.yml\"><img src=\"https://github.com/Blankly-Finance/Blankly/actions/workflows/test.yml/badge.svg?branch=main\"></a> <br>\n   <a target=\"_blank\" href=\"https://pepy.tech/project/blankly\"><img src=\"https://pepy.tech/badge/blankly/month\"></a>\n   <a target=\"_blank\" href=\"https://github.com/Blankly-Finance/Blankly/blob/main/LICENSE\"><img src=\"https://img.shields.io/pypi/l/blankly?color=gree\"></a>\n   <a target=\"_blank\" href=\"https://github.com/Blankly-Finance/Blankly/stargazers\"><img src=\"https://img.shields.io/github/stars/blankly-finance/blankly?style=social\"></a>\n   <a target=\"_blank\" href=\"https://discord.gg/XWcmy7Y9bb\"><img src=\"https://img.shields.io/discord/821563936297451530.svg?color=7289da&label=Blankly%20Discord&logo=discord&style=flat\"></a>\n   <a target=\"_blank\" href=\"https://reddit.com/r/blankly\"><img src=\"https://badgen.net/reddit/subscribers/r/blankly\"></a>\n</p>\n<p align=\"center\">\n    <a target=\"_blank\" href=\"https://docs.blankly.finance\">View Docs</a>\n    \u00b7\n    <a target=\"_blank\" href=\"https://blankly.finance\">Our Website</a>\n    \u00b7\n    <a target=\"_blank\" href=\"https://blankly.substack.com\">Join Our Newsletter</a>\n    \u00b7\n    <a href=\"#quickstart\">Getting Started</a>\n  </p>\n\n---\n\n## Why Blankly? \n\nBlankly is an ecosystem for algotraders enabling anyone to build, monetize and scale their trading algorithms for stocks, crypto, futures or forex. The same code can be backtested, paper traded, sandbox tested and run live by simply changing a single line. Develop locally then deploy, iterate and share using the blankly platform.\n\nThe blankly package is designed to be **extremely precise** in both simulation and live trading. **The engineering considerations for highly accurate simulation are described [here](blankly/BACKTESTING_ENGINEERING.md)**\n\nGetting started is easy - just `pip install blankly` and `blankly init`.\n\nCheck out our [website](https://blankly.finance) and our [docs](https://docs.blankly.finance).\n\n<div align=\"center\">\n<a target=\"_blank\" href=\"https://youtu.be/pcm0h63rhUU\"><img src=\"https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2Fbuild_a_bot_readme_thumbnail.jpg?alt=media&token=a9dd030a-805c-447f-a970-2bc8e1815662\" style=\"border-radius:10px; width: 50%\"></a>\n</div>\n\n---------\n\n### Trade Stocks, Crypto, Futures, and Forex\n\n```python\nfrom blankly import Alpaca, CoinbasePro\n\nstocks = Alpaca()\ncrypto = CoinbasePro()\nfutures = BinanceFutures()\n\n# Easily perform the same actions across exchanges & asset types\nstocks.interface.market_order('AAPL', 'buy', 1)\ncrypto.interface.market_order('BTC-USD', 'buy', 1)\n# Full futures feature set\nfutures.interface.get_hedge_mode()\n```\n\n### Backtest your trades, events, websockets, and custom data\n\n```python\nimport blankly\n\"\"\"\nThis example shows how backtest over tweets\n\"\"\"\n\nclass TwitterBot(blankly.Model):\n    def main(self, args):\n        while self.has_data:\n            self.backtester.value_account()\n            self.sleep('1h')\n\n    def event(self, type_: str, data: str):\n        # Now check if it's a tweet about Tesla\n        if 'tsla' in data.lower() or 'gme' in data.lower():\n            # Buy, sell or evaluate your portfolio\n            pass\n\n\nif __name__ == \"__main__\":\n    exchange = blankly.Alpaca()\n    model = TwitterBot(exchange)\n\n    # Add the tweets json here\n    model.backtester.add_custom_events(blankly.data.JsonEventReader('./tweets.json'))\n    # Now add some underlying prices at 1 month\n    model.backtester.add_prices('TSLA', '1h', start_date='3/20/22', stop_date='4/15/22')\n\n    # Backtest or run live\n    print(model.backtest(args=None, initial_values={'USD': 10000}))\n\n```\n\n**Check out alternative data examples [here](https://docs.blankly.finance/examples/model-framework)**\n\n#### Accurate Backtest Holdings\n\n<div align=\"center\">\n    <a><img src=\"https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2FScreen%20Shot%202022-04-17%20at%202.37.58%20PM.png?alt=media&token=d5738617-e197-4da2-850d-8fbbfda05275\" style=\"border-radius:10px\"></a>\n</div>\n\n\n### Go Live in One Line\n\nSeamlessly run your model live!\n\n```python\n# Just turn this\nstrategy.backtest(to='1y')\n# Into this\nstrategy.start()\n```\n\nDates, times, and scheduling adjust on the backend to make the experience instant.\n\n## Quickstart\n\n### Installation\n\n1. First install Blankly using `pip`. Blankly is hosted on [PyPi](https://pypi.org/project/Blankly/).\n\n```bash\n$ pip install blankly\n```\n\n2. Next, just run:\n```bash\n$ blankly init\n```\nThis will initialize your working directory.\n\nThe command will create the files `keys.json`, `settings.json`, `backtest.json`, `blankly.json` and an example script called `bot.py`.\n\nIf you don't want to use our `init` command, you can find the same files in the `examples` folder under [`settings.json`](https://github.com/Blankly-Finance/Blankly/blob/main/examples/settings.json) and [`keys_example.json`](https://github.com/Blankly-Finance/Blankly/blob/main/examples/keys_example.json)\n\n3. From there, **insert your API keys** from your exchange into the generated `keys.json` file or take advantage of the CLI keys prompt.\n\nMore information can be found on our [docs](https://docs.blankly.finance)\n\n### Directory format\n\nThe working directory format should have *at least* these files:\n```\nproject/\n   |-bot.py\n   |-keys.json\n   |-settings.json\n```\n\n#### Additional Info\n\nMake sure you're using a supported version of python. The module is currently tested on these versions:\n\n- Python 3.7\n- Python 3.8\n- Python 3.9\n- Python 3.10\n\nFor more info, and ways to do more advanced things, check out our [getting started docs](https://docs.blankly.finance).\n\n## Supported Exchanges\n\n| Exchange            | Live Trading | Websockets | Paper Trading | Backtesting |\n| ------------------- |--------------| ---------- |--------------| ----------- |\n| Coinbase Pro        | \ud83d\udfe2           | \ud83d\udfe2          | \ud83d\udfe2           | \ud83d\udfe2           |\n| Binance             | \ud83d\udfe2           | \ud83d\udfe2          | \ud83d\udfe2           | \ud83d\udfe2           |\n| Alpaca              | \ud83d\udfe2           | \ud83d\udfe2          | \ud83d\udfe2           | \ud83d\udfe2           |\n| OANDA               | \ud83d\udfe2           |  | \ud83d\udfe2           | \ud83d\udfe2           |\n| FTX                 | \ud83d\udfe2           | \ud83d\udfe2          | \ud83d\udfe2           | \ud83d\udfe2           |\n| KuCoin              | \ud83d\udfe2           | \ud83d\udfe2        | \ud83d\udfe2           | \ud83d\udfe2           |\n| Binance Futures | \ud83d\udfe2 | \ud83d\udfe2 | \ud83d\udfe2 | \ud83d\udfe2 |\n| FTX Futures | \ud83d\udfe1 | \ud83d\udfe1 | \ud83d\udfe2 | \ud83d\udfe2 |\n| Okx | \ud83d\udfe2 | \ud83d\udfe2 | \ud83d\udfe2 | \ud83d\udfe2 |\n| Kraken              | \ud83d\udfe1           | \ud83d\udfe1          | \ud83d\udfe1           | \ud83d\udfe1           |\n| Keyless Backtesting |              |            |              | \ud83d\udfe2           |\n| TD Ameritrade       | \ud83d\udd34           | \ud83d\udd34          | \ud83d\udd34           | \ud83d\udd34           |\n| Webull              | \ud83d\udd34           | \ud83d\udd34          | \ud83d\udd34           | \ud83d\udd34           |\n| Robinhood           | \ud83d\udd34           | \ud83d\udd34          | \ud83d\udd34           | \ud83d\udd34           |\n\n\n\ud83d\udfe2  = working\n\n\ud83d\udfe1  = in development, some or most features are working\n\n\ud83d\udd34  = planned but not yet in development\n\n## RSI Example\n\nWe have a pre-built cookbook examples that implement strategies such as RSI, MACD, and the Golden Cross found in our [examples](https://docs.blankly.finance/examples/golden-cross).\n\nOther Info\n\n### Subscribe to our news!\nhttps://blankly.substack.com/p/coming-soon\n\n### Bugs\n\nPlease report any bugs or issues on the GitHub's Issues page.\n\n### Disclaimer \n\nTrading is risky. We are not responsible for losses incurred using this software, software fitness for any particular purpose, or responsibility for any issues or bugs.\nThis is free software.\n\n### Contributing\n\nIf you would like to support the project, pull requests are welcome.\n\n### Licensing \n\n**Blankly** is distributed under the [**LGPL License**](https://www.gnu.org/licenses/lgpl-3.0.en.html). See the [LICENSE](/LICENSE) for more details.\n\nNew updates every day \ud83d\udcaa.\n\n<div align=\"center\">\n    <img src=\"https://firebasestorage.googleapis.com/v0/b/blankly-6ada5.appspot.com/o/github%2Fblanklybots.png?alt=media&token=005728b0-5f49-476d-968a-07fe0683ca09\" style=\"border-radius:10px; width: 30%\">\n</div>\nArt by DALL\u00b7E 2 - \"Robots playfully trading stocks synthwave\"\n",
    "bugtrack_url": null,
    "license": "lgpl-3.0",
    "summary": "Rapidly build, backtest & deploy trading bots",
    "version": "1.18.25b0",
    "project_urls": {
        "Homepage": "https://github.com/Blankly-Finance/Blankly"
    },
    "split_keywords": [
        "crypto",
        "stocks",
        "quantitative finance",
        "exchanges",
        "bot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd2c72d10d95336b153379425d6232a114e8c8860b8a77966c6d37ad0b5bce84",
                "md5": "1f20bdf90883dffe2b96d4ee4d85edba",
                "sha256": "07549d6b01a5b3c66716fa34ef37e1bbfdb8e5c650bb93f7077a76db8ebd11b6"
            },
            "downloads": -1,
            "filename": "blankly-1.18.25b0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f20bdf90883dffe2b96d4ee4d85edba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 304411,
            "upload_time": "2023-07-23T15:30:10",
            "upload_time_iso_8601": "2023-07-23T15:30:10.251886Z",
            "url": "https://files.pythonhosted.org/packages/dd/2c/72d10d95336b153379425d6232a114e8c8860b8a77966c6d37ad0b5bce84/blankly-1.18.25b0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73fba856f5aaae13280c5d6d0ddd6fd331513f63edc099b15d850e405524a88f",
                "md5": "b33407c99407bf73ab1cf66bd7df913c",
                "sha256": "7b26d4ba685c31465f55a197d87ec296278d696d209e88140f33f0403880d5a4"
            },
            "downloads": -1,
            "filename": "blankly-1.18.25b0.tar.gz",
            "has_sig": false,
            "md5_digest": "b33407c99407bf73ab1cf66bd7df913c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 212222,
            "upload_time": "2023-07-23T15:30:12",
            "upload_time_iso_8601": "2023-07-23T15:30:12.686464Z",
            "url": "https://files.pythonhosted.org/packages/73/fb/a856f5aaae13280c5d6d0ddd6fd331513f63edc099b15d850e405524a88f/blankly-1.18.25b0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-23 15:30:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Blankly-Finance",
    "github_project": "Blankly",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "blankly"
}
        
Elapsed time: 0.08974s