Skip to content

Commit a22e626

Browse files
authored
V2.1.4 (#55)
* update * news fix
1 parent e7c21cd commit a22e626

File tree

9 files changed

+22
-12
lines changed

9 files changed

+22
-12
lines changed

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "py-alpaca-api"
3-
version = "2.1.3"
3+
version = "2.1.4"
44
description = "Python package, for communicating with Alpaca Markets REST API."
55
authors = ["TexasCoding <[email protected]>"]
66
readme = "README.md"

src/py_alpaca_api/http/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def request(
2121
method: str,
2222
url: str,
2323
headers: Optional[Dict[str, str]] = None,
24-
params: Optional[Dict[str, str]] = None,
24+
params: Optional[Dict[str, str] | Dict[str, bool] | Dict[str, float]] = None,
2525
json: Optional[Dict[str, str]] = None,
2626
):
2727
"""

src/py_alpaca_api/models/watchlist_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass
22
from datetime import datetime
3-
from typing import Dict, List
3+
from typing import Dict, List, Union
44

55
from py_alpaca_api.models.asset_model import AssetModel
66
from py_alpaca_api.models.model_utils import KEY_PROCESSORS, extract_class_data
@@ -13,7 +13,7 @@ class WatchlistModel:
1313
created_at: datetime
1414
updated_at: datetime
1515
name: str
16-
assets: List[object]
16+
assets: List[Union[object | AssetModel]]
1717

1818

1919
############################################

src/py_alpaca_api/stock/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(
1111
self, api_key: str, api_secret: str, api_paper: bool, market: Market
1212
) -> None:
1313
headers = {
14+
"accept": "application/json",
1415
"APCA-API-KEY-ID": api_key,
1516
"APCA-API-SECRET-KEY": api_secret,
1617
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class LatestQuote:
2+
def __init__(self) -> None:
3+
pass

src/py_alpaca_api/stock/predictor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,18 @@ def get_losers_to_gainers(
105105
future_periods: int = 14,
106106
) -> list:
107107
"""
108-
Retrieves a list of future gainers by predicting stock prices using Prophet.
108+
Predicts future gainers based on the previous day's losers using Prophet forecasting.
109109
110110
Args:
111-
losers_to_scan (int): The number of previous day losers to scan. Defaults to 200.
111+
gain_ratio: The minimum gain ratio required for a stock to be considered a future gainer.
112+
losers_to_scan: The number of previous day's losers to scan.
113+
future_periods: The number of future periods to forecast.
112114
113115
Returns:
114-
list: A list of symbols representing the future gainers.
116+
A list of future gainers.
117+
118+
Raises:
119+
Exception: If there is an error while predicting future gainers for a stock.
115120
"""
116121
previous_day_losers = self.screener.losers(total_losers_returned=losers_to_scan)
117122
losers_list = previous_day_losers["symbol"].tolist()

src/py_alpaca_api/trading/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class Trading:
1414
def __init__(self, api_key: str, api_secret: str, api_paper: bool) -> None:
1515
headers = {
16+
"accept": "application/json",
1617
"APCA-API-KEY-ID": api_key,
1718
"APCA-API-SECRET-KEY": api_secret,
1819
}

src/py_alpaca_api/trading/news.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _get_yahoo_news(self, symbol: str, limit: int = 5) -> List[Dict[str, str]]:
143143
)
144144
except Exception as e:
145145
logging.error(f"Error scraping article: {e}")
146-
pass
146+
continue
147147

148148
return yahoo_news
149149

@@ -173,7 +173,7 @@ def _get_benzinga_news(
173173
- "url": The URL of the news article.
174174
- "source": The source of the news article (in this case, "benzinga").
175175
- "content": The content of the news article, or None if there is no content.
176-
- "publish_date": The publish date of the news article.
176+
- "publish_date": The publishing date of the news article.
177177
- "symbol": The symbol associated with the news article.
178178
"""
179179
url = f"{self.news_url}"

0 commit comments

Comments
 (0)