revenyouio / bots-lab Goto Github PK
View Code? Open in Web Editor NEWBacktesting tool and connector for the platform Bots.
Backtesting tool and connector for the platform Bots.
Currently the dataframe values are float64 values I believe, I was wondering if it is possible to turn these values to native floats so that they don't need to be converted or if there is a default way to deal with this so that there is no time spent on fixing this.
After building the docker and trying to read an other strategy (the default ones or any self made strategy) the error 'bot not found' keeps coming up. Latest terminal output below:
Successfully tagged docker_bot:latest
Recreating docker_bot_1 ... done
Attaching to docker_bot_1
bot_1 | /usr/local/lib/python3.8/site-packages/pandas_datareader/compat/__init__.py:7: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
bot_1 | from pandas.util.testing import assert_frame_equal
bot_1 | Traceback (most recent call last):
bot_1 | File "run_test.py", line 10, in import_bot
bot_1 | return importlib.import_module(name)
bot_1 | File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
bot_1 | return _bootstrap._gcd_import(name[level:], package, level)
bot_1 | File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
bot_1 | File "<frozen importlib._bootstrap>", line 991, in _find_and_load
bot_1 | File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
bot_1 | File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
bot_1 | File "<frozen importlib._bootstrap_external>", line 783, in exec_module
bot_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
bot_1 | File "/opt/bot/bots/sma.py", line 1, in <module>
bot_1 | import talib
bot_1 | File "/usr/local/lib/python3.8/site-packages/talib/__init__.py", line 43, in <module>
bot_1 | from ._ta_lib import (
bot_1 | ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory
bot_1 |
bot_1 | During handling of the above exception, another exception occurred:
bot_1 |
bot_1 | Traceback (most recent call last):
bot_1 | File "run_test.py", line 29, in <module>
bot_1 | bot = import_bot(name = bot_name)
bot_1 | File "run_test.py", line 12, in import_bot
bot_1 | raise Exception(f'Bot module {name} does not exist')
bot_1 | Exception: Bot module bots.sma does not exist
docker_bot_1 exited with code 1
Due to changes in the latest released jinja2 the project is failing to run.
The following exception is thrown:
Attaching to docker_bot_1
bot_1 | Traceback (most recent call last):
bot_1 | File "run_test.py", line 4, in <module>
bot_1 | from youengine.helpers.analyze import analyze_mpl, analyze_bokeh
bot_1 | File "/opt/bot/youengine/helpers/analyze.py", line 4, in <module>
bot_1 | import bokeh.plotting
bot_1 | File "/usr/local/lib/python3.8/site-packages/bokeh/plotting/__init__.py", line 67, in <module>
bot_1 | from ..document import Document; Document
bot_1 | File "/usr/local/lib/python3.8/site-packages/bokeh/document/__init__.py", line 35, in <module>
bot_1 | from .document import DEFAULT_TITLE ; DEFAULT_TITLE
bot_1 | File "/usr/local/lib/python3.8/site-packages/bokeh/document/document.py", line 49, in <module>
bot_1 | from ..core.templates import FILE
bot_1 | File "/usr/local/lib/python3.8/site-packages/bokeh/core/templates.py", line 42, in <module>
bot_1 | from jinja2 import Environment, FileSystemLoader, Markup
bot_1 | ImportError: cannot import name 'Markup' from 'jinja2' (/usr/local/lib/python3.8/site-packages/jinja2/__init__.py)
docker_bot_1 exited with code 1
By adding a specific version range in requirements.txt for jinja2, the issue is fixed.
Jinja2>=2.10.1,<3.1
PullRequest: #26
When in a buy position, I'd like to define my stoploss and take profit every tick and update them accordingly. Currently it's not possible to set these based on the current position, and it's not possible to adjust these variables in the buy_and_sell script every tick.
Currently you have to select one pair to trade one. It would be nice if you can select multiple pairs to run at the same time (and split funds by choice on these pairs). To consider:
It would be great if next to the backtesting graph a file with the entry point (time, price, direction) and subsequently exit point (time, price, direction) would be created, so we can analyse it more in depth.
Function throws errors in:
if(analyze): self.analyze(title_suffix=self.pair, **kwargs)
Fixing this is a distraction as the analyze function is a placeholder and doesn't do anything - should be removed?
def analyze(self): pass
I have a error.
My strategy is build in the freqtrade style so now i want to transform it to the bots style, but is a little complex. I found it difficult because bots cannot accept libary's used by freqtrade so you need to rewrite your whole strat, Now do i have a error whom i found it hard to find a answer online for so i ask directly to you. In the following code do i get this erorr:
from ctypes.wintypes import SHORT
from fileinput import close
from operator import truediv
import numpy as np # noqa
import pandas as pd # noqa
from functools import reduce
from pandas import DataFrame
import talib
SHORT = 56
LONG = 32
rsi = talib.RSI
upperbb1, middlebb1, lowerbb1 = talib.BBANDS(DataFrame['close'], nbdevup=1, nbdevdn=1, timeperiod=20)
upperbb2, middlebb2, lowerbb2 = talib.BBANDS(DataFrame['close'], nbdevup=2, nbdevdn=2, timeperiod=20)
upperbb3, middlebb3, lowerbb3 = talib.BBANDS(DataFrame['close'], nbdevup=3, nbdevdn=3, timeperiod=20)
upperbb4, middlebb4, lowerbb4 = talib.BBANDS(DataFrame['close'], nbdevup=4, nbdevdn=4, timeperiod=20)
def get_buy_or_sell_signal(data):
"""
Main algorithm method (the actual bot!), which will be called every tick.
This method receives a Pandas DataFrame(data). Each row of this Dataframe is a candle.
Rows of a DataFrame are dictionary like objects. To access a row value you can use
the follwing syntax: row_name['column_name']. Based upon this DataFrame the bot must
make a decision to buy, sell or do nothing. See below for a simple example.
Param data:
List of candles or ticker data in the form of a Pandas Dataframe. The test environment
uses candles (historical data) and the live environment ticker data. Candles or ticker data
have minimal the following properties: date, open, high, low, close and volume.
Float64:
The Dataframe number values are of type float64 (numpy dtype float). To convert this values to native
Python floats use the item() function. See below.
Example candle / ticker data:
date(index) open high low close volume date
2020-03-03 12:00:00 0.02608580 0.02613449 0.02581001 0.02581078 59.40688146 2020-03-03 12:00:00
Return: 'buy', 'sell' or None
"""
# skip when the number of rows (candles) is too short
if len(data) < 2:
return None
short = rsi(data['close'].values)
long = rsi(data['close'].values)
# get the last and second to last row
current_candle = data.iloc[-1]
previous_candle = data.iloc[-2]
# return sell signal
if data['close'] < lowerbb1 and long[-1]> 32 :
return 'buy'
elif data['close'] > middlebb1 and short[-1]>56:
return 'sell'
else:
return None
The error is get is this one:
Traceback (most recent call last):
bot_1 | File "run_test.py", line 41, in
bot_1 | bot = import_bot(name = bot_name)
bot_1 | File "run_test.py", line 10, in import_bot
bot_1 | return importlib.import_module(name)
bot_1 | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
bot_1 | return _bootstrap._gcd_import(name[level:], package, level)
bot_1 | File "", line 1014, in _gcd_import
bot_1 | File "", line 991, in _find_and_load
bot_1 | File "", line 975, in _find_and_load_unlocked
bot_1 | File "", line 671, in _load_unlocked
bot_1 | File "", line 843, in exec_module
bot_1 | File "", line 219, in _call_with_frames_removed
bot_1 | File "/opt/bot/bots/bbrsi.py", line 19, in
bot_1 | upperbb1, middlebb1, lowerbb1 = talib.BBANDS(DataFrame['close'], nbdevup=1, nbdevdn=1, timeperiod=20)
bot_1 | TypeError: 'type' object is not subscriptable
docker_bot_1 exited with code 1
What do i need to change in order to let it work? I would appreciate it if you could answer me.
Currently it's not possible to store any variables. For example you want to check a variable multiple ticks before taking action, or you use an indicator to define a threshold that you want stored. (Maybe this aligns with the store current position ticket, depending on how it is designed)
When setting up a test strategy I defined the following strategy (where both sell and buy have the same requirements to force buys only)
macd, macdsignal, macdhist = talib.MACD(data['close'].values, fastperiod=12, slowperiod=26, signalperiod=9)
if macdhist[-1] > 0:
return 'buy'
elif macdhist[-1] > 0:
return 'sell'
else:
return None
The result yields a lot of buys, while the bot is only able to do one buy (since after that all funds are used).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.