diff --git a/api/research/controller.py b/api/research/controller.py
index e03520c37..683b6da6f 100644
--- a/api/research/controller.py
+++ b/api/research/controller.py
@@ -1,11 +1,12 @@
from db import setup_db
from datetime import datetime
from time import sleep
-from tools.handle_error import json_response, json_response_error
+from tools.handle_error import json_response, json_response_error, json_response_message
from pymongo.errors import DuplicateKeyError
from apis import ThreeCommasApi
from tools.round_numbers import round_numbers
from pymongo import ASCENDING
+from fastapi.encoders import jsonable_encoder
class Controller:
"""
@@ -134,4 +135,50 @@ def get_3commas_signals(self):
return json_response({"message": "Successfully retrieved profitable 3commas signals", "data": signals})
+ """
+ Get pairs that binbot-research signals are subscribed to
+ receive cryptodata
+
+ To merge with blacklist
+ """
+ def get_subscribed_symbols(self):
+ query_result = self.db.subscribed_symbols.find({}).sort("pair", ASCENDING)
+ all_symbols = list(query_result)
+ return json_response(
+ {"message": "Successfully retrieved blacklist", "data": all_symbols}
+ )
+
+ def delete_all_subscribed_symbols(self):
+ query_result = self.db.subscribed_symbols.delete_many({})
+
+ return json_response(
+ {"message": "Successfully deleted all symbols", "data": {
+ "total": 0
+ }}
+ )
+ def bulk_upsert_all(self, data):
+ symbols = jsonable_encoder(data)
+ try:
+ query_result = self.db.subscribed_symbols.update_many(
+ symbols,
+ upsert=True,
+ )
+ return json_response(
+ {"message": "Successfully created new susbcribed list", "data": {
+ "total": len(query_result.inserted_ids) + 1
+ }}
+ )
+ except Exception as error:
+ return json_response_error(f"Failed to update symbol in the subscribed list {error}")
+
+ def edit_subscribed_symbol(self, symbol):
+ symbol = jsonable_encoder(symbol)
+ try:
+ self.db.subscribed_symbols.update_one(
+ symbol,
+ upsert=True,
+ )
+ return json_response_message("Successfully update symbol in the subscribed list")
+ except Exception as error:
+ return json_response_error(f"Failed to update symbol in the subscribed list {error}")
\ No newline at end of file
diff --git a/api/research/routes.py b/api/research/routes.py
index 2bf8269db..ec1b11948 100644
--- a/api/research/routes.py
+++ b/api/research/routes.py
@@ -2,7 +2,7 @@
from apis import ThreeCommasApi
from research.controller import Controller
-from research.schemas import BlacklistSchema, BlacklistResponse
+from research.schemas import BlacklistSchema, BlacklistResponse, SubscribedSymbolsSchema
research_blueprint = APIRouter()
@@ -42,3 +42,17 @@ def get_blacklisted():
@research_blueprint.get("/3commas-presets", tags=["blacklist and research"])
def three_commas_presets():
return ThreeCommasApi().get_marketplace_presets()
+
+
+@research_blueprint.get("/subscribed", tags=["blacklist and research"])
+def get_subscribed_symbols():
+ return Controller().get_subscribed_symbols()
+
+
+@research_blueprint.post("/subscribed", tags=["blacklist and research"])
+def create_subscribed_symbols(data: list[SubscribedSymbolsSchema]):
+ return Controller().bulk_upsert_all(data)
+
+@research_blueprint.put("/subscribed/{symbol}", tags=["blacklist and research"])
+def edit_subscribed_symbol(symbol: str):
+ return Controller().edit_subscribed_symbol(symbol)
diff --git a/api/research/schemas.py b/api/research/schemas.py
index bb603dc22..bc1428392 100644
--- a/api/research/schemas.py
+++ b/api/research/schemas.py
@@ -16,3 +16,28 @@ class Config:
class BlacklistResponse(StandardResponse):
data: list[BlacklistSchema]
+
+
+"""
+Database control for symbols that are used
+in signals.
+"""
+class SubscribedSymbolsSchema(BaseModel):
+ _id: str
+ pair: str
+ blacklisted: bool = False
+ blacklisted_reason: str = ""
+
+ class Config:
+ schema_extra = {
+ "example": {
+ "_id": "BNBBTC",
+ "pair": "BNBBTC",
+ "blacklisted": False,
+ "blacklisted_reason": "Overtraded"
+ }
+ }
+
+
+class SubscribedSymbolsResponse(StandardResponse):
+ data: list[SubscribedSymbolsSchema]
diff --git a/web/.env b/web/.env
index d3ceaa627..190bda841 100644
--- a/web/.env
+++ b/web/.env
@@ -30,6 +30,7 @@ REACT_APP_TICKER=/account/ticker
REACT_APP_TICKER_24="https://api.binance.com/api/v3/ticker/24hr"
REACT_APP_RESEARCH_BLACKLIST=/research/blacklist
REACT_APP_RESEARCH_CONTROLLER=/autotrade-settings/bots
+REACT_APP_SUBSCRIBED="/research/subscribed"
REACT_APP_NO_CANNIBALISM_SYMBOLS=/account/symbols/no-cannibal
REACT_APP_BINANCE_INFO="https://api.binance.com/api/v3/exchangeInfo"
REACT_APP_HEDGE_GBP=/account/hedge-gbp
diff --git a/web/src/pages/research/ControllerTab.jsx b/web/src/pages/research/ControllerTab.jsx
index 4663a418d..5da737534 100644
--- a/web/src/pages/research/ControllerTab.jsx
+++ b/web/src/pages/research/ControllerTab.jsx
@@ -21,6 +21,7 @@ export const ControllerTab = ({
addToBlacklist,
removeFromBlacklist,
triggerGbpHedge,
+ subscribedSymbols,
}) => {
const [addBlacklist, setAddBlacklist] = useImmer({ reason: "", pair: "" });
const [removeBlacklist, setRemoveBlacklist] = useState("");
@@ -124,6 +125,29 @@ export const ControllerTab = ({
{" "}
+
+