Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fee = config['env']['exchanges'][self.exchange]['fee']. KeyError: None #390

Closed
shhhmel opened this issue Jan 12, 2023 · 2 comments
Closed
Labels
bug Something isn't working stale No recent activity.

Comments

@shhhmel
Copy link

shhhmel commented Jan 12, 2023

Describe the bug
[Live Mode] After Submitting an order Jeese tries to Submit Stop Loss and get this Error.

[INFO | 2023-01-12T00:00:00] SUBMITTED order: ETH-USDT, MARKET, buy, 1.76, $1388.8
[INFO | 2023-01-12T00:00:04] EXECUTED order: ETH-USDT, MARKET, buy, 1.76, $1388.6
[INFO | 2023-01-12T00:00:04] Traceback (most recent call last):
  File "jesse_live/exchanges/LiveExchange.py", line 421, in jesse_live.exchanges.LiveExchange.LiveExchange._connect_ws._on_message
  File "jesse_live/exchanges/Bybit/BybitUSDTPerpetualMain.py", line 464, in jesse_live.exchanges.Bybit.BybitUSDTPerpetualMain.BybitUSDTPerpetualMain.on_ws_message
  File "jesse_live/exchanges/Bybit/BybitUSDTPerpetualMain.py", line 551, in jesse_live.exchanges.Bybit.BybitUSDTPerpetualMain.BybitUSDTPerpetualMain.prepare_order_stream
  File "jesse_live/exchanges/LiveExchange.py", line 929, in jesse_live.exchanges.LiveExchange.LiveExchange.handle_order_stream
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Order.py", line 252, in execute
    p._on_executed_order(self)
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Position.py", line 393, in _on_executed_order
    self._close()
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Position.py", line 301, in _close
    store.completed_trades.close_trade(self)
  File "/usr/local/lib/python3.8/dist-packages/jesse/store/state_completed_trades.py", line 91, in close_trade
    f"CLOSED a {t.type} trade for {t.exchange}-{t.symbol}: qty: {t.qty}, entry_price: {round(t.entry_price, 2)}, exit_price: {round(t.exit_price, 2)}, PNL: {round(t.pnl, 2)} ({round(t.pnl_percentage, 2)}%)"
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/ClosedTrade.py", line 100, in pnl
    fee = config['env']['exchanges'][self.exchange]['fee']
KeyError: None

[ERROR | 2023-01-12T00:00:04] Traceback (most recent call last):
  File "jesse_live/exchanges/LiveExchange.py", line 421, in jesse_live.exchanges.LiveExchange.LiveExchange._connect_ws._on_message
  File "jesse_live/exchanges/Bybit/BybitUSDTPerpetualMain.py", line 464, in jesse_live.exchanges.Bybit.BybitUSDTPerpetualMain.BybitUSDTPerpetualMain.on_ws_message
  File "jesse_live/exchanges/Bybit/BybitUSDTPerpetualMain.py", line 551, in jesse_live.exchanges.Bybit.BybitUSDTPerpetualMain.BybitUSDTPerpetualMain.prepare_order_stream
  File "jesse_live/exchanges/LiveExchange.py", line 929, in jesse_live.exchanges.LiveExchange.LiveExchange.handle_order_stream
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Order.py", line 252, in execute
    p._on_executed_order(self)
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Position.py", line 393, in _on_executed_order
    self._close()
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/Position.py", line 301, in _close
    store.completed_trades.close_trade(self)
  File "/usr/local/lib/python3.8/dist-packages/jesse/store/state_completed_trades.py", line 91, in close_trade
    f"CLOSED a {t.type} trade for {t.exchange}-{t.symbol}: qty: {t.qty}, entry_price: {round(t.entry_price, 2)}, exit_price: {round(t.exit_price, 2)}, PNL: {round(t.pnl, 2)} ({round(t.pnl_percentage, 2)}%)"
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/ClosedTrade.py", line 100, in pnl
    fee = config['env']['exchanges'][self.exchange]['fee']
KeyError: None

[INFO | 2023-01-12T00:00:04] AttributeError: 'NoneType' object has no attribute '__name__'
[ERROR | 2023-01-12T00:00:04] AttributeError: 'NoneType' object has no attribute '__name__'
[INFO | 2023-01-12T00:00:04] Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/dist-packages/timeloop/job.py", line 19, in run
    self.execute(*self.args, **self.kwargs)
  File "jesse_live/live_mode.py", line 130, in jesse_live.live_mode.run.update_dashboard
  File "jesse_live/services/dashboard.py", line 12, in jesse_live.services.dashboard.realtime
  File "/usr/local/lib/python3.8/dist-packages/jesse/services/report.py", line 101, in livetrade
    df = pd.DataFrame.from_records([t.to_dict for t in store.completed_trades.trades])
  File "/usr/local/lib/python3.8/dist-packages/jesse/services/report.py", line 101, in <listcomp>
    df = pd.DataFrame.from_records([t.to_dict for t in store.completed_trades.trades])
  File "/usr/local/lib/python3.8/dist-packages/jesse/models/ClosedTrade.py", line 73, in to_dict
    'strategy_name': jh.get_class_name(self.strategy_name),
  File "/usr/local/lib/python3.8/dist-packages/jesse/helpers.py", line 992, in get_class_name
    return cls.__name__
AttributeError: 'NoneType' object has no attribute '__name__'

[INFO | 2023-01-12T00:00:04] Session terminated as the result of an uncaught exception
[ERROR | 2023-01-12T00:00:04] Session terminated as the result of an uncaught exception

To Reproduce
Steps to reproduce the behavior:
2 routes: Bybit USDT Perpetual-ETH-USDT-2h, Bybit USDT Perpetual-ETH-USDT-6h (Extra)
Local candle generation mode is DISABLED

Just wait for Order trigger.

Go Long code:

    def go_long(self):
        entry = self.price
        stop = entry - self.stop_loss_diff
        qty = utils.risk_to_qty(self.balance, 8, entry, stop, 8, self.fee_rate)
        self.buy = qty, entry
        self.stop_loss = qty, stop

Expected behavior
Stop Loss order should be done

Screenshots
If applicable, add screenshots to help explain your problem.

Enviroment (please complete the following information):

  • OS: Ubuntu 20
  • Version: jesse v0.41.5 and jesse_live v0.41.4

Additional context
Add any other context about the problem here.

@shhhmel shhhmel added the bug Something isn't working label Jan 12, 2023
@shhhmel
Copy link
Author

shhhmel commented Jan 12, 2023

Application settings:
Screenshot 2023-01-12 at 08 40 00

@stale
Copy link

stale bot commented Sep 16, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent activity. label Sep 16, 2023
@stale stale bot closed this as completed Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale No recent activity.
Projects
None yet
Development

No branches or pull requests

1 participant