Skip to content

Commit

Permalink
Merge pull request #2680 from Drakkar-Software/dev
Browse files Browse the repository at this point in the history
Dev merge
  • Loading branch information
GuillaumeDSM authored Jul 17, 2024
2 parents c601c26 + e01e05c commit 78d15bf
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

*It is strongly advised to perform an update of your tentacles after updating OctoBot. (start.py tentacles --install --all)*

## [2.0.2] - 2024-07-17
### Updated
- [WebInterface] Improve light & dark themes display
### Fixed
- [WebInterface] Fix extension checkout
- [RAM] Reduce required RAM when loading a large amount of trades
- [BingX] Fix order sizing issues

## [2.0.1] - 2024-07-09
### Updated
- [WebInterface] Add contact on extension page
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OctoBot [2.0.1](https://github.com/Drakkar-Software/OctoBot/blob/master/CHANGELOG.md)
# OctoBot [2.0.2](https://github.com/Drakkar-Software/OctoBot/blob/master/CHANGELOG.md)
[![PyPI](https://img.shields.io/pypi/v/OctoBot.svg?logo=pypi)](https://pypi.org/project/OctoBot)
[![Downloads](https://pepy.tech/badge/octobot/month)](https://pepy.tech/project/octobot)
[![Dockerhub](https://img.shields.io/docker/pulls/drakkarsoftware/octobot.svg?logo=docker)](https://hub.docker.com/r/drakkarsoftware/octobot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ async def inner_test_create_and_cancel_limit_orders(self, symbol=None, settlemen
size = self.get_order_size(
await self.get_portfolio(), price, symbol=symbol, settlement_currency=settlement_currency
)
self.check_order_size_and_price(size, price)
# # DEBUG tools, uncomment to create specific orders
# symbol = "BTC/USD:BTC"
# market_status = self.exchange_manager.exchange.get_market_status(symbol)
Expand Down Expand Up @@ -832,6 +833,23 @@ def get_order_size(self, portfolio, price, symbol=None, order_size=None, settlem
order_quantity
)

def check_order_size_and_price(self, size, price, symbol=None):
market_status = self.exchange_manager.exchange.get_market_status(str(symbol or self.SYMBOL))
precision_amount = market_status[
trading_enums.ExchangeConstantsMarketStatusColumns.PRECISION.value
].get(trading_enums.ExchangeConstantsMarketStatusColumns.PRECISION_AMOUNT.value, 0)
assert 0 <= precision_amount < 10 # is really the number of digits
assert int(precision_amount) == precision_amount # is an int
precision_price = market_status[
trading_enums.ExchangeConstantsMarketStatusColumns.PRECISION.value
].get(trading_enums.ExchangeConstantsMarketStatusColumns.PRECISION_PRICE.value, 0)
assert 0 < precision_price < 10 # is really the number of digits
assert int(precision_price) == precision_price # is an int

assert personal_data_orders.decimal_trunc_with_n_decimal_digits(size, precision_amount) == size
assert personal_data_orders.decimal_trunc_with_n_decimal_digits(price, precision_price) == price


def get_sell_size_from_buy_order(self, buy_order):
sell_size = buy_order.origin_quantity
if buy_order.fee and buy_order.fee[trading_enums.FeePropertyColumns.CURRENCY.value] == self.ORDER_CURRENCY:
Expand Down Expand Up @@ -1016,7 +1034,9 @@ async def order_in_fetched_orders(self, method, previous_orders, order, symbol=N
print(f"=> {self.exchange_manager.exchange_name} {order.order_type} Order found in {len(fetched_orders)} "
f"{method.__name__} after after {time.time() - t0} seconds and {iterations} iterations. "
f"Order: [{order}].")
assert len(fetched_orders) == len(previous_orders) + 1
# use in as exchanges can have a max amount of fetched elements
assert len(fetched_orders) in (len(previous_orders), len(previous_orders) + 1), \
f"{len(fetched_orders)} not in {len(previous_orders), len(previous_orders) + 1}"
return True
else:
# check order not in open orders
Expand All @@ -1039,7 +1059,7 @@ async def order_in_fetched_orders(self, method, previous_orders, order, symbol=N
f" in {len(fetched_orders)} {method.__name__} after after {time.time() - t0} seconds "
f"and {iterations} iterations. "
f"Order: [{order}].")
assert len(fetched_orders) == max(len(previous_orders) - 1, 0)
assert len(fetched_orders) <= len(previous_orders), f"{len(fetched_orders)} !<= {len(previous_orders)}"
# order not found
return True
await asyncio.sleep(1)
Expand Down
2 changes: 1 addition & 1 deletion additional_tests/exchanges_tests/test_bingx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestBingxAuthenticatedExchange(
USE_ORDER_OPERATION_TO_CHECK_API_KEY_RIGHTS = True
EXPECT_MISSING_FEE_IN_CANCELLED_ORDERS = False

VALID_ORDER_ID = "1777764898965454838"
VALID_ORDER_ID = "1812980957928929280"

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand Down
2 changes: 1 addition & 1 deletion octobot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

PROJECT_NAME = "OctoBot"
AUTHOR = "Drakkar-Software"
VERSION = "2.0.1" # major.minor.revision
VERSION = "2.0.2" # major.minor.revision
LONG_VERSION = f"{VERSION}"
9 changes: 9 additions & 0 deletions octobot/community/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ async def update_orders(self, orders: list, exchange_name: str):
"""
formatted_orders = formatters.format_orders(orders, exchange_name)
await self.supabase_client.update_bot_orders(self.user_account.bot_id, formatted_orders)
self.logger.info(f"Bot orders updated: using {len(orders)} orders")

@_bot_data_update
async def update_portfolio(self, current_value: dict, initial_value: dict, profitability: float,
Expand All @@ -729,16 +730,24 @@ async def update_portfolio(self, current_value: dict, initial_value: dict, profi
current_value, initial_value, profitability, unit, content, price_by_asset, self.user_account.bot_id
)
if reset or self.user_account.get_selected_bot_current_portfolio_id() is None:
self.logger.info(f"Switching bot portfolio")
await self.supabase_client.switch_portfolio(formatted_portfolio)
await self.refresh_selected_bot()

formatted_portfolio[backend_enums.PortfolioKeys.ID.value] = \
self.user_account.get_selected_bot_current_portfolio_id()
await self.supabase_client.update_portfolio(formatted_portfolio)
self.logger.info(
f"Bot portfolio [{formatted_portfolio[backend_enums.PortfolioKeys.ID.value]}] "
f"updated with content: {formatted_portfolio[backend_enums.PortfolioKeys.CONTENT.value]}"
)
if formatted_histories := formatters.format_portfolio_history(
history, unit, self.user_account.get_selected_bot_current_portfolio_id()
):
await self.supabase_client.upsert_portfolio_history(formatted_histories)
self.logger.info(
f"Bot portfolio [{formatted_portfolio[backend_enums.PortfolioKeys.ID.value]}] history updated"
)
except KeyError as err:
self.logger.debug(f"Error when updating community portfolio {err} (missing reference market value)")

Expand Down
1 change: 1 addition & 0 deletions octobot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
# system
ENABLE_CLOCK_SYNCH = os_util.parse_boolean_environment_var("ENABLE_CLOCK_SYNCH", "True")
ENABLE_SYSTEM_WATCHER = os_util.parse_boolean_environment_var("ENABLE_SYSTEM_WATCHER", "True")
WATCH_RAM = os_util.parse_boolean_environment_var("WATCH_RAM", "False")
DUMP_USED_RESOURCES = os_util.parse_boolean_environment_var("DUMP_USED_RESOURCES", "False")
USED_RESOURCES_OUTPUT = os.getenv("USED_RESOURCES_OUTPUT", "system_resources.csv")

Expand Down
1 change: 1 addition & 0 deletions octobot/octobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ async def _ensure_watchers(self):
if constants.ENABLE_SYSTEM_WATCHER:
await system_resources_watcher.start_system_resources_watcher(
constants.DUMP_USED_RESOURCES,
constants.WATCH_RAM,
constants.USED_RESOURCES_OUTPUT
)

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Drakkar-Software requirements
OctoBot-Commons==1.9.49
OctoBot-Trading==2.4.91
OctoBot-Commons==1.9.50
OctoBot-Trading==2.4.92
OctoBot-Evaluators==1.9.5
OctoBot-Tentacles-Manager==2.9.15
OctoBot-Services==1.6.15
Expand Down

0 comments on commit 78d15bf

Please sign in to comment.