jesse-ai / jesse Goto Github PK
View Code? Open in Web Editor NEWAn advanced crypto trading bot written in Python
Home Page: https://jesse.trade
License: MIT License
An advanced crypto trading bot written in Python
Home Page: https://jesse.trade
License: MIT License
Hi!
How can I tell it to open another positions of the same strategy if the previous has been still holding?
For example I want to have 10 opened positions at the same time.
Tried to optimize a strategy with Ryzen 3990X, it failed at %1 with Uncaught Exception: ZeroDivisionError: integer division or modulo by zero
.
On jesse/modes/optimize_mode/Genetics.py
line 360 is the problem.
360: if i != 0 and i % int(100 / self.cpu_cores) == 0:
361: self.take_snapshot(i * self.cpu_cores)
int(100/128) = 0
in my case.
Hello,
Latest version of branch dashboard.
When you move the mouse over the Equity curve graph it shows "strange" dates, everyone at 08:00 as hour:
Also other time data on Results page are "invalid", they seems timestamps or intervals in seconds maybe;
Anyway, probably you already know about them
Hope it helps
When running backtest with a strategy that needs multiple routes I get this uncaught exception
File "/home/giulio/.local/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/giulio/.local/lib/python3.6/site-packages/jesse/__init__.py", line 293, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "/home/giulio/.local/lib/python3.6/site-packages/jesse/modes/backtest_mode/__init__.py", line 58, in run
simulator(candles)
File "/home/giulio/.local/lib/python3.6/site-packages/jesse/modes/backtest_mode/__init__.py", line 193, in simulator
_simulate_price_change_effect(short_candle, exchange, symbol)
File "/home/giulio/.local/lib/python3.6/site-packages/jesse/modes/backtest_mode/__init__.py", line 314, in _simulate_price_change_effect
p.current_price = real_candle[2]
=========================================================================
Uncaught Exception: AttributeError: 'NoneType' object has no attribute 'current_price'
I think my routes.py file is correct:
routes = [
('Bitfinex', 'ETHEUR', '8h', 'PairStrategy'),
]
extra_candles = [
('Bitfinex', 'EOSEUR', '8h'),
]
Describe the bug
I followed the tutorial, went through pulling candles and storing them into the database. Tried to run backtest but am getting an error of
Uncaught Exception: CandleNotFoundInDatabase: Not enough candles for Binance BTC-USDT exists to run backtest from 2020-07-01 => 2021-10-01.
First available date is 2018-07-12
Last available date is 2021-12-03
To Reproduce
jesse import-candles 'Binance' 'BTC-USDT' '2020-06-01'
jesse backtest '2020-07-01' '2021-10-01'
to backtestThen error occurs
Screenshots
Enviroment (please complete the following information):
MAC OS
Name: jesse
Version: 0.29.3
Hi,
I have a problem when I run backtest on Spot mode. The problem appear at the very end of the trading session, when we compute stats :
[2021-02-05T00:00:00+00:00]: Terminating strategy...
============================== EXCEPTION TRACEBACK:
File "/Users/floriancabirol/miniconda3/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/__init__.py", line 329, in backtest
json=json)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/modes/backtest_mode/__init__.py", line 59, in run
simulator(candles)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/modes/backtest_mode/__init__.py", line 287, in simulator
r.strategy._terminate()
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/strategies/Strategy.py", line 897, in _terminate
round(self.position.pnl_percentage, 2)
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 71, in pnl_percentage
return self.roi
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 79, in roi
return self.pnl / self.total_cost * 100
File "/Users/floriancabirol/miniconda3/lib/python3.7/site-packages/jesse/models/Position.py", line 89, in total_cost
return self.entry_price * abs(self.qty) / self.exchange.futures_leverage
=========================================================================
My config :
Binance': {
'fee': 0.001,
# backtest mode only: accepted are 'spot' and 'futures'
'type': 'spot',
# futures mode only
'settlement_currency': 'USDT',
# accepted values are: 'cross' and 'isolated'
'futures_leverage_mode': 'cross',
# 1x, 2x, 10x, 50x, etc. Enter as integers
'futures_leverage': 1,
# used for spot exchange only
'assets': [
{'asset': 'USDT', 'balance': 10_000},
{'asset': 'BTC', 'balance': 0},
],
},
In the config.py it is required to input redis server details but I'm trying to use redislabs.com which requires a password and adding a key 'redis_password' doesn't work.
Is there a way to go about this or a patch needs to fix this?
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\pydoc.py", line 346, in safeimport
module = import(path)
File "D:\MEGA\algorithm_development\jesse-binance-trader\config.py", line 20
loading candles...
EXCEPTION TRACEBACK:
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\jesse.exe_main.py", line 7, in
sys.exit(cli())
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 764, in call
return self.main(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\jesse_init.py", line 286, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init.py", line 40, in run
candles = load_candles(start_date, finish_date)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init.py", line 91, in _load_candles
required_candles.load_required_candles(c[0], c[1], start_date_str, finish_date_str),
File "c:\programdata\anaconda3\lib\site-packages\jesse\services\required_candles.py", line 40, in load_required_candles
cached_value = cache.get_cache(cache_key)
File "c:\programdata\anaconda3\lib\site-packages\jesse\services\cache.py", line 21, in get_cache
exists = self.db.exists(key)
File "c:\programdata\anaconda3\lib\site-packages\redis\client.py", line 1307, in exists
return self.execute_command('EXISTS', *names)
File "c:\programdata\anaconda3\lib\site-packages\redis\client.py", line 839, in execute_command
return self.parse_response(conn, command_name, **options)
File "c:\programdata\anaconda3\lib\site-packages\redis\client.py", line 853, in parse_response
response = connection.read_response()
File "c:\programdata\anaconda3\lib\site-packages\redis\connection.py", line 687, in read_response
response = self._parser.read_response()
File "c:\programdata\anaconda3\lib\site-packages\redis\connection.py", line 315, in read_response
raise error
Uncaught Exception: AuthenticationError: Authentication required
Hi and thanks for this beautiful framework.
I found an error in the requied_candles.py. Could you please verify?
How to test:
Result:
Uncaught Exception: CandleNotFoundInDatabase: Not enough candles for Binance Futures BTCUSDT exists to run backtest from 2019-10-15 => 2020-05-18.
First available date is 2019-11-20
Last available date is 2020-05-19
Possible reason:
jesse/jesse/services/required_candles.py
Line 53 in 3c5b5fe
candles_duple is empty, because in the SELECT query, the start_date_str 2019-10-15 turns into pre_start_date 2019-09-09 and finish_date_str 2020-05-18 into pre_finish_date 2019-10-14,.
Why is the pre_start_date in SELECT query 4 months ahead of start_date and pre_finish date not even calculated from finish_date?
jesse import-candles Bitfinex ETHUSD 2016-01-01
Importing 1579 days candles from "Bitfinex" for "ETHUSD". Maximum time it'll take to finish:"26.33 minutes" (duplicates will be skipped). All good? [Y/n]: Y
No candle exists in the market for 2016-01-01 First present candle is since 2016-01-01. Would you like to continue? [Y/n]: Y
============================== EXCEPTION TRACEBACK:
File "/usr/local/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/__init__.py", line 250, in import_candles
import_candles_mode.run(exchange, symbol, start_date)
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/modes/import_candles_mode/__init__.py", line 109, in run
run(exchange, symbol, jh.timestamp_to_time(first_existing_timestamp)[:10], True)
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/modes/import_candles_mode/__init__.py", line 109, in run
run(exchange, symbol, jh.timestamp_to_time(first_existing_timestamp)[:10], True)
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/modes/import_candles_mode/__init__.py", line 109, in run
run(exchange, symbol, jh.timestamp_to_time(first_existing_timestamp)[:10], True)
[Previous line repeated 117 more times]
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/modes/import_candles_mode/__init__.py", line 74, in run
candles = driver.fetch(symbol, temp_start_timestamp)
File "/home/jesse/.local/lib/python3.8/site-packages/jesse/modes/import_candles_mode/drivers/bitfinex.py", line 76, in fetch
'volume': d[5]
=========================================================================
Uncaught Exception: IndexError: string index out of range
im running the example:
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters
from jesse import research
research.init()
import jesse.indicators as ta
eth_candles = research.get_candles('Binance', 'ETHUSDT', '4h', '2019-07-28', '2019-09-28')```
But im getting:
```OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?```
==== ETHUSD | 2020-02-05T12:00 | 197.63 | 197.51 | 198.4 | 195.82 | 18236.37
[2020-02-05T15:00:00+00:00]: balance changed from 12078.14018141486 to -24.872733937947487
[2020-02-05T15:00:00+00:00]: SUBMITTED order: ETHUSD, STOP, buy, 60.87, $198.44
[2020-02-05T15:49:00+00:00]: EXECUTED order: ETHUSD, STOP, buy, 60.87, $198.44
[2020-02-05T15:49:00+00:00]: OPENED long position: Bitfinex, ETHUSD, 60.87, $198.44
[2020-02-05T15:49:00+00:00]: Detected open position
[2020-02-05T15:49:00+00:00]: SUBMITTED order: ETHUSD, LIMIT, sell, -30.43, $229.33
[2020-02-05T15:49:00+00:00]: SUBMITTED order: ETHUSD, STOP, sell, -60.87, $191.33
==== ETHUSD | 2020-02-05T15:00 | 197.517 | 201.22 | 201.47 | 197.06 | 23105.77
==== BTCUSD | 2020-02-05T12:00 | 9418.0 | 9571.43 | 9583.8 | 9418.0 | 3145.39
==== ETHUSD | 2020-02-05T18:00 | 201.295 | 203.37 | 204.64 | 201.258 | 17941.14
==== ETHUSD | 2020-02-05T21:00 | 203.46 | 203.79 | 207.99 | 202.91 | 16343.85
==== BTCUSD | 2020-02-05T18:00 | 9571.4 | 9612.0 | 9731.9 | 9571.4 | 5429.39
==== ETHUSD | 2020-02-06T00:00 | 203.78 | 203.152 | 205.11 | 201.02 | 8212.96
==== ETHUSD | 2020-02-06T03:00 | 203.16 | 207.08 | 207.1 | 203.13 | 11347.61
==== BTCUSD | 2020-02-06T00:00 | 9612.1 | 9651.1 | 9661.2 | 9547.0 | 1236.78
[2020-02-06T06:00:00+00:00]: balance changed from -24.872733937947487 to -24.872733937947487
[2020-02-06T06:00:00+00:00]: SUBMITTED order: BTCUSD, STOP, buy, 0.0, $9695.77
[2020-02-06T07:56:00+00:00]: EXECUTED order: BTCUSD, STOP, buy, 0.0, $9695.77
[2020-02-06T07:56:00+00:00]: OPENED close position: Bitfinex, BTCUSD, 0.0, $9695.77
[2020-02-06T07:56:00+00:00]: Detected open position
Traceback (most recent call last):
File "C:\Users\Markus\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "C:\Users\Markus\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Markus\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "C:/home/src/jesse/jesse/__init__.py", line 293, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "C:\home\src\jesse\jesse\modes\backtest_mode\__init__.py", line 58, in run
simulator(candles)
File "C:\home\src\jesse\jesse\modes\backtest_mode\__init__.py", line 193, in simulator
_simulate_price_change_effect(short_candle, exchange, symbol)
File "C:\home\src\jesse\jesse\modes\backtest_mode\__init__.py", line 298, in _simulate_price_change_effect
order.execute()
File "C:\home\src\jesse\jesse\models\Order.py", line 153, in execute
p._on_executed_order(self)
File "C:\home\src\jesse\jesse\models\Position.py", line 302, in _on_executed_order
self.strategy._on_updated_position(order)
File "C:\home\src\jesse\jesse\strategies\Strategy.py", line 133, in _on_updated_position
self._on_open_position()
File "C:\home\src\jesse\jesse\strategies\Strategy.py", line 683, in _on_open_position
self.broker.reduce_position_at(
File "C:\home\src\jesse\jesse\services\broker.py", line 91, in reduce_position_at
raise OrderNotAllowed(
jesse.exceptions.OrderNotAllowed: Cannot submit a reduce_position order when there is not open position
I think the problem is here:
[2020-02-06T06:00:00+00:00]: SUBMITTED order: BTCUSD, STOP, buy, 0.0, $9695.77 [2020-02-06T07:56:00+00:00]: EXECUTED order: BTCUSD, STOP, buy, 0.0, $9695.77 [2020-02-06T07:56:00+00:00]: OPENED close position: Bitfinex, BTCUSD, 0.0, $9695.77
QTY is 0.0
The backtest has two routes. One for BTCUSD and one for ETHUSD. Both with the same strategy.
If i backtest the strategy alone it works.
When trying to pull candles from Coinbase it looks like it exceeds their rate limits. Candle settings that initially triggered the error were:
routes = [
('Coinbase', 'USDBTC', '15m', 'ExampleStrategy'),
]
extra_candles = [
('Coinbase', 'USDBTC', anchor_timeframe('4h')),
And my timeframe was just to the 1st of April, 2020. It populated about 65% of them and then gave me the rate limit error.
ERROR:
============================== EXCEPTION TRACEBACK:
File "/usr/local/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/jesse/__init__.py", line 250, in import_candles
import_candles_mode.run(exchange, symbol, start_date)
File "/usr/local/lib/python3.8/dist-packages/jesse/modes/import_candles_mode/__init__.py", line 74, in run
candles = driver.fetch(symbol, temp_start_timestamp)
File "/usr/local/lib/python3.8/dist-packages/jesse/modes/import_candles_mode/drivers/coinbase.py", line 52, in fetch
self._handle_errors(response)
File "/usr/local/lib/python3.8/dist-packages/jesse/modes/import_candles_mode/drivers/coinbase.py", line 83, in _handle_errors
raise Exception(response.content)
=========================================================================
Uncaught Exception: Exception: b'{"message":"Slow rate limit exceeded"}'
hey, when i run:
im running into this trouble on jesse version 0.12.2
============================== EXCEPTION TRACEBACK:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Projects\Environments\jesse\Scripts\jesse.exe\__main__.py", line 7, in <module>
sys.exit(cli())
File "c:\projects\environments\jesse\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\projects\environments\jesse\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\projects\environments\jesse\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\projects\environments\jesse\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\projects\environments\jesse\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\projects\environments\jesse\lib\site-packages\jesse\__init__.py", line 352, in optimize
optimize_mode(start_date, finish_date, optimal_total, cpu)
File "c:\projects\environments\jesse\lib\site-packages\jesse\modes\optimize_mode\__init__.py", line 172, in optimize_mode
optimizer.run()
File "c:\projects\environments\jesse\lib\site-packages\jesse\modes\optimize_mode\Genetics.py", line 382, in run
return self.evolve()
File "c:\projects\environments\jesse\lib\site-packages\jesse\modes\optimize_mode\Genetics.py", line 218, in evolve
self.generate_initial_population()
File "c:\projects\environments\jesse\lib\site-packages\jesse\modes\optimize_mode\Genetics.py", line 100, in generate_initial_population
w.start()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
=========================================================================
Uncaught Exception: AttributeError: Can't pickle local object 'Genetics.generate_initial_population.<locals>.get_fitness'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
Any idea(s)?
Hey, I got this error when I try to launch a Backtest.
root@797704255f30:/home/mybot# jesse backtest 2020-01-01 2020-11-10
loading candles...
============================== EXCEPTION TRACEBACK:
File "/usr/local/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/jesse/__init__.py", line 322, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview, csv=csv, json=json)
File "/usr/local/lib/python3.8/dist-packages/jesse/modes/backtest_mode/__init__.py", line 41, in run
candles = load_candles(start_date, finish_date)
File "/usr/local/lib/python3.8/dist-packages/jesse/modes/backtest_mode/__init__.py", line 105, in load_candles
cached_value = cache.get_value(cache_key)
File "/usr/local/lib/python3.8/dist-packages/jesse/services/cache.py", line 69, in get_value
return pickle.load(f)
=========================================================================
Uncaught Exception: UnpicklingError: invalid load key, '\x00'.
Hello,
while backtesting a long-only strategy I notice there might be something wrong in computing the average_entry_price
Here it a sequence of buy order (1st one made in go_long
, the others in update_position
) and how the average_entry_price
gets updated
buying qty: 3.3426391274712346 price: 150.44
average_entry_price: 150.44
buying 3.1774795305245025 150.33
average_entry_price: 150.33
buying 3.024307255417514 150.03
average_entry_price: 150.03
buying 2.8473431610486517 151.37
average_entry_price: 151.37
buying 2.6811195961259826 152.7
average_entry_price: 152.7
buying 2.5541417738143384 152.26
average_entry_price: 152.26
buying 2.4468974718562766 150.97
average_entry_price: 150.97
buying 2.318153649389877 151.37
average_entry_price: 151.37
buying 2.2468293065477463 148.35
average_entry_price: 148.35
buying 2.1494655325637435 147.3
average_entry_price: 147.3
buying 2.0424598613965914 147.25
average_entry_price: 147.25
buying 1.9870837092479907 143.77
average_entry_price: 143.77
It looks like average_entry_price
always takes the last buying price.
Am I doing something wrong or is it a real bug?
Describe the bug
When trying to use an external PostgreSQL database (e.g from Heroku), authentication is failing.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
There should be no failure.
Enviroment (please complete the following information):
Everytime I run a backtest with the --chart option I run into this problem:
File "/Applications/anaconda3/envs/crypto/lib/python3.8/site-packages/jesse/services/charts.py", line 84, in portfolio_vs_asset_returns
price_dict[key]['prices'][price_dict[key]['indexes'][str(int(t.closed_at))]]
=========================================================================
Uncaught Exception: KeyError: '1603929600000'
Using the csv output works fine and so does the json (I even used the graphical tool and it showed it fine)
Hello,
Bitfinex symbols don't have a dash in them as a quote/base separator (see symbol list here: https://api-pub.bitfinex.com/v2/tickers?symbols=ALL)
And that creates a problem, since quote_asset()
is looking for a dash in symbol name and fails if there isn't one.
Just a short question. Will the framework use CPU or GPU for backtesting and optimization?
Describe the bug
There is a problem in the following line: https://github.com/jesse-ai/jesse/blob/master/jesse/indicators/kaufmanstop.py#L30
Long direction is returning negative values as an answer. I believe the correct calculation would be:
res = low - (hl_diff * mult) if direction == "long" else hl_diff * mult + high
instead of
res = hl_diff * mult - low if direction == "long" else hl_diff * mult + high
When I try to install on macOS 10.14.6 with Python 3.7 installed I get an error that TA-Lib cannot be found:
# first, make sure that the PyPi version is not installed
pip uninstall jesse
# now install Jesse from the repository
git clone https://github.com/jesse-ai/jesse.git
cd jesse
pip install -e .
Error output:
Running setup.py clean for TA-Lib
Building wheel for timeloop (setup.py) ... done
Created wheel for timeloop: filename=timeloop-1.0.2-py3-none-any.whl size=3720 sha256=5433fd31956a17cc1d0cc624344279d6b2a56f27e3daf63b132036407ed44180
Stored in directory: /private/tmp/pip-ephem-wheel-cache-opaqwm4j/wheels/3a/7e/fc/5e4d6da12b9ab6550604412936723ec6f2faf7391dd6726a01
Successfully built blinker newtulipy peewee timeloop
Failed to build TA-Lib
Installing collected packages: blinker, pytz, pandas, pandas-datareader, scipy, crypto-empyrical, pyparsing, kiwisolver, cycler, matplotlib, newtulipy, peewee, psycopg2-binary, pydash, iniconfig, packaging, py, zipp, importlib-metadata, pluggy, toml, pytest, TA-Lib, tabulate, timeloop, websocket-client, jesse
Running setup.py install for TA-Lib ... error
ERROR: Command errored out with exit status 1:
command: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-j9q6vmja/TA-Lib/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-j9q6vmja/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-lm5732up/install-record.txt --single-version-externally-managed --compile --install-headers /opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/TA-Lib
cwd: /private/tmp/pip-install-j9q6vmja/TA-Lib/
Complete output (27 lines):
/private/tmp/pip-install-j9q6vmja/TA-Lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
warnings.warn('Cannot find ta-lib library, installation may fail.')
running install
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/abstract.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/test_abstract.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/deprecated.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/stream.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/test_pandas.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/test_data.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/test_func.py -> build/lib.macosx-10.14-x86_64-3.7/talib
copying talib/test_stream.py -> build/lib.macosx-10.14-x86_64-3.7/talib
running build_ext
building 'talib._ta_lib' extension
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/talib
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c talib/_ta_lib.c -o build/temp.macosx-10.14-x86_64-3.7/talib/_ta_lib.o
talib/_ta_lib.c:611:10: fatal error: 'ta-lib/ta_defs.h' file not found
#include "ta-lib/ta_defs.h"
^~~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-j9q6vmja/TA-Lib/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-j9q6vmja/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-lm5732up/install-record.txt --single-version-externally-managed --compile --install-headers /opt/local/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/TA-Lib Check the logs for full command output.
Is your feature request related to a problem? Please describe.
Can't go short on spot type backtests
Describe the solution you'd like
If we have access to the current assets we can use them to filter out orders that we can't afford and avoid InsufficientMargin errors
Describe alternatives you've considered
We could keep track of that manually on the strategy but I think it makes more sense to just pass it down from the SpotExchange model
Additional context
Does this make sense or am I missing something here?
Is your feature request related to a problem? Please describe.
Can't run jesse import-candles ...
outside of a Jesse project
Additional context
Unless I'm missing something, candle importing is not associated with any project and shouldn't require the user to be in a specific folder
Hello,
have you ever considered using Julia instead of Python ?
https://julialang.org/benchmarks/
Kind regards
For command below
jesse import-candles 'Binance' 'BTCUSDT' '2018-01-01'
Exception thrown
============================== EXCEPTION TRACEBACK:
File "/Users/alimzhan/.pyenv/versions/3.7.4/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/jesse/__init__.py", line 250, in import_candles
import_candles_mode.run(exchange, symbol, start_date)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/jesse/modes/import_candles_mode/__init__.py", line 113, in run
candles = _fill_absent_candles(candles, temp_start_timestamp, temp_end_timestamp)
File "/Users/alimzhan/.pyenv/versions/3.7.4/lib/python3.7/site-packages/jesse/modes/import_candles_mode/__init__.py", line 251, in _fill_absent_candles
raise ValueError('No candles were sent')
=========================================================================
Uncaught Exception: ValueError: No candles were sent
Describe the bug
While loading the initial candles, jesse uses biggest timeframe in the routes file as a reference to calculate first available date for that route.
Expected behavior
It should use timeframes from routes file.
Hi,
Could it be possible to have 12 hours timeframe available ?
🥇
jesse import-candles 'Binance' 'BTCUSDT' '2018-06-01'
EXCEPTION TRACEBACK:
File "c:\users\USER\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\USER\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\USER\Anaconda3\Scripts\jesse.exe\__main__.py", line 7, in <module>
sys.exit(cli())
File "c:\users\USER\anaconda3\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\USER\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\USER\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\USER\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\USER\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\USER\anaconda3\lib\site-packages\jesse\__init__.py", line 250, in import_candles
import_candles_mode.run(exchange, symbol, start_date)
File "c:\users\USER\anaconda3\lib\site-packages\jesse\modes\import_candles_mode\__init__.py", line 40, in run
raise ValueError('entered exchange is not supported')
Uncaught Exception: ValueError: entered exchange is not supported
I imported candles as instructed on documentation from 1st January 2020:
jesse import-candles Binance BTCUSDT 2020-01-01
Database now have around ~151000 rows
Tried running a backtest as shown in documentation:
jesse backtest 2020-01-01 2020-04-06
And getting the following error:
`File "c:\programdata\anaconda3\lib\site-packages\jesse_init_.py", line 286, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init_.py", line 40, in run
candles = load_candles(start_date, finish_date)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init.py", line 91, in _load_candles
required_candles.load_required_candles(c[0], c[1], start_date_str, finish_date_str),
File "c:\programdata\anaconda3\lib\site-packages\jesse\services\required_candles.py", line 94, in load_required_candles
exchange, symbol
Uncaught Exception: CandleNotFoundInDatabase: Not enough candle for Binance BTCUSDT is present in the database. Try importing candles.`
Am I missing something?
Also when importing candles at what time frame are they being downloaded at?
Open orders do not close in the liquidation event. Creates the following error:
============================== EXCEPTION TRACEBACK:
File "/jesse_strategy/venv/bin/jesse", line 8, in <module>
sys.exit(cli())
File "/jesse_strategy/venv/lib/python3.9/site-packages/click/core.py", line 1134, in __call__
return self.main(*args, **kwargs)
File "/jesse_strategy/venv/lib/python3.9/site-packages/click/core.py", line 1059, in main
rv = self.invoke(ctx)
File "/jesse_strategy/venv/lib/python3.9/site-packages/click/core.py", line 1665, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/jesse_strategy/venv/lib/python3.9/site-packages/click/core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/jesse_strategy/venv/lib/python3.9/site-packages/click/core.py", line 767, in invoke
return __callback(*args, **kwargs)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/__init__.py", line 302, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview, csv=csv,
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/modes/backtest_mode/__init__.py", line 66, in run
simulator(candles)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/modes/backtest_mode/__init__.py", line 274, in simulator
_simulate_price_change_effect(short_candle, exchange, symbol)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/modes/backtest_mode/__init__.py", line 378, in _simulate_price_change_effect
order.execute()
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/models/Order.py", line 148, in execute
p._on_executed_order(self)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/models/Position.py", line 353, in _on_executed_order
self.strategy._on_updated_position(order)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/strategies/Strategy.py", line 142, in _on_updated_position
self._log_position_update(order, role)
File "/jesse_strategy/venv/lib/python3.9/site-packages/jesse/strategies/Strategy.py", line 1078, in _log_position_update
self.trade.orders.append(order)
=========================================================================
Uncaught Exception: AttributeError: 'NoneType' object has no attribute 'orders'
Hello,
I would like to know if there are examples of jesse being used as a crypto screener rather than a crypto trading bot, sending notifications with relevant informations over a telegram channel for example,
Anton
Uncaught Exception: FileNotFoundError: You are missing the "plugins.py" file
Enviroment (please complete the following information):
After the update, strategies can't be backtested as the Tulipy module can't be found.
I manually installed Tulipy via pip but I am still getting same error.
system info:
macosx 11.0.1
Python 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 17:50:39)
[GCC Clang 10.0.0 ] on darwin
docker info:
Docker version 19.03.13, build 4484c46d9d
error info:
14cb0f48885a: Pull complete
Digest: sha256:8e329b49694c3feb55053d78304b100826d59beedf6447d746fefb32f682baea
Status: Downloaded newer image for salehmir/jesse:python38
docker: Error response from daemon: error while creating mount source path '/Users/saleh/Codes/tests/docker/home': mkdir /Users/saleh: operation not permitted.
jesse import-candles Binance BTCUSDT 2018-06-01
Where or how can i specify the timeframes im interested in?
tried using DOGE/BTC as sample
Returns "Uncaught Exception: KeyError: 'EBTC' "
bot will store 2 symbols DOG,EBTC and will exit with error OR if u add new asset named EBTC it will run Sim with no transactions
i think the issue from here
jesse / helper.py
def base_asset(symbol: str):
if symbol.endswith('USDT'):
return symbol[0:len(symbol) - 4]
if symbol.endswith('USD'):
return symbol[0:len(symbol) - 3]
return symbol[0:3]
I tried the --chart parameter and got this as an exception whilst --tradingview is working fine.
` File "c:\programdata\anaconda3\lib\site-packages\jesse_init_.py", line 286, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview)
File "c:\programdata\anaconda3\lib\site-packages\jesse\modes\backtest_mode_init_.py", line 71, in run
charts.portfolio_vs_asset_returns()
File "c:\programdata\anaconda3\lib\site-packages\jesse\services\charts.py", line 111, in portfolio_vs_asset_returns
plt.savefig(file_path)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\pyplot.py", line 722, in savefig
res = fig.savefig(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\figure.py", line 2180, in savefig
self.canvas.print_figure(fname, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 2089, in print_figure
**kwargs)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 530, in print_png
cbook.open_file_cm(filename_or_obj, "wb") as fh:
File "c:\programdata\anaconda3\lib\contextlib.py", line 112, in enter
return next(self.gen)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\cbook_init_.py", line 447, in open_file_cm
fh, opened = to_filehandle(path_or_file, mode, True, encoding)
File "c:\programdata\anaconda3\lib\site-packages\matplotlib\cbook_init_.py", line 432, in to_filehandle
fh = open(fname, flag, encoding=encoding)
Uncaught Exception: OSError: [Errno 22] Invalid argument: 'storage/charts/BT-2020-04-18T16:56:53.png'`
Also, what value is the qty exactly, in the case of BTCUSDT, does 1 qty mean opening a trade for 1 BTC or 1$?
I apologize for the number of opened issues but I'm migrating my algorithm to this framework and finding issues / questions as I go along but other than that quite impressed by how it all works :)
Thanks.
I am using Linux. Used the script to install everything from a fresh installation. Configured and ran the psql service and db. No luck running Jesse. Stuck on import-candles. Following is the error:
jesse import-candles Bitfinex BTCUSD 2019-01-01
Traceback (most recent call last):
File "/usr/local/bin/jesse", line 5, in
from jesse.init import cli
File "/usr/local/lib/python3.8/dist-packages/jesse/init.py", line 60, in
inject_local_routes()
File "/usr/local/lib/python3.8/dist-packages/jesse/init.py", line 53, in inject_local_routes
router.set_routes(local_router.routes)
AttributeError: module 'routes' has no attribute 'routes'
Describe the bug
I get this error if I set a stop_loss when buying in a spot type backtest:
============================== EXCEPTION TRACEBACK:
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/bin/jesse", line 33, in <module>
sys.exit(load_entry_point('jesse', 'console_scripts', 'jesse')())
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/diogo/.local/share/virtualenvs/jesse-23XDl2ti/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/diogo/personal/projects/jesse/jesse/jesse/__init__.py", line 302, in backtest
backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview, csv=csv,
File "/home/diogo/personal/projects/jesse/jesse/jesse/modes/backtest_mode/__init__.py", line 63, in run
simulator(candles)
File "/home/diogo/personal/projects/jesse/jesse/jesse/modes/backtest_mode/__init__.py", line 279, in simulator
store.orders.execute_pending_market_orders()
File "/home/diogo/personal/projects/jesse/jesse/jesse/store/state_orders.py", line 68, in execute_pending_market_orders
o.execute()
File "/home/diogo/personal/projects/jesse/jesse/jesse/models/Order.py", line 148, in execute
p._on_executed_order(self)
File "/home/diogo/personal/projects/jesse/jesse/jesse/models/Position.py", line 304, in _on_executed_order
self.strategy._on_updated_position(order)
File "/home/diogo/personal/projects/jesse/jesse/jesse/strategies/Strategy.py", line 131, in _on_updated_position
self._on_open_position(order)
File "/home/diogo/personal/projects/jesse/jesse/jesse/strategies/Strategy.py", line 681, in _on_open_position
self.broker.stop_loss_at(
File "/home/diogo/personal/projects/jesse/jesse/jesse/services/broker.py", line 180, in stop_loss_at
return self.api.stop_order(
File "/home/diogo/personal/projects/jesse/jesse/jesse/services/api.py", line 47, in stop_order
return self.drivers[exchange].stop_order(symbol, qty, price, side, role, flags)
File "/home/diogo/personal/projects/jesse/jesse/jesse/exchanges/sandbox/Sandbox.py", line 84, in stop_order
order = Order({
File "/home/diogo/personal/projects/jesse/jesse/jesse/models/Order.py", line 61, in __init__
e.on_order_submission(self)
File "/home/diogo/personal/projects/jesse/jesse/jesse/models/SpotExchange.py", line 72, in on_order_submission
raise NegativeBalance(
=========================================================================
Uncaught Exception: NegativeBalance: Balance cannot go below zero in spot market. Available capital at Binance for BTC is 0 but you're trying to sell 0.5293795036961276
To Reproduce
Use this strategy after generating a new project and setting the backtest type to spot
:
from jesse.strategies import Strategy
class ExampleStrategy(Strategy):
def should_long(self) -> bool:
return self.index == 0
def should_short(self) -> bool:
return False
def should_cancel(self) -> bool:
return False
def go_long(self):
qty = 0.5 * self.balance / self.price
self.buy = qty, self.price
self.stop_loss = qty, 0.995 * self.price
def go_short(self):
pass
Enviroment (please complete the following information):
Is your feature request related to a problem? Please describe.
When running optimize mode, the program will propagate DNA that results in "None" for the various optimization metrics.
Describe the solution you'd like
DNA resulting in "None" results should be eliminated from the population.
Describe alternatives you've considered
You could leave them in there, as some parameters may be useful, but it's perhaps one or two that's causing a problem, but their fitness score should be significantly decreased so they don't make up a large percentage of the population.
after using jesse docker stack steps , after 'jesse import-candles Binance BTCUSDT 2019-11-17' it throws:
Uncaught Exception: ValueError: start_date must be a string representing a date before today. ex: 2020-01-17
even I tried 'jesse import-candles Binance BTCUSDT 2019-11-17'
If I try to import candles with the command jesse import-candles Binance BTCUSDT 2018-02-01
it starts to download but after some time the following exception is thrown Uncaught Exception: CandleNotFoundInExchange: No candles exists in the market for this day: 2018-02-08 Try another start_date
Hello,
I am trying to implement a strategy that keeps updating the position but never closes it.
Here is a snippet of my strategy update_position
def update_position(self):
[...]
qty = size / self.price
tp_price = self.price * (1 + self.hp["take_profit_factor"])
tp_qty = size / tp_price
self.buy = qty, self.price
self.take_profit = tp_qty, tp_price
basically I leave the profit in the in the coin I am trading.
However when backtesting I get this sequence of logs
[2020-05-26T00:00:00+00:00]: SUBMITTED order: XBTEUR, MARKET, buy, 0.12247324903628957, $8163.3
[2020-05-26T00:00:00+00:00]: balance changed from 9997.858738579427 to 9012.229304579654
[2020-05-26T00:00:00+00:00]: SUBMITTED order: XBTEUR, LIMIT, sell, -0.12031952945897394, $8326.57
[2020-05-26T00:00:00+00:00]: EXECUTED order: XBTEUR, MARKET, buy, 0.12247324903628957, $8163.3
[2020-05-26T00:00:00+00:00]: balance changed from 9012.229304579654 to 8010.34388038661
[2020-05-26T00:00:00+00:00]: INCREASED position: Kraken, XBTEUR, long, 0.12466917871770918, $8160.57
[2020-05-26T00:00:00+00:00]: Position size increased.
so although I submit one market order and one limit order, my balance gets decreased twice.
I debugged a bit the problem starting from printing the stack trace of the Exchange::decrease_balance()
Here are the two stacks of the double calls
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 861, in _execute
self._check()
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 641, in _check
self._update_position()
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 427, in _update_position
self._detect_and_handle_entry_and_exit_modifications()
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 542, in _detect_and_handle_entry_and_exit_modifications
order_roles.CLOSE_POSITION
File "/home/giulio/src/jesse/jesse/services/broker.py", line 172, in reduce_position_at
[order_flags.REDUCE_ONLY]
File "/home/giulio/src/jesse/jesse/services/api.py", line 58, in limit_order
return self.drivers[exchange].limit_order(symbol, qty, price, side, role, flags)
File "/home/giulio/src/jesse/jesse/exchanges/sandbox/Sandbox.py", line 65, in limit_order
'role': role
File "/home/giulio/src/jesse/jesse/models/Order.py", line 42, in __init__
p._on_opened_order(self)
File "/home/giulio/src/jesse/jesse/models/Position.py", line 243, in _on_opened_order
self.exchange.decrease_balance(self, size)
File "/home/giulio/src/jesse/jesse/models/Exchange.py", line 49, in decrease_balance
and the second one
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 861, in _execute
self._check()
File "/home/giulio/src/jesse/jesse/strategies/Strategy.py", line 644, in _check
store.orders.execute_pending_market_orders()
File "/home/giulio/src/jesse/jesse/store/state_orders.py", line 101, in execute_pending_market_orders
o.execute()
File "/home/giulio/src/jesse/jesse/models/Order.py", line 156, in execute
p._on_executed_order(self)
File "/home/giulio/src/jesse/jesse/models/Position.py", line 292, in _on_executed_order
self._increase(qty, price)
File "/home/giulio/src/jesse/jesse/models/Position.py", line 175, in _increase
self.exchange.decrease_balance(self, size)
File "/home/giulio/src/jesse/jesse/models/Exchange.py", line 49, in decrease_balance
I couldn't go further...
Describe the bug
The ubuntu 18.04 script fails when used on a raspberry Pi 4 in the following ways:-
1.) Ta-lib fails to compile as architecture aarch64 is not detected by build scripts - Solved see below.
2.) Install script fails as llvmlite cannot be built
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect that the scripts should build on any ubuntu supported platform
Screenshots
If applicable, add screenshots to help explain your problem.
Enviroment (please complete the following information):
Additional context
Fix for the ta-lib script. Ta-lib script fails because config.guess included in ta-lib download is very old, solution is to replace it with a current one.
cd ta-lib
rm config.guess
rm config.sub
wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
Output from failed llvmlite build
Requirement already satisfied: multitasking>=0.0.7 in ./.local/lib/python3.8/site-packages (from yfinance>=0.1.55->quantstats==0.0.30->-r https://raw.githubusercontent.com/jesse-ai/jesse/master/requirements.txt (line 21)) (0.0.9)
Requirement already satisfied: lxml>=4.5.1 in ./.local/lib/python3.8/site-packages (from yfinance>=0.1.55->quantstats==0.0.30->-r https://raw.githubusercontent.com/jesse-ai/jesse/master/requirements.txt (line 21)) (4.6.3)
Building wheels for collected packages: llvmlite
Building wheel for llvmlite (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"'; __file__='"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-y0nib2em
cwd: /tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/
Complete output (11 lines):
running bdist_wheel
/usr/bin/python /tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py
LLVM version... Traceback (most recent call last):
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 220, in <module>
main()
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 210, in main
main_posix('linux', '.so')
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 134, in main_posix
raise RuntimeError(msg) from None
RuntimeError: Could not find a `llvm-config` binary. There are a number of reasons this could occur, please see: https://llvmlite.readthedocs.io/en/latest/admin-guide/install.html#using-pip for help.
error: command '/usr/bin/python' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for llvmlite
Running setup.py clean for llvmlite
Failed to build llvmlite
Installing collected packages: llvmlite, quantstats, numpy-groupies, numba, click
Running setup.py install for llvmlite ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"'; __file__='"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-336lc0w_/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ubuntu/.local/include/python3.8/llvmlite
cwd: /tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/
Complete output (14 lines):
running install
running build
got version from file /tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/llvmlite/_version.py {'version': '0.36.0', 'full': 'e6bb8d137d922bec8beeb01a237254778759becd'}
running build_ext
/usr/bin/python /tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py
LLVM version... Traceback (most recent call last):
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 220, in <module>
main()
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 210, in main
main_posix('linux', '.so')
File "/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/ffi/build.py", line 134, in main_posix
raise RuntimeError(msg) from None
RuntimeError: Could not find a `llvm-config` binary. There are a number of reasons this could occur, please see: https://llvmlite.readthedocs.io/en/latest/admin-guide/install.html#using-pip for help.
error: command '/usr/bin/python' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"'; __file__='"'"'/tmp/pip-install-74oqeiap/llvmlite_f836d5e5fbd4419e91ff5f8f7409e469/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-336lc0w_/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ubuntu/.local/include/python3.8/llvmlite Check the logs for full command output.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: jesse in ./.local/lib/python3.8/site-packages (0.20.9)
Requirement already satisfied: arrow in ./.local/lib/python3.8/site-packages (from jesse
Option1: Use docker - most likely not possible as docker images will be x86/X64 so wont run on arm architecture
Option2: Modify script to use conda but python packages are not available.
Option3: Fix llvmlite issue.
Option3 seems the only viable one.
Any help appreciated.
The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.
Hello.
Is is possible to add possibility to update leverage before every new trade with helper functions or with self.leverage.
For example on another tick (candle) my strategy allows to open LONG position with open price = 500, stop price = 450, balance 1000, risk 1% from balance and leverage for that trade will be = 5. In that case total position notional will be 100, size (quantity) = 0.2 and my margin for that order = 20 (because of leverage = 5). And now until position is opened I will not change leverage, only add more margin. But when position will be closed and after some time strategy decide to make new trade, before opening new position I should be able to change leverage for example to 7 (previous was = 5) and etc.
Is it possible?
Thank you.
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.