Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf6c4846c4 |
+2
-6
@@ -60,12 +60,8 @@ def display_recent_signals(df: pd.DataFrame):
|
||||
# Optional: Show a quick mini-forecast chart per symbol
|
||||
st.write("---")
|
||||
st.subheader("Mini Signal Forecasts (per symbol)")
|
||||
for symbol in sorted(df[COL_SYMBOL].unique()):
|
||||
mini_df = (
|
||||
df[df[COL_SYMBOL] == symbol]
|
||||
.sort_values(COL_TIMESTAMP)
|
||||
.tail(N_FORWARD)
|
||||
)
|
||||
for symbol, group in df.sort_values(COL_TIMESTAMP).groupby(COL_SYMBOL):
|
||||
mini_df = group.tail(N_FORWARD)
|
||||
# Only show if there is more than one unique value
|
||||
if mini_df[COL_PREDICTION].nunique() > 1:
|
||||
st.write(f"**{symbol}**")
|
||||
|
||||
@@ -82,9 +82,6 @@ class TradingApp:
|
||||
Fetch 'n' bars of historical data for the given symbol and timeframe.
|
||||
"""
|
||||
rates = mt5.copy_rates_from_pos(symbol, timeframe, 0, n)
|
||||
if rates is None:
|
||||
log_and_print(f"Could not retrieve data for {symbol}", is_error=True)
|
||||
return None
|
||||
rates_frame = pd.DataFrame(rates)
|
||||
rates_frame['time'] = pd.to_datetime(rates_frame['time'], unit='s')
|
||||
rates_frame.set_index('time', inplace=True)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import sys
|
||||
from unittest.mock import MagicMock
|
||||
# Mock out MetaTrader5 before importing our module
|
||||
sys.modules['MetaTrader5'] = MagicMock()
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
import pandas as pd
|
||||
from live_trading.multi_bar import TradingApp, log_and_print
|
||||
|
||||
class TestTradingApp(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.app = TradingApp(symbol="EURUSD", lot_size=0.01, magic_number=123456)
|
||||
|
||||
@patch("live_trading.multi_bar.mt5.copy_rates_from_pos")
|
||||
@patch("live_trading.multi_bar.log_and_print")
|
||||
def test_get_data_returns_none(self, mock_log, mock_copy_rates):
|
||||
mock_copy_rates.return_value = None
|
||||
|
||||
# Test what happens when mt5.copy_rates_from_pos returns None
|
||||
result = self.app.get_data("EURUSD", 100, 16408)
|
||||
|
||||
self.assertIsNone(result)
|
||||
mock_log.assert_called_once_with("Could not retrieve data for EURUSD", is_error=True)
|
||||
Reference in New Issue
Block a user