Skip to content

Commit

Permalink
Merge pull request #153 from hummingbot/feat/minor_bugs
Browse files Browse the repository at this point in the history
Feat/minor bugs
  • Loading branch information
cardosofede authored Jun 28, 2024
2 parents 68cf26c + ce337ca commit 86c440d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion backend/services/backend_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def add_account(self, account_name: str):

def delete_account(self, account_name: str):
"""Delete an account."""
endpoint = "delete-account/"
endpoint = "delete-account"
return self.post(endpoint, params={"account_name": account_name})

def delete_credential(self, account_name: str, connector_name: str):
Expand Down
5 changes: 2 additions & 3 deletions frontend/components/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ def get_default_config_loader(controller_name: str):
all_configs = backend_api_client.get_all_controllers_config()
existing_configs = [config["id"].split("_")[0] for config in all_configs]
default_dict = {"id": generate_random_name(existing_configs)}
default_config = st.session_state.get("default_config")
config_controller_name = st.session_state.get("controller_name", controller_name)
st.write(f"controller_name: {controller_name} | config_controller_name: {config_controller_name}")
default_config = st.session_state.get("default_config", default_dict)
config_controller_name = default_config.get("controller_name")
if default_config is None or controller_name != config_controller_name:
st.session_state["default_config"] = default_dict
with st.expander("Configurations", expanded=True):
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/save_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def render_save_config(config_base_default: str, config_data: dict):
if upload_config_to_backend:
config_data["id"] = f"{config_base}_{config_tag}"
backend_api_client.add_controller_config(config_data)
st.session_state["default_config"] = None
st.session_state.pop("default_config")
st.success("Config uploaded successfully!")
10 changes: 2 additions & 8 deletions frontend/pages/config/bollinger_v1/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
from datetime import datetime

import streamlit as st
import pandas as pd
import yaml
import pandas_ta as ta # noqa: F401

from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from backend.services.backend_api_client import BackendAPIClient
from frontend.components.backtesting import backtesting_section
from frontend.components.config_loader import get_default_config_loader
from frontend.components.save_config import render_save_config
from frontend.pages.config.utils import get_max_records, get_candles
from frontend.pages.config.utils import get_candles
from frontend.st_utils import initialize_st_page, get_backend_api_client
from frontend.pages.config.bollinger_v1.user_inputs import user_inputs
from plotly.subplots import make_subplots
Expand All @@ -36,7 +30,7 @@
st.session_state["default_config"].update(inputs)

st.write("### Visualizing Bollinger Bands and Trading Signals")
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=3)
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=7)
# Load candle data
candles = get_candles(connector_name=inputs["candles_connector"], trading_pair=inputs["candles_trading_pair"], interval=inputs["interval"], days=days_to_visualize)

Expand Down
11 changes: 3 additions & 8 deletions frontend/pages/config/macd_bb_v1/app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import streamlit as st
import pandas as pd
import plotly.graph_objects as go
import yaml
from plotly.subplots import make_subplots

from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from backend.services.backend_api_client import BackendAPIClient
from frontend.components.backtesting import backtesting_section
from frontend.components.config_loader import get_default_config_loader
from frontend.components.save_config import render_save_config
from frontend.pages.config.macd_bb_v1.user_inputs import user_inputs
from frontend.pages.config.utils import get_candles, get_max_records
from frontend.pages.config.utils import get_candles
from frontend.st_utils import initialize_st_page, get_backend_api_client
from frontend.visualization import theme
from frontend.visualization.backtesting import create_backtesting_figure
from frontend.visualization.backtesting_metrics import render_backtesting_metrics, render_accuracy_metrics, \
render_close_types
from frontend.visualization.candles import get_candlestick_trace
from frontend.visualization.indicators import get_bbands_traces, get_volume_trace, get_macd_traces
from frontend.visualization.indicators import get_bbands_traces, get_macd_traces
from frontend.visualization.signals import get_macdbb_v1_signal_traces
from frontend.visualization.utils import add_traces_to_fig

Expand All @@ -32,7 +27,7 @@


st.write("### Visualizing MACD Bollinger Trading Signals")
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=3)
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=7)
# Load candle data
candles = get_candles(connector_name=inputs["candles_connector"], trading_pair=inputs["candles_trading_pair"], interval=inputs["interval"], days=days_to_visualize)

