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

add MinimumOrderCostNotReachedError and minor fixes #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

techfreaque
Copy link
Contributor

@techfreaque techfreaque commented Jan 15, 2023

properly handle MissingMinimalExchangeTradeVolume

import octobot_trading.exchanges as exchanges
import octobot_trading.exchanges.exchange_builder as exchange_builder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import philosophy is to import high level module (exchanges, personal_data) when not importing from within the module. The idea here is to prevent changing all imports when we update internal module architecture

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay, I removed those changes

@@ -21,6 +21,12 @@ class MissingFunds(Exception):
"""


class MinimumOrderCostNotReachedError(Exception):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why we need both MinimumOrderCostNotReachedError and MissingMinimalExchangeTradeVolume. MissingMinimalExchangeTradeVolume is not doing the same thing ? Should we raise it where you are raising MinimumOrderCostNotReachedError or you need another exception ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it so its using MissingMinimalExchangeTradeVolume, didnt notice that one

@@ -497,13 +497,13 @@ def get_fees(self, symbol):
return {
enums.ExchangeConstantsMarketPropertyColumns.TAKER.value:
market_status.get(enums.ExchangeConstantsMarketPropertyColumns.TAKER.value,
constants.CONFIG_DEFAULT_FEES),
) or constants.CONFIG_DEFAULT_FEES,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When market_status[ExchangeConstantsMarketPropertyColumns.TAKER.value], market_status[ExchangeConstantsMarketPropertyColumns.MAKER.value] or market_status[ExchangeConstantsMarketPropertyColumns.FEE.value] is None, it will now properly use the fallback fees. Before my changes it would set them to None

@@ -188,7 +188,11 @@ def decimal_check_and_adapt_order_details_if_necessary(quantity, price, symbol_m

# check total_order_price not < min_cost
if not personal_data.check_cost(float(total_order_price), min_cost):
return []
symbol = f"{symbol_market['symbol']} - " if 'symbol' in symbol_market else ""
raise errors.MinimumOrderCostNotReachedError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it should be catch if necessary everywhere this method is called

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added exceptions, also in the PR in octobot tentacles -> [Order] handle MinimumOrderCostNotReachedError

@@ -714,7 +714,7 @@ def parse_order_type(raw_order):
parsed_order_type = _get_sell_and_buy_types(order_type)
return side, parsed_order_type
except (KeyError, ValueError):
return None, None
return side, enums.TraderOrderType.UNKNOWN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was an accident, I removed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants