Update utils.py
Browse files
utils.py
CHANGED
@@ -49,7 +49,17 @@ def smc_structure_backtest(data, filename, swing_hl, **kwargs):
|
|
49 |
|
50 |
def run_strategy(ticker_symbol, strategy, period, interval, kwargs):
|
51 |
# Fetching ohlc of random ticker_symbol.
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
filename = f'{ticker_symbol}.html'
|
55 |
|
|
|
49 |
|
50 |
def run_strategy(ticker_symbol, strategy, period, interval, kwargs):
|
51 |
# Fetching ohlc of random ticker_symbol.
|
52 |
+
retries = 3
|
53 |
+
for i in range(retries):
|
54 |
+
try:
|
55 |
+
data = fetch(ticker_symbol, period, interval)
|
56 |
+
except:
|
57 |
+
raise Exception(f"{ticker_symbol} data fetch failed")
|
58 |
+
|
59 |
+
if len(data) == 0:
|
60 |
+
raise Exception(f"{ticker_symbol} ohlc is empty")
|
61 |
+
else:
|
62 |
+
break
|
63 |
|
64 |
filename = f'{ticker_symbol}.html'
|
65 |
|