Skip to content

Commit

Permalink
Merge pull request #27 from jk1mm/feature/sentiment
Browse files Browse the repository at this point in the history
Feature/sentiment
  • Loading branch information
jk1mm authored Aug 2, 2021
2 parents 468f60e + ed29efa commit 26c5f41
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 8 deletions.
18 changes: 18 additions & 0 deletions docs/pages/mydoc/module_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ print(abnb)

```

The **stock_health** function gets a given ticker's external information (news, analyst ratings, insider trading)
using the [finviz](https://github.com/mariostoev/finviz) api.

```python
# Python

# Import module
from stock_market.data import stock_health

# Get external information about Airbnb
abnb_health = stock_health(
ticker="ABNB"
)

print(abnb_health)

```

## IPO

Initial Public Offering is the offering of a company's shares into the stock market/exchange.
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/mydoc/version_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Below lists the history of changes made to this package.

### V1.0 +

#### 1.3.1
- Data health call, using [finviz](https://pypi.org/project/finviz/) api

#### 1.3.0
- IPO data module, fix several bugs
- isort addition

#### 1.2.1
- Update documentation to Jekyll format

Expand Down
1 change: 1 addition & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ prawcore>=2.3.0,<3.0.0
pyspellchecker==0.6.2,<1.0.0
python-dotenv
nltk>=3.6.2,<4.0.0
finviz>=1.4.2,<2.0.0
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="stock_market",
version="1.3.0",
version="1.3.1",
description="Modules related to stock market model.",
author="Josh Kim",
author_email="joshkim47@gmail.com",
Expand All @@ -19,6 +19,7 @@
"pyspellchecker==0.6.2,<1.0.0",
"python-dotenv",
"nltk>=3.6.2,<4.0.0",
"finviz>=1.4.2,<2.0.0",
],
include_package_data=True,
python_requires=">=3.6",
Expand Down
6 changes: 0 additions & 6 deletions stock_market/analysis/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ def stock_profit(
return net_profit


# TODO: Stock sentiment
# def stock_sentiment(
# ticker: str,
# ) -> Optional[float]:


def stock_chart(
stocks: List[str],
start_date: str,
Expand Down
2 changes: 1 addition & 1 deletion stock_market/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as _pandas

from stock_market.data._ipo import IPO
from stock_market.data._stocks import get_ticker
from stock_market.data._stocks import get_ticker, stock_health
from stock_market.data.reddit.trends import get_reddit_top_posts

# S&P data
Expand Down
32 changes: 32 additions & 0 deletions stock_market/data/_stocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Optional

import finviz
import numpy as np
import pandas as pd
import requests.exceptions
from pandas_datareader import data


Expand Down Expand Up @@ -101,3 +103,33 @@ def get_ticker(
)

return stock_data


def stock_health(
ticker: str,
) -> dict:
"""
Stock health, using finviz api.
Parameters
----------
ticker: str
Stock ticker symbol.
Returns
-------
health: dict
Stock news, insider trading, and price target information.
"""
health = {}

try:
health["news"] = finviz.get_news(ticker)
except requests.exceptions.HTTPError:
raise ValueError("Please input a valid ticker")

health["insider_trades"] = finviz.get_insider(ticker)
health["price_targets"] = finviz.get_analyst_price_targets(ticker)

return health

0 comments on commit 26c5f41

Please sign in to comment.