Expand Down
6 changes: 2 additions & 4 deletions frontend/pages/config/pmm_dynamic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import plotly.graph_objects as go
from plotly.subplots import make_subplots

from backend.services.backend_api_client import BackendAPIClient
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from frontend.components.config_loader import get_default_config_loader
from frontend.components.executors_distribution import get_executors_distribution_inputs
from frontend.components.save_config import render_save_config
Expand All @@ -12,7 +10,7 @@
from frontend.components.backtesting import backtesting_section
from frontend.pages.config.pmm_dynamic.spread_and_price_multipliers import get_pmm_dynamic_multipliers
from frontend.pages.config.pmm_dynamic.user_inputs import user_inputs
from frontend.pages.config.utils import get_max_records, get_candles
from frontend.pages.config.utils import get_candles
from frontend.st_utils import initialize_st_page, get_backend_api_client
from frontend.visualization import theme
from frontend.visualization.backtesting import create_backtesting_figure
Expand All @@ -35,7 +33,7 @@
st.write("### Visualizing MACD and NATR indicators for PMM Dynamic")
st.text("The MACD is used to shift the mid price and the NATR to make the spreads dynamic. "
"In the order distributions graph, we are going to see the values of the orders affected by the average NATR")
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=3)
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=7)
# Load candle data
candles = get_candles(connector_name=inputs["candles_connector"], trading_pair=inputs["candles_trading_pair"], interval=inputs["interval"], days=days_to_visualize)
with st.expander("Visualizing PMM Dynamic Indicators", expanded=True):
Expand Down
6 changes: 2 additions & 4 deletions frontend/pages/config/supertrend_v1/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import streamlit as st
from plotly.subplots import make_subplots

from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from backend.services.backend_api_client import BackendAPIClient
from frontend.components.backtesting import backtesting_section
from frontend.components.config_loader import get_default_config_loader
from frontend.components.save_config import render_save_config
from frontend.pages.config.supertrend_v1.user_inputs import user_inputs
from frontend.pages.config.utils import get_candles, get_max_records
from frontend.pages.config.utils import get_candles
from frontend.st_utils import initialize_st_page, get_backend_api_client
from frontend.visualization import theme
from frontend.visualization.backtesting import create_backtesting_figure
Expand All @@ -28,7 +26,7 @@
st.session_state["default_config"].update(inputs)

st.write("### Visualizing Supertrend Trading Signals")
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=3)
days_to_visualize = st.number_input("Days to Visualize", min_value=1, max_value=365, value=7)
# Load candle data
candles = get_candles(connector_name=inputs["candles_connector"], trading_pair=inputs["candles_trading_pair"], interval=inputs["interval"], days=days_to_visualize)

Expand Down
10 changes: 9 additions & 1 deletion frontend/pages/orchestration/credentials/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ def get_all_connectors_config_map():
st.header("Create a New Account")
new_account_name = st.text_input("New Account Name")
if st.button("Create Account"):
new_account_name = new_account_name.replace(" ", "_")
if new_account_name:
if new_account_name in accounts:
st.warning(f"Account {new_account_name} already exists.")
st.stop()
elif new_account_name == "" or all(char == "_" for char in new_account_name):
st.warning("Please enter a valid account name.")
st.stop()
response = client.add_account(new_account_name)
st.write(response)
else:
Expand Down Expand Up @@ -95,4 +102,5 @@ def get_all_connectors_config_map():
with cols[-1]:
if st.button("Submit Credentials"):
response = client.add_connector_keys(account_name, connector_name, config_inputs)

if response:
st.success(response)
8 changes: 7 additions & 1 deletion frontend/pages/orchestration/portfolio/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def account_history_to_df(history):
# Fetch account state from the backend
account_state = client.get_accounts_state()
account_history = client.get_account_state_history()

if len(account_state) == 0:
st.warning("No accounts found.")
st.stop()

# Display the accounts available
accounts = st.multiselect("Select Accounts", list(account_state.keys()), list(account_state.keys()))
Expand All @@ -65,6 +67,10 @@ def account_history_to_df(history):
exchanges_available = []
for account in accounts:
exchanges_available += account_state[account].keys()

if len(exchanges_available) == 0:
st.warning("No exchanges found.")
st.stop()
exchanges = st.multiselect("Select Exchanges", exchanges_available, exchanges_available)

# Display the tokens available
Expand Down

0 comments on commit 86c440d

Please sign in to comment.