# OctoBot-Script [0.0.20](https://github.com/Drakkar-Software/OctoBot-Script/tree/master/CHANGELOG.md)
[![PyPI](https://img.shields.io/pypi/v/OctoBot-Script.svg?logo=pypi)](https://pypi.python.org/pypi/octobot-script/)
[![Downloads](https://static.pepy.tech/badge/OctoBot-Script/month)](https://pepy.tech/project/octobot-script)
[![Dockerhub](https://img.shields.io/docker/pulls/drakkarsoftware/OctoBot-Script.svg?logo=docker)](https://hub.docker.com/r/drakkarsoftware/octobot-script)
[![Github-Action-CI](https://github.com/Drakkar-Software/OctoBot-Script/actions/workflows/main.yml/badge.svg)](https://github.com/Drakkar-Software/OctoBot-Script/actions/workflows/main.yml)
## OctoBot-Script Community
[![Telegram Chat](https://img.shields.io/badge/telegram-chat-green.svg?logo=telegram&label=Telegram)](https://t.me/+366CLLZ2NC0xMjFk)
[![Discord](https://img.shields.io/discord/530629985661222912.svg?logo=discord&label=Discord)](https://discord.com/invite/vHkcb8W)
[![Twitter](https://img.shields.io/twitter/follow/DrakkarsOctobot.svg?label=twitter&style=social)](https://twitter.com/DrakkarsOctoBot)
## OctoBot Script is the Quant framework by OctoBot
> OctoBot Script is in alpha version
Documentation available at [octobot.cloud/en/guides/octobot-script](https://www.octobot.cloud/en/guides/octobot-script?utm_source=octobot&utm_medium=dk&utm_campaign=regular_open_source_content&utm_content=octobot_script_readme)
## Install OctoBot Script from pip
> OctoBot Script requires **Python 3.10**
``` {.sourceCode .bash}
python3 -m pip install OctoBot wheel appdirs==1.4.4
python3 -m pip install octobot-script
```
## Example of a backtesting script
### Script
``` python
import asyncio
import tulipy # Can be any TA library.
import octobot_script as obs
async def rsi_test():
async def strategy(ctx):
# Will be called at each candle.
if run_data["entries"] is None:
# Compute entries only once per backtest.
closes = await obs.Close(ctx, max_history=True)
times = await obs.Time(ctx, max_history=True, use_close_time=True)
rsi_v = tulipy.rsi(closes, period=ctx.tentacle.trading_config["period"])
delta = len(closes) - len(rsi_v)
# Populate entries with timestamps of candles where RSI is
# bellow the "rsi_value_buy_threshold" configuration.
run_data["entries"] = {
times[index + delta]
for index, rsi_val in enumerate(rsi_v)
if rsi_val < ctx.tentacle.trading_config["rsi_value_buy_threshold"]
}
await obs.plot_indicator(ctx, "RSI", times[delta:], rsi_v, run_data["entries"])
if obs.current_live_time(ctx) in run_data["entries"]:
# Uses pre-computed entries times to enter positions when relevant.
# Also, instantly set take profits and stop losses.
# Position exists could also be set separately.
await obs.market(ctx, "buy", amount="10%", stop_loss_offset="-15%", take_profit_offset="25%")
# Configuration that will be passed to each run.
# It will be accessible under "ctx.tentacle.trading_config".
config = {
"period": 10,
"rsi_value_buy_threshold": 28,
}
# Read and cache candle data to make subsequent backtesting runs faster.
data = await obs.get_data("BTC/USDT", "1d", start_timestamp=1505606400)
run_data = {
"entries": None,
}
# Run a backtest using the above data, strategy and configuration.
res = await obs.run(data, strategy, config)
print(res.describe())
# Generate and open report including indicators plots
await res.plot(show=True)
# Stop data to release local databases.
await data.stop()
# Call the execution of the script inside "asyncio.run" as
# OctoBot-Script runs using the python asyncio framework.
asyncio.run(rsi_test())
```
### Generated report
![report-p1](https://raw.githubusercontent.com/Drakkar-Software/OctoBot-Script/assets/images/report_1.jpg)
### Join the community
We recently created a telegram channel dedicated to OctoBot Script.
[![Telegram News](https://img.shields.io/static/v1?label=Telegram%20chat&message=Join&logo=telegram&&color=007bff&style=for-the-badge)](https://t.me/+366CLLZ2NC0xMjFk)
Raw data
{
"_id": null,
"home_page": "https://github.com/Drakkar-Software/OctoBot-Script",
"name": "OctoBot-Script",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Drakkar-Software",
"author_email": "contact@drakkar.software",
"download_url": "https://files.pythonhosted.org/packages/e0/f0/785e0a1a05efaa274ba4971a5c816021b84bbc8ebf95a67e5db108cad09e/OctoBot-Script-0.0.20.tar.gz",
"platform": null,
"description": "# OctoBot-Script [0.0.20](https://github.com/Drakkar-Software/OctoBot-Script/tree/master/CHANGELOG.md)\n[![PyPI](https://img.shields.io/pypi/v/OctoBot-Script.svg?logo=pypi)](https://pypi.python.org/pypi/octobot-script/)\n[![Downloads](https://static.pepy.tech/badge/OctoBot-Script/month)](https://pepy.tech/project/octobot-script)\n[![Dockerhub](https://img.shields.io/docker/pulls/drakkarsoftware/OctoBot-Script.svg?logo=docker)](https://hub.docker.com/r/drakkarsoftware/octobot-script)\n[![Github-Action-CI](https://github.com/Drakkar-Software/OctoBot-Script/actions/workflows/main.yml/badge.svg)](https://github.com/Drakkar-Software/OctoBot-Script/actions/workflows/main.yml)\n\n## OctoBot-Script Community\n[![Telegram Chat](https://img.shields.io/badge/telegram-chat-green.svg?logo=telegram&label=Telegram)](https://t.me/+366CLLZ2NC0xMjFk)\n[![Discord](https://img.shields.io/discord/530629985661222912.svg?logo=discord&label=Discord)](https://discord.com/invite/vHkcb8W)\n[![Twitter](https://img.shields.io/twitter/follow/DrakkarsOctobot.svg?label=twitter&style=social)](https://twitter.com/DrakkarsOctoBot)\n\n\n## OctoBot Script is the Quant framework by OctoBot\n\n> OctoBot Script is in alpha version\n\nDocumentation available at [octobot.cloud/en/guides/octobot-script](https://www.octobot.cloud/en/guides/octobot-script?utm_source=octobot&utm_medium=dk&utm_campaign=regular_open_source_content&utm_content=octobot_script_readme)\n\n\n## Install OctoBot Script from pip\n\n> OctoBot Script requires **Python 3.10**\n\n``` {.sourceCode .bash}\npython3 -m pip install OctoBot wheel appdirs==1.4.4\npython3 -m pip install octobot-script\n```\n\n## Example of a backtesting script\n\n### Script\n``` python\nimport asyncio\nimport tulipy # Can be any TA library.\nimport octobot_script as obs\n\n\nasync def rsi_test():\n async def strategy(ctx):\n # Will be called at each candle.\n if run_data[\"entries\"] is None:\n # Compute entries only once per backtest.\n closes = await obs.Close(ctx, max_history=True)\n times = await obs.Time(ctx, max_history=True, use_close_time=True)\n rsi_v = tulipy.rsi(closes, period=ctx.tentacle.trading_config[\"period\"])\n delta = len(closes) - len(rsi_v)\n # Populate entries with timestamps of candles where RSI is\n # bellow the \"rsi_value_buy_threshold\" configuration.\n run_data[\"entries\"] = {\n times[index + delta]\n for index, rsi_val in enumerate(rsi_v)\n if rsi_val < ctx.tentacle.trading_config[\"rsi_value_buy_threshold\"]\n }\n await obs.plot_indicator(ctx, \"RSI\", times[delta:], rsi_v, run_data[\"entries\"])\n if obs.current_live_time(ctx) in run_data[\"entries\"]:\n # Uses pre-computed entries times to enter positions when relevant.\n # Also, instantly set take profits and stop losses.\n # Position exists could also be set separately.\n await obs.market(ctx, \"buy\", amount=\"10%\", stop_loss_offset=\"-15%\", take_profit_offset=\"25%\")\n\n # Configuration that will be passed to each run.\n # It will be accessible under \"ctx.tentacle.trading_config\".\n config = {\n \"period\": 10,\n \"rsi_value_buy_threshold\": 28,\n }\n\n # Read and cache candle data to make subsequent backtesting runs faster.\n data = await obs.get_data(\"BTC/USDT\", \"1d\", start_timestamp=1505606400)\n run_data = {\n \"entries\": None,\n }\n # Run a backtest using the above data, strategy and configuration.\n res = await obs.run(data, strategy, config)\n print(res.describe())\n # Generate and open report including indicators plots \n await res.plot(show=True)\n # Stop data to release local databases.\n await data.stop()\n\n\n# Call the execution of the script inside \"asyncio.run\" as\n# OctoBot-Script runs using the python asyncio framework.\nasyncio.run(rsi_test())\n```\n\n### Generated report\n![report-p1](https://raw.githubusercontent.com/Drakkar-Software/OctoBot-Script/assets/images/report_1.jpg)\n\n### Join the community\nWe recently created a telegram channel dedicated to OctoBot Script.\n\n[![Telegram News](https://img.shields.io/static/v1?label=Telegram%20chat&message=Join&logo=telegram&&color=007bff&style=for-the-badge)](https://t.me/+366CLLZ2NC0xMjFk)\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "Backtesting framework of the OctoBot Ecosystem",
"version": "0.0.20",
"project_urls": {
"Homepage": "https://github.com/Drakkar-Software/OctoBot-Script"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e0f0785e0a1a05efaa274ba4971a5c816021b84bbc8ebf95a67e5db108cad09e",
"md5": "0b196467f4f40dbc402dab749b25b7fd",
"sha256": "14ec6b49246d124a6deae8e3022ff96e794a46f7b151cc2387a1f0883246c88b"
},
"downloads": -1,
"filename": "OctoBot-Script-0.0.20.tar.gz",
"has_sig": false,
"md5_digest": "0b196467f4f40dbc402dab749b25b7fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 36301,
"upload_time": "2024-10-11T08:36:24",
"upload_time_iso_8601": "2024-10-11T08:36:24.971902Z",
"url": "https://files.pythonhosted.org/packages/e0/f0/785e0a1a05efaa274ba4971a5c816021b84bbc8ebf95a67e5db108cad09e/OctoBot-Script-0.0.20.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 08:36:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Drakkar-Software",
"github_project": "OctoBot-Script",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "octobot-script"
}