diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c730e34d..c6405187c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: git clone -q $OCTOBOT_GH_REPO -b ${TARGET_BRANCH} || git clone -q $OCTOBOT_GH_REPO -b $OCTOBOT_DEFAULT_BRANCH cd OctoBot git status - pip install --prefer-binary -r dev_requirements.txt -r requirements.txt + pip install --prefer-binary -r dev_requirements.txt -r requirements.txt -r full_requirements.txt cd .. mkdir new_tentacles cp -r Automation Backtesting Evaluator Meta Services Trading profiles new_tentacles @@ -70,7 +70,7 @@ jobs: cd OctoBot git status pip install --upgrade pip setuptools wheel - pip install --prefer-binary -r dev_requirements.txt -r requirements.txt + pip install --prefer-binary -r dev_requirements.txt -r requirements.txt -r full_requirements.txt cd .. mkdir new_tentacles xcopy Automation new_tentacles\\Automation /E/H/I @@ -134,7 +134,7 @@ jobs: git clone -q $OCTOBOT_GH_REPO -b ${TARGET_BRANCH} || git clone -q $OCTOBOT_GH_REPO -b $OCTOBOT_DEFAULT_BRANCH cd OctoBot git status - pip install --prefer-binary -r dev_requirements.txt -r requirements.txt + pip install --prefer-binary -r dev_requirements.txt -r requirements.txt -r full_requirements.txt cd .. mkdir new_tentacles cp -r Automation Backtesting Evaluator Meta Services Trading profiles new_tentacles diff --git a/Evaluator/Social/forum_evaluator/forum.py b/Evaluator/Social/forum_evaluator/forum.py index e5bc55a36..3bbf4f5b5 100644 --- a/Evaluator/Social/forum_evaluator/forum.py +++ b/Evaluator/Social/forum_evaluator/forum.py @@ -30,8 +30,7 @@ # RedditForumEvaluator is used to get an overall state of a market, it will not trigger a trade # (notify its evaluators) but is used to measure hype and trend of a market. class RedditForumEvaluator(evaluators.SocialEvaluator): - - SERVICE_FEED_CLASS = Services_feeds.RedditServiceFeed + SERVICE_FEED_CLASS = Services_feeds.RedditServiceFeed if hasattr(Services_feeds, 'RedditServiceFeed') else None def __init__(self, tentacles_setup_config): evaluators.SocialEvaluator.__init__(self, tentacles_setup_config) diff --git a/Evaluator/Social/news_evaluator/news.py b/Evaluator/Social/news_evaluator/news.py index 339178c89..7a22ad384 100644 --- a/Evaluator/Social/news_evaluator/news.py +++ b/Evaluator/Social/news_evaluator/news.py @@ -27,7 +27,7 @@ # disable inheritance to disable tentacle visibility. Disabled as starting from feb 9 2023, API is now paid only # class TwitterNewsEvaluator(evaluators.SocialEvaluator): class TwitterNewsEvaluator: - SERVICE_FEED_CLASS = Services_feeds.TwitterServiceFeed + SERVICE_FEED_CLASS = Services_feeds.TwitterServiceFeed if hasattr(Services_feeds, 'TwitterServiceFeed') else None # max time to live for a pulse is 10min _EVAL_MAX_TIME_TO_LIVE = 10 * commons_constants.MINUTE_TO_SECONDS diff --git a/Evaluator/Social/signal_evaluator/signal.py b/Evaluator/Social/signal_evaluator/signal.py index 10b6ca346..f87091714 100644 --- a/Evaluator/Social/signal_evaluator/signal.py +++ b/Evaluator/Social/signal_evaluator/signal.py @@ -23,7 +23,7 @@ class TelegramSignalEvaluator(evaluators.SocialEvaluator): - SERVICE_FEED_CLASS = Services_feeds.TelegramServiceFeed + SERVICE_FEED_CLASS = Services_feeds.TelegramServiceFeed if hasattr(Services_feeds, 'TelegramServiceFeed') else None def init_user_inputs(self, inputs: dict) -> None: channels_config = self.UI.user_input(services_constants.CONFIG_TELEGRAM_CHANNEL, @@ -106,7 +106,7 @@ def _get_tentacle_registration_topic(self, all_symbols_by_crypto_currencies, tim class TelegramChannelSignalEvaluator(evaluators.SocialEvaluator): - SERVICE_FEED_CLASS = Services_feeds.TelegramApiServiceFeed + SERVICE_FEED_CLASS = Services_feeds.TelegramApiServiceFeed if hasattr(Services_feeds, 'TelegramApiServiceFeed') else None SIGNAL_PATTERN_KEY = "signal_pattern" SIGNAL_PATTERN_MARKET_BUY_KEY = "MARKET_BUY" diff --git a/Evaluator/Social/trends_evaluator/trends.py b/Evaluator/Social/trends_evaluator/trends.py index 88afc23c2..5eb5c8940 100644 --- a/Evaluator/Social/trends_evaluator/trends.py +++ b/Evaluator/Social/trends_evaluator/trends.py @@ -25,7 +25,7 @@ class GoogleTrendsEvaluator(evaluators.SocialEvaluator): - SERVICE_FEED_CLASS = Services_feeds.GoogleServiceFeed + SERVICE_FEED_CLASS = Services_feeds.GoogleServiceFeed if hasattr(Services_feeds, 'GoogleServiceFeed') else None def __init__(self, tentacles_setup_config): evaluators.SocialEvaluator.__init__(self, tentacles_setup_config) diff --git a/Evaluator/Util/text_analysis/text_analysis.py b/Evaluator/Util/text_analysis/text_analysis.py index 623d73c9c..72e2f813c 100644 --- a/Evaluator/Util/text_analysis/text_analysis.py +++ b/Evaluator/Util/text_analysis/text_analysis.py @@ -14,7 +14,17 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. -import vaderSentiment.vaderSentiment as vaderSentiment +import octobot_commons.constants as commons_constants +try: + import vaderSentiment.vaderSentiment as vaderSentiment +except ImportError: + if commons_constants.USE_MINIMAL_LIBS: + # mock vaderSentiment imports + class VaderSentimentImportMock: + class SentimentIntensityAnalyzer: + def __init__(self, *args): + raise ImportError("vaderSentiment not installed") + vaderSentiment = VaderSentimentImportMock() class TextAnalysis: diff --git a/Services/Interfaces/telegram_bot_interface/__init__.py b/Services/Interfaces/telegram_bot_interface/__init__.py index 8ef5a2e99..5d2990bb4 100644 --- a/Services/Interfaces/telegram_bot_interface/__init__.py +++ b/Services/Interfaces/telegram_bot_interface/__init__.py @@ -1 +1,3 @@ -from .telegram_bot import TelegramBotInterface \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram_bot import TelegramBotInterface \ No newline at end of file diff --git a/Services/Interfaces/web_interface/__init__.py b/Services/Interfaces/web_interface/__init__.py index 51810f686..0cfeefb11 100644 --- a/Services/Interfaces/web_interface/__init__.py +++ b/Services/Interfaces/web_interface/__init__.py @@ -44,9 +44,10 @@ def register_notifier(notification_key, notifier): STRATEGY_OPTIMIZER_NOTIFICATION_KEY = "strategy_optimizer_notifications" DASHBOARD_NOTIFICATION_KEY = "dashboard_notifications" - -# Make WebInterface visible to imports -from tentacles.Services.Interfaces.web_interface.web import WebInterface +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + # Make WebInterface visible to imports + from tentacles.Services.Interfaces.web_interface.web import WebInterface # disable server logging diff --git a/Services/Notifiers/telegram_notifier/__init__.py b/Services/Notifiers/telegram_notifier/__init__.py index 54d742a1f..66d969b8d 100644 --- a/Services/Notifiers/telegram_notifier/__init__.py +++ b/Services/Notifiers/telegram_notifier/__init__.py @@ -1 +1,3 @@ -from .telegram import TelegramNotifier \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram import TelegramNotifier \ No newline at end of file diff --git a/Services/Notifiers/twitter_notifier/__init__.py b/Services/Notifiers/twitter_notifier/__init__.py index ca95fcb34..7b241c534 100644 --- a/Services/Notifiers/twitter_notifier/__init__.py +++ b/Services/Notifiers/twitter_notifier/__init__.py @@ -1 +1,3 @@ -from .twitter import TwitterNotifier \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .twitter import TwitterNotifier \ No newline at end of file diff --git a/Services/Notifiers/web_notifier/__init__.py b/Services/Notifiers/web_notifier/__init__.py index 8558eb4f6..61093df47 100644 --- a/Services/Notifiers/web_notifier/__init__.py +++ b/Services/Notifiers/web_notifier/__init__.py @@ -1 +1,3 @@ -from .web import WebNotifier \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .web import WebNotifier \ No newline at end of file diff --git a/Services/Services_bases/google_service/__init__.py b/Services/Services_bases/google_service/__init__.py index 452cfee77..cc455c486 100644 --- a/Services/Services_bases/google_service/__init__.py +++ b/Services/Services_bases/google_service/__init__.py @@ -1 +1,3 @@ -from .google import GoogleService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .google import GoogleService \ No newline at end of file diff --git a/Services/Services_bases/reddit_service/__init__.py b/Services/Services_bases/reddit_service/__init__.py index 8450de311..7b7fae814 100644 --- a/Services/Services_bases/reddit_service/__init__.py +++ b/Services/Services_bases/reddit_service/__init__.py @@ -1 +1,3 @@ -from .reddit import RedditService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .reddit import RedditService diff --git a/Services/Services_bases/telegram_api_service/__init__.py b/Services/Services_bases/telegram_api_service/__init__.py index a803492cf..77e27daab 100644 --- a/Services/Services_bases/telegram_api_service/__init__.py +++ b/Services/Services_bases/telegram_api_service/__init__.py @@ -1 +1,3 @@ -from .telegram_api import TelegramApiService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram_api import TelegramApiService \ No newline at end of file diff --git a/Services/Services_bases/telegram_service/__init__.py b/Services/Services_bases/telegram_service/__init__.py index 66462968b..551c747e5 100644 --- a/Services/Services_bases/telegram_service/__init__.py +++ b/Services/Services_bases/telegram_service/__init__.py @@ -1 +1,3 @@ -from .telegram import TelegramService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram import TelegramService \ No newline at end of file diff --git a/Services/Services_bases/trading_view_service/__init__.py b/Services/Services_bases/trading_view_service/__init__.py index a4b739be3..03ef6fbf0 100644 --- a/Services/Services_bases/trading_view_service/__init__.py +++ b/Services/Services_bases/trading_view_service/__init__.py @@ -1 +1,3 @@ -from .trading_view import TradingViewService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .trading_view import TradingViewService diff --git a/Services/Services_bases/twitter_service/__init__.py b/Services/Services_bases/twitter_service/__init__.py index 5061207db..2b5377a16 100644 --- a/Services/Services_bases/twitter_service/__init__.py +++ b/Services/Services_bases/twitter_service/__init__.py @@ -1 +1,3 @@ -from .twitter import TwitterService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .twitter import TwitterService \ No newline at end of file diff --git a/Services/Services_bases/web_service/__init__.py b/Services/Services_bases/web_service/__init__.py index 689d36495..da60838b4 100644 --- a/Services/Services_bases/web_service/__init__.py +++ b/Services/Services_bases/web_service/__init__.py @@ -1 +1,3 @@ -from .web import WebService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .web import WebService \ No newline at end of file diff --git a/Services/Services_bases/webhook_service/__init__.py b/Services/Services_bases/webhook_service/__init__.py index 0e60e4e5c..80378c845 100644 --- a/Services/Services_bases/webhook_service/__init__.py +++ b/Services/Services_bases/webhook_service/__init__.py @@ -1 +1,3 @@ -from .webhook import WebHookService \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .webhook import WebHookService diff --git a/Services/Services_feeds/google_service_feed/__init__.py b/Services/Services_feeds/google_service_feed/__init__.py index 0f50f01ee..64d9c49db 100644 --- a/Services/Services_feeds/google_service_feed/__init__.py +++ b/Services/Services_feeds/google_service_feed/__init__.py @@ -1,2 +1,4 @@ -from .google_feed import GoogleServiceFeed -from .google_feed import TrendTopic +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .google_feed import GoogleServiceFeed + from .google_feed import TrendTopic diff --git a/Services/Services_feeds/reddit_service_feed/__init__.py b/Services/Services_feeds/reddit_service_feed/__init__.py index d90aaea44..7bcddcb40 100644 --- a/Services/Services_feeds/reddit_service_feed/__init__.py +++ b/Services/Services_feeds/reddit_service_feed/__init__.py @@ -1 +1,3 @@ -from .reddit_feed import RedditServiceFeed \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .reddit_feed import RedditServiceFeed diff --git a/Services/Services_feeds/telegram_api_service_feed/__init__.py b/Services/Services_feeds/telegram_api_service_feed/__init__.py index 6db2a999f..3212eb63e 100644 --- a/Services/Services_feeds/telegram_api_service_feed/__init__.py +++ b/Services/Services_feeds/telegram_api_service_feed/__init__.py @@ -1 +1,3 @@ -from .telegram_api_feed import TelegramApiServiceFeed \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram_api_feed import TelegramApiServiceFeed diff --git a/Services/Services_feeds/telegram_service_feed/__init__.py b/Services/Services_feeds/telegram_service_feed/__init__.py index dc5e80c6a..cb5d3560a 100644 --- a/Services/Services_feeds/telegram_service_feed/__init__.py +++ b/Services/Services_feeds/telegram_service_feed/__init__.py @@ -1 +1,3 @@ -from .telegram_feed import TelegramServiceFeed \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .telegram_feed import TelegramServiceFeed diff --git a/Services/Services_feeds/trading_view_service_feed/__init__.py b/Services/Services_feeds/trading_view_service_feed/__init__.py index 72405eb60..337c11ce9 100644 --- a/Services/Services_feeds/trading_view_service_feed/__init__.py +++ b/Services/Services_feeds/trading_view_service_feed/__init__.py @@ -1 +1,3 @@ -from .trading_view_feed import TradingViewServiceFeed \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .trading_view_feed import TradingViewServiceFeed diff --git a/Services/Services_feeds/twitter_service_feed/__init__.py b/Services/Services_feeds/twitter_service_feed/__init__.py index 541ab4cf8..430e4c198 100644 --- a/Services/Services_feeds/twitter_service_feed/__init__.py +++ b/Services/Services_feeds/twitter_service_feed/__init__.py @@ -1 +1,3 @@ -from .twitter_feed import TwitterServiceFeed \ No newline at end of file +import octobot_commons.constants as commons_constants +if not commons_constants.USE_MINIMAL_LIBS: + from .twitter_feed import TwitterServiceFeed diff --git a/Trading/Exchange/binance/binance_exchange.py b/Trading/Exchange/binance/binance_exchange.py index 0f6b56338..31a95c89d 100644 --- a/Trading/Exchange/binance/binance_exchange.py +++ b/Trading/Exchange/binance/binance_exchange.py @@ -15,6 +15,7 @@ # License along with this library. import decimal import typing +import enum import ccxt @@ -23,12 +24,19 @@ import octobot_trading.enums as trading_enums import octobot_trading.exchanges as exchanges import octobot_trading.errors as errors +import octobot_trading.constants as trading_constants import octobot_trading.exchanges.connectors.ccxt.constants as ccxt_constants import octobot_trading.exchanges.connectors.ccxt.enums as ccxt_enums import octobot_trading.util as trading_util import octobot_trading.personal_data as personal_data +class BinanceMarkets(enum.Enum): + SPOT = "spot" + LINEAR = "linear" + INVERSE = "inverse" + + class Binance(exchanges.RestExchange): DESCRIPTION = "" FIX_MARKET_STATUS = True @@ -241,6 +249,12 @@ def get_additional_connector_config(self): "filterClosed": False, # return empty positions as well } } + if trading_constants.FETCH_MIN_EXCHANGE_MARKETS: + config[ccxt_constants.CCXT_OPTIONS][ccxt_constants.CCXT_FETCH_MARKETS] = ( + [ + BinanceMarkets.LINEAR.value, BinanceMarkets.INVERSE.value + ] if self.exchange_manager.is_future else [BinanceMarkets.SPOT.value] + ) return config def is_authenticated_request(self, url: str, method: str, headers: dict, body) -> bool: diff --git a/Trading/Mode/trading_view_signals_trading_mode/trading_view_signals_trading.py b/Trading/Mode/trading_view_signals_trading_mode/trading_view_signals_trading.py index dcfb5850c..82fbfc043 100644 --- a/Trading/Mode/trading_view_signals_trading_mode/trading_view_signals_trading.py +++ b/Trading/Mode/trading_view_signals_trading_mode/trading_view_signals_trading.py @@ -21,11 +21,21 @@ import async_channel.channels as channels import octobot_commons.symbols.symbol_util as symbol_util import octobot_commons.enums as commons_enums +import octobot_commons.constants as commons_constants import octobot_commons.signals as commons_signals import octobot_commons.tentacles_management as tentacles_management import octobot_services.api as services_api import octobot_trading.personal_data as trading_personal_data -import tentacles.Services.Services_feeds.trading_view_service_feed as trading_view_service_feed +try: + import tentacles.Services.Services_feeds.trading_view_service_feed as trading_view_service_feed +except ImportError: + if commons_constants.USE_MINIMAL_LIBS: + # mock trading_view_service_feed imports + class TradingViewServiceFeedImportMock: + class TradingViewServiceFeed: + def get_name(self, *args, **kwargs): + raise ImportError("trading_view_service_feed not installed") + trading_view_service_feed = TradingViewServiceFeedImportMock() import tentacles.Trading.Mode.daily_trading_mode.daily_trading as daily_trading_mode import octobot_trading.constants as trading_constants import octobot_trading.enums as trading_enums @@ -39,7 +49,7 @@ class TradingViewSignalsTradingMode(trading_modes.AbstractTradingMode): - SERVICE_FEED_CLASS = trading_view_service_feed.TradingViewServiceFeed + SERVICE_FEED_CLASS = trading_view_service_feed.TradingViewServiceFeed if hasattr(trading_view_service_feed, 'TradingViewServiceFeed') else None TRADINGVIEW_FUTURES_SUFFIXES = [".P"] PARAM_SEPARATORS = [";", "\\n", "\n"] @@ -128,14 +138,22 @@ async def _get_feed_consumers(self): parsed_symbol = symbol_util.parse_symbol(self.symbol) self.str_symbol = str(parsed_symbol) self.merged_simple_symbol = parsed_symbol.merged_str_base_and_quote_only_symbol(market_separator="") - service_feed = services_api.get_service_feed(self.SERVICE_FEED_CLASS, self.bot_id) feed_consumer = [] - if service_feed is not None: - feed_consumer = [await channels.get_chan(service_feed.FEED_CHANNEL.get_name()).new_consumer( - self._trading_view_signal_callback - )] + if self.SERVICE_FEED_CLASS is None: + if commons_constants.USE_MINIMAL_LIBS: + self.logger.debug( + "Trading view service feed not installed, this trading mode won't be listening to trading view signals." + ) + else: + raise ImportError("TradingViewServiceFeed not installed") else: - self.logger.error("Impossible to find the Trading view service feed, this trading mode can't work.") + service_feed = services_api.get_service_feed(self.SERVICE_FEED_CLASS, self.bot_id) + if service_feed is not None: + feed_consumer = [await channels.get_chan(service_feed.FEED_CHANNEL.get_name()).new_consumer( + self._trading_view_signal_callback + )] + else: + self.logger.error("Impossible to find the Trading view service feed, this trading mode can't work.") return feed_consumer async def create_consumers(self) -> list: