Coder Social home page Coder Social logo

jesse-ai / jesse Goto Github PK

View Code? Open in Web Editor NEW
5.2K 181.0 680.0 14.92 MB

An advanced crypto trading bot written in Python

Home Page: https://jesse.trade

License: MIT License

Python 99.83% Dockerfile 0.05% Shell 0.05% HTML 0.06%
cryptocurrency trading-bot trading-algorithms trading crypto framework algo-trading algorithmic-trading jesse trading-strategies

jesse's Introduction


Jesse

Algo-trading was 😵‍💫, we made it 🤩

Jesse

PyPI Downloads Docker Pulls GitHub coverage


Jesse is an advanced crypto trading framework that aims to simplify researching and defining YOUR OWN trading strategies.

Why Jesse?

In short, Jesse is more accurate than other solutions, and way more simple. In fact, it is so simple that in case you already know Python, you can get started today, in matter of minutes, instead of weeks and months.

Here you can read more about Jesse's features and why you should use it.

Getting Started

Head over to the "getting started" section of the documentation. The documentation is short yet very informative.

Resources

Screenshots

Check out Jesse's Youtube channel for tutorials that go through example strategies step by step.

Here are a few screenshots just to get you excited:

Backtest results:

image

Example strategy code:

image

Live trading (requires live plugin):

image

What's next?

You can see the project's roadmap here. Subscribe to our mailing list at jesse.trade to get the good stuff as soon they're released. Don't worry, We won't send you spam—Pinky promise.

How to contribute

Thank you for your interest in contributing to the project. The best way to contribute is by participating in the community and helping other users.

You can also contribute by submitting bug reports and feature requests or writing code (submitting PRs) which can be incorporated into Jesse itself.

In that case, here's what you need to know:

  • Before starting to work on a PR, please reach out to make sure it aligns with the project's roadmap and vision.
  • If your PR makes changes to the source code, please make sure to add unit tests. If you're not sure how to do that, just check out some of the already existing tests.

First, you need to install Jesse from the repository instead of PyPi:

# 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 .

Now every change you make to the code will be affected immediately.

After every change, make sure your changes did not break any functionality by running tests:

pytest

Disclaimer

This software is for educational purposes only. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS. Do not risk money that you are afraid to lose. There might be bugs in the code - this software DOES NOT come with ANY warranty.

jesse's People

Contributors

0xvox avatar bamartos avatar btagliani avatar burruplambert avatar cryptocoinserver avatar dependabot[bot] avatar discohead avatar fengkiej avatar gabri avatar guidi-injenia avatar jcsaaddupuy avatar jeremytregunna avatar julesgoullee avatar kakulukia avatar lightyear15 avatar macd2 avatar morteza-koohgard avatar movy avatar ob00218 avatar poe28 avatar pyup-bot avatar qwpto avatar regaltsui avatar saleh-mir avatar saleh-old avatar sbkhosh avatar techdubb avatar vladkochetov007 avatar yakir4123 avatar ysdede avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jesse's Issues

Coinbase Slow rate limit exceeded

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"}'

optimize propages DNA with "None" results

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.

Additional context
cropped_dna

ValueError: entered exchange is not supported

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

FATAL: password authentication failed for user "postgres"

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:

  1. Create a PostgreSQL database by using providers like Heroku etc.
  2. Enter the correct credentials in config.py

Expected behavior
There should be no failure.

Enviroment (please complete the following information):

  • OS: Ubuntu and Docker
  • Version latest

can't seem to use the --chart option

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)

specify pulled candles

jesse import-candles Binance BTCUSDT 2018-06-01

Where or how can i specify the timeframes im interested in?

Optimization mode fails with more than 100 cpu cores

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.

Tulips issue

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.

Import not working

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

average_entry_price in Strategy is wrong

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?

Dynamic Leverage

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.

Optimize wont work on Windows: EOFError: Ran out of input

