Document exception hierarchy
This commit is contained in:
parent
6dfa159a91
commit
faa2bbb555
@ -85,6 +85,35 @@ docker-compose exec freqtrade_develop /bin/bash
|
|||||||
|
|
||||||
![image](https://user-images.githubusercontent.com/419355/65456522-ba671a80-de06-11e9-9598-df9ca0d8dcac.png)
|
![image](https://user-images.githubusercontent.com/419355/65456522-ba671a80-de06-11e9-9598-df9ca0d8dcac.png)
|
||||||
|
|
||||||
|
## ErrorHandling
|
||||||
|
|
||||||
|
Freqtrade Exceptions all inherit from `FreqtradeException`.
|
||||||
|
This general class of error should however not be used directly, instead, multiple specialized sub-Exceptions exist.
|
||||||
|
|
||||||
|
Below is an outline of exception inheritance hierarchy:
|
||||||
|
|
||||||
|
```
|
||||||
|
+ FreqtradeException
|
||||||
|
|
|
||||||
|
+---+ OperationalException
|
||||||
|
|
|
||||||
|
+---+ DependencyException
|
||||||
|
| |
|
||||||
|
| +---+ PricingError
|
||||||
|
| |
|
||||||
|
| +---+ ExchangeError
|
||||||
|
| |
|
||||||
|
| +---+ TemporaryError
|
||||||
|
| |
|
||||||
|
| +---+ DDosProtection
|
||||||
|
| |
|
||||||
|
| +---+ InvalidOrderException
|
||||||
|
| |
|
||||||
|
| +---+ RetryableOrderError
|
||||||
|
|
|
||||||
|
+---+ StrategyError
|
||||||
|
```
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
### Dynamic Pairlist
|
### Dynamic Pairlist
|
||||||
|
@ -29,7 +29,14 @@ class PricingError(DependencyException):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class InvalidOrderException(FreqtradeException):
|
class ExchangeError(DependencyException):
|
||||||
|
"""
|
||||||
|
Error raised out of the exchange.
|
||||||
|
Has multiple Errors to determine the appropriate error.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidOrderException(ExchangeError):
|
||||||
"""
|
"""
|
||||||
This is returned when the order is not valid. Example:
|
This is returned when the order is not valid. Example:
|
||||||
If stoploss on exchange order is hit, then trying to cancel the order
|
If stoploss on exchange order is hit, then trying to cancel the order
|
||||||
@ -44,13 +51,6 @@ class RetryableOrderError(InvalidOrderException):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ExchangeError(DependencyException):
|
|
||||||
"""
|
|
||||||
Error raised out of the exchange.
|
|
||||||
Has multiple Errors to determine the appropriate error.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class TemporaryError(ExchangeError):
|
class TemporaryError(ExchangeError):
|
||||||
"""
|
"""
|
||||||
Temporary network or exchange related error.
|
Temporary network or exchange related error.
|
||||||
|
@ -919,7 +919,7 @@ class FreqtradeBot:
|
|||||||
if not trade.open_order_id:
|
if not trade.open_order_id:
|
||||||
continue
|
continue
|
||||||
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
||||||
except (ExchangeError, InvalidOrderException):
|
except (ExchangeError):
|
||||||
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
|
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -952,7 +952,7 @@ class FreqtradeBot:
|
|||||||
for trade in Trade.get_open_order_trades():
|
for trade in Trade.get_open_order_trades():
|
||||||
try:
|
try:
|
||||||
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
||||||
except (DependencyException, InvalidOrderException):
|
except (ExchangeError):
|
||||||
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
|
logger.info('Cannot query order for %s due to %s', trade, traceback.format_exc())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union
|
|||||||
import arrow
|
import arrow
|
||||||
from numpy import NAN, mean
|
from numpy import NAN, mean
|
||||||
|
|
||||||
from freqtrade.exceptions import (ExchangeError, InvalidOrderException,
|
from freqtrade.exceptions import (ExchangeError,
|
||||||
PricingError)
|
PricingError)
|
||||||
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs
|
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs
|
||||||
from freqtrade.misc import shorten_date
|
from freqtrade.misc import shorten_date
|
||||||
@ -555,7 +555,7 @@ class RPC:
|
|||||||
try:
|
try:
|
||||||
self._freqtrade.exchange.cancel_order(trade.open_order_id, trade.pair)
|
self._freqtrade.exchange.cancel_order(trade.open_order_id, trade.pair)
|
||||||
c_count += 1
|
c_count += 1
|
||||||
except (ExchangeError, InvalidOrderException):
|
except (ExchangeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# cancel stoploss on exchange ...
|
# cancel stoploss on exchange ...
|
||||||
@ -565,7 +565,7 @@ class RPC:
|
|||||||
self._freqtrade.exchange.cancel_stoploss_order(trade.stoploss_order_id,
|
self._freqtrade.exchange.cancel_stoploss_order(trade.stoploss_order_id,
|
||||||
trade.pair)
|
trade.pair)
|
||||||
c_count += 1
|
c_count += 1
|
||||||
except (ExchangeError, InvalidOrderException):
|
except (ExchangeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
Trade.session.delete(trade)
|
Trade.session.delete(trade)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# pragma pylint: disable=missing-docstring, C0103
|
# pragma pylint: disable=missing-docstring, C0103
|
||||||
# pragma pylint: disable=protected-access, too-many-lines, invalid-name, too-many-arguments
|
# pragma pylint: disable=protected-access, too-many-lines, invalid-name, too-many-arguments
|
||||||
|
|
||||||
|
from freqtrade.exchange.exchange import Exchange
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
@ -4107,7 +4108,7 @@ def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order,
|
|||||||
def test_cancel_all_open_orders(mocker, default_conf, fee, limit_buy_order, limit_sell_order):
|
def test_cancel_all_open_orders(mocker, default_conf, fee, limit_buy_order, limit_sell_order):
|
||||||
default_conf['cancel_open_orders_on_exit'] = True
|
default_conf['cancel_open_orders_on_exit'] = True
|
||||||
mocker.patch('freqtrade.exchange.Exchange.fetch_order',
|
mocker.patch('freqtrade.exchange.Exchange.fetch_order',
|
||||||
side_effect=[DependencyException(), limit_sell_order, limit_buy_order])
|
side_effect=[ExchangeError(), limit_sell_order, limit_buy_order])
|
||||||
buy_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_cancel_buy')
|
buy_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_cancel_buy')
|
||||||
sell_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_cancel_sell')
|
sell_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_cancel_sell')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user