alpaca_daily_losers.global_functions
Attributes
Classes
A class to send messages to a Slack channel. |
Functions
|
Calculate RSI and Bollinger Bands for a given history and window. |
|
Retrieve historical data for a given ticker. |
|
Retrieve historical data for given tickers and compute technical indicators. |
|
Sends position messages based on the type of position. |
|
Send a message to Slack. |
Module Contents
- class alpaca_daily_losers.global_functions.Slack(slack_token: str = None)
A class to send messages to a Slack channel.
- slack_token
Token for authenticating with the Slack API.
- Type:
str
- client
Slack WebClient instance for making API calls.
- Type:
WebClient
- send_message(channel: str, text: str, username: str = None)
Sends a message to the specified Slack channel.
- Parameters:
channel (str) – Slack channel ID or name.
text (str) – Message text to send.
username (str, optional) – Username to send the message as. Defaults to None.
- Returns:
Response from the Slack API.
- Return type:
dict
- Raises:
ValueError – If the Slack token is not set or if the message fails to send.
- alpaca_daily_losers.global_functions.tz
- alpaca_daily_losers.global_functions.ctime
- alpaca_daily_losers.global_functions.today
- alpaca_daily_losers.global_functions.previous_day
- alpaca_daily_losers.global_functions.year_ago
- alpaca_daily_losers.global_functions.production
- alpaca_daily_losers.global_functions.slack_username
- alpaca_daily_losers.global_functions.logger
- alpaca_daily_losers.global_functions.calculate_indicators(history: pandas.DataFrame, window: int) pandas.DataFrame
Calculate RSI and Bollinger Bands for a given history and window.
- Parameters:
history (pd.DataFrame) – Historical stock data.
window (int) – Window period for RSI and Bollinger Bands.
- Returns:
DataFrame with RSI and Bollinger Band indicators.
- Return type:
df (pd.DataFrame)
- alpaca_daily_losers.global_functions.get_historical_data(stock_client: py_alpaca_api.Stock, ticker: str, start_date: str, end_date: str) pandas.DataFrame
Retrieve historical data for a given ticker.
- Parameters:
stock_client (Stock) – Stock client for retrieving historical data.
ticker (str) – Stock ticker symbol.
start_date (str) – Start date for historical data.
end_date (str) – End date for historical data.
- Returns:
Historical stock data.
- Return type:
history (pd.DataFrame)
- alpaca_daily_losers.global_functions.get_ticker_data(tickers, stock_client: py_alpaca_api.Stock, py_logger=None) pandas.DataFrame
Retrieve historical data for given tickers and compute technical indicators.
- Parameters:
tickers (list) – List of stock ticker symbols.
stock_client (Stock) – Stock client for retrieving historical data.
py_logger (logging.Logger, optional) – Logger for logging warnings and errors.
- Returns:
DataFrame with the latest technical indicators for each ticker.
- Return type:
df_tech (pd.DataFrame)
- alpaca_daily_losers.global_functions.send_position_messages(positions: list, pos_type: str)
Sends position messages based on the type of position.
- Parameters:
positions (list) – List of position dictionaries.
pos_type (str) – Type of position (“buy”, “sell”, or “liquidate”).
- Returns:
True if message was sent successfully, False otherwise.
- Return type:
bool
- alpaca_daily_losers.global_functions.send_message(message: str)
Send a message to Slack.
- Parameters:
message (str) – Message to send.