hey, when i run:

  • jesse optimize '2020-01-01' '2020-09-28' 10

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)?

File Not Found "plugins.py"

Describe the bug

$ jesse import-candles 'Binance' 'BTC-USDT' '2020-01-01'
import_candles_mode.run(exchange, symbol, start_date, skip_confirmation)
File "c:\users\taka9\desktop\jesse-master\jesse\modes\import_candles_mode_init_.py", line 47, in run
raise FileNotFoundError('You are missing the "plugins.py" file')

Uncaught Exception: FileNotFoundError: You are missing the "plugins.py" file

Enviroment (please complete the following information):

  • OS: Windows 10
  • Version: 0.25.0
  • Location: c:\users\taka9\desktop\jesse-master
  • Requires: arrow, blinker, Click, crypto-empyrical, matplotlib, newtulipy, numpy, pandas, peewee, psycopg2-binary, pydash, pytest, requests, scipy, TA-Lib, tabula
    te, timeloop, websocket-client

Uncaught Exception: AttributeError: 'NoneType' object has no attribute 'current_price'

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'),
]

Ubuntu 18.04 script fails on Raspberry PI

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:

  1. Install Ubuntu 18.04 on a raspberry Pi 4 - 4GB
  2. Run the script provided in the documentation

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):

  • Pi4 runinng Ubunu server 18.04 lTS

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.

Allow import-candles outside of a Jesse project

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

Not enough candle for Binance BTCUSDT is present in the database

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?

AttributeError: 'SpotExchange' object has no attribute 'futures_leverage'

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},
            ],
        },

jesse.exceptions.OrderNotAllowed: Cannot submit a reduce_position order when there is not open position

==== 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.

Open multiple positions

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.

collab can not connect to server

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?```

Using Jesse as a screener

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

pre_start_date and pre_finish_date error in the Candle.select() query causes no candles to be returned.

Hi and thanks for this beautiful framework.

I found an error in the requied_candles.py. Could you please verify?

How to test:

  1. Clear candles from the DB and cache
  2. Add route: routes=[("Binance Futures"), "BTCUSDT", "1h", "ExampleStrategy")]
  3. Add route: extra_candles=[("Binance Futures"), "BTCUSDT", anchor_timeframe("1h"))]
  4. jesse import-candles "Binance Futures" BTCUSDT 2019-10-15
  5. jesse backtest 2019-10-15 2020-05-18

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:

Candle.timestamp.between(pre_start_date, pre_finish_date),

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?

buying order in ``update_position`` causes double decrease_balance in backtest

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...

Allow going short on spot type backtests

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?

Open orders do not close in the liquidation event

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'

Uncaught Exception: IndexError: string index out of range - during import of candles

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

Redis Authentication

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

Cannot find ta-lib library, installation may fail. (and does)

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.

Initial Update

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.

docker run 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.

--chart not working

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.

Import candle error with Binance

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

Uncaught Exception: UnpicklingError: invalid load key, '\x00'.

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'.

AttributeError: module 'routes' has no attribute 'routes'

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'

Can't use stop_loss with SpotExchange

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):

  • OS: Arch Linux
  • Version 0.20.9 (master)

Error When using 4 letters Tokens

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]

Dashboard : Equity Curve chart showing invalid dates and time

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:
image

Also other time data on Results page are "invalid", they seems timestamps or intervals in seconds maybe;
image

Anyway, probably you already know about them

Hope it helps

Not enough candles for Binance BTC-USDT exists to run backtest

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

  1. Create a new project
  2. run jesse import-candles 'Binance' 'BTC-USDT' '2020-06-01'
  3. run jesse backtest '2020-07-01' '2021-10-01' to backtest

Then error occurs

Screenshots

Screen Shot 2021-12-03 at 11 20 54 AM

Enviroment (please complete the following information):
MAC OS
Name: jesse
Version: 0.29.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.