createbatch image tool + send to telefram enrichment
This commit is contained in:
@ -13,6 +13,7 @@ from collections import defaultdict
|
||||
from pandas import to_datetime
|
||||
from msgpack.ext import Timestamp
|
||||
import time
|
||||
from traceback import format_exc
|
||||
|
||||
def convert_historical_bars(daily_bars):
|
||||
"""Converts a list of daily bars into a dictionary with the specified keys.
|
||||
@ -124,5 +125,5 @@ def get_historical_bars(symbol: str, time_from: datetime, time_to: datetime, tim
|
||||
time.sleep(backoff_factor * (2 ** attempt))
|
||||
|
||||
print("All attempts to fetch historical bar data failed.")
|
||||
send_to_telegram(f"Failed to fetch historical bar data after {max_retries} retries. Last exception: {last_exception}")
|
||||
raise Exception(f"Failed to fetch historical bar data after {max_retries} retries. Last exception: {last_exception}")
|
||||
send_to_telegram(f"Failed to fetch historical bar data after {max_retries} retries. Last exception: {str(last_exception)} and {format_exc()}")
|
||||
raise Exception(f"Failed to fetch historical bar data after {max_retries} retries. Last exception: {str(last_exception)} and {format_exc()}")
|
||||
|
||||
@ -29,6 +29,7 @@ import numpy as np
|
||||
from alpaca.trading.requests import GetCalendarRequest
|
||||
from alpaca.trading.client import TradingClient
|
||||
import time as timepkg
|
||||
from traceback import format_exc
|
||||
|
||||
#Alpaca Calendar wrapper with retry
|
||||
def fetch_calendar_data(start, end, max_retries=5, backoff_factor=1):
|
||||
@ -60,8 +61,8 @@ def fetch_calendar_data(start, end, max_retries=5, backoff_factor=1):
|
||||
timepkg.sleep(backoff_factor * (2 ** attempt))
|
||||
|
||||
richprint("****All attempts to fetch calendar data failed.****")
|
||||
send_to_telegram(f"FETCH_CALENDER_DATA_FAILED. {last_exception} BACKEST STOPPED" )
|
||||
raise ConnectionError(f"Failed to fetch calendar data after {max_retries} retries. Last exception: {last_exception}")
|
||||
send_to_telegram(f"FETCH_CALENDER_DATA_FAILED. {str(last_exception)} and {format_exc()} BACKEST STOPPED" )
|
||||
raise ConnectionError(f"Failed to fetch calendar data after {max_retries} retries. Last exception: {str(last_exception)} and {format_exc()}")
|
||||
|
||||
def concatenate_weekdays(weekday_filter):
|
||||
# Mapping of weekdays where 0 is Monday and 6 is Sunday
|
||||
|
||||
Reference in New Issue
Block a user