Skip to content

Commit 1daacd4

Browse files
committed
Modified project structure
1 parent 24dab15 commit 1daacd4

14 files changed

Lines changed: 492 additions & 163 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Python-generated files
22
__pycache__/
33
.mypy_cache
4+
.ruff_cache
45
*.py[cod]
56
*$py.class
67
*.so

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ authors = [
99
requires-python = ">=3.12"
1010
dependencies = [
1111
"asyncio>=3.4.3",
12-
"dash>=2.18.2",
1312
"duckdb>=1.1.3",
1413
"fastapi>=0.115.4",
1514
"httpx>=0.27.2",
@@ -18,6 +17,8 @@ dependencies = [
1817
"pydantic>=2.9.2",
1918
"python-dotenv>=1.0.1",
2019
"pyyaml>=6.0.2",
20+
"streamlit>=1.40.1",
21+
"uvicorn>=0.32.0",
2122
]
2223

2324
[project.scripts]

src/stock_valuation_app/data/fmp_client.py renamed to src/api/fmp_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any
55
import httpx
66
import utils
7-
from stock_valuation_app.models.stock import CombinedModel
7+
from models.stock_data import CombinedModel
88

99

1010
def get_endpoint(url: str) -> str:
@@ -37,6 +37,7 @@ async def get_data(self, client: httpx.Client, url: str) -> dict[str, Any]:
3737
return data
3838

3939
async def fetch_data(self, ticker: str) -> dict[str, list[dict[str, Any]]]:
40+
"""Extracts data asynchronously from multiple FMP endpoints"""
4041
urls = []
4142
for metric in self.metric_types:
4243
if metric in ["profile", "rating"]:
@@ -60,4 +61,4 @@ async def fetch_data(self, ticker: str) -> dict[str, list[dict[str, Any]]]:
6061
records = dict(zip(new_metric_types, results))
6162

6263
# Validate the combined records
63-
return CombinedModel(**records).model_dump()
64+
return CombinedModel(**records).model_dump()

src/main.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
import asyncio
2-
from stock_valuation_app.data import fmp_client
3-
4-
async def main() -> None:
5-
"""Main function to fetch data from the Financial Modeling Prep API."""
6-
api_client = fmp_client.FMPClient()
7-
rating_endpoint = fmp_client.get_endpoint("annual_ratios")
8-
data = await api_client.fetch_data(rating_endpoint, "AAPL")
9-
print(data)
10-
11-
12-
if __name__ == "__main__":
13-
asyncio.run(main())

src/services/stock_analysis.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import asyncio
2+
import polars as pl
3+
# from stock_valuation_app.data.fmp_client import FMPClient
4+
5+
6+
7+
8+
raw_data = asyncio.run(extract_source_data("PAYS"))
9+
10+
profile_df = pl.DataFrame(raw_data["profile"])
11+
rating_df = pl.DataFrame(raw_data["rating"])
12+
metric_df = pl.DataFrame(raw_data["key_metrics"])
13+
growth_df = pl.DataFrame(raw_data["growth"])
14+
15+
# Pivot the DataFrame
16+
pivoted_df = profile_df.unpivot(variable_name="Column", value_name="Value")
17+
# Sort the result to maintain the original order
18+
pivoted_df = pivoted_df.sort("Column")
19+
20+
# Convert DataFrame to formatted text
21+
formatted_text = []
22+
for row in pivoted_df.iter_rows():
23+
column, value = row
24+
formatted_text.append(html.Div([html.Strong(f"{column}: "), f"{value}"]))
25+
26+
# async def extract_source_data(ticker: str):
27+
# source_data = await FMPClient().fetch_data(ticker)
28+
# return {
29+
# "profile": source_data["profile"],
30+
# "rating": source_data["rating"],
31+
# "key_metrics": source_data["key_metrics"],
32+
# "growth": source_data["growth"],
33+
# }
34+
35+
# async def extract_source_data(ticker: str):
36+
# source_data = await FMPClient().fetch_data(ticker)
37+
# return source_data
38+
39+
40+
# if __name__ == "__main__":
41+
# pass
42+
# raw_data = asyncio.run(extract_source_data('PAYS'))
43+
44+
# def get_dataframes():
45+
# """Captures source dataframes"""
46+
# profile_df = pl.DataFrame(raw_data["profile"])
47+
# rating_df = pl.DataFrame(raw_data["rating"])
48+
# metric_df = pl.DataFrame(raw_data["key_metrics"])
49+
# growth_df = pl.DataFrame(raw_data["growth"])
50+
# return (profile_df, rating_df, metric_df, growth_df)

src/stock_valuation_app/api/routes.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)