Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoestner committed Nov 5, 2023
1 parent 82f493b commit ddf6e97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from dash import html
from dash.dependencies import Input, Output, State
from dash.dash_table.Format import Format, Scheme
from io import StringIO

from folioflex.dashboard import dashboard_helper, layouts
from folioflex.dashboard.pages import (
Expand Down Expand Up @@ -284,7 +285,7 @@ def get_results(task_status, task_id):
def update_SectorData(sector_status, yf_data):
"""Provide sector data table."""
if sector_status == "ready":
cq_sector_close = pd.read_json(yf_data)
cq_sector_close = pd.read_json(StringIO(yf_data))
min, max, value, marks = dashboard_helper.get_slider_values(
cq_sector_close.index
)
Expand All @@ -308,7 +309,7 @@ def update_SectorGraph(slide_value, yf_data, sector_status):
layout = go.Layout(hovermode="closest")

if sector_status == "ready" and slide_value != 0:
cq_sector_close = pd.read_json(yf_data)
cq_sector_close = pd.read_json(StringIO(yf_data))
sector_data = cq_sector_close[
(dashboard_helper.unix_time_millis(cq_sector_close.index) > slide_value[0])
& (
Expand Down
23 changes: 13 additions & 10 deletions folioflex/portfolio/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
"""

import fredapi
import logging
import pandas as pd
import yfinance as yf
import requests
import ssl

from bs4 import BeautifulSoup
from datetime import datetime, timedelta
from io import StringIO
from urllib import request

import fredapi
import pandas as pd
import requests
import yfinance as yf
from bs4 import BeautifulSoup

from folioflex.utils import config_helper

pd.options.display.float_format = "{:,.2f}".format
Expand Down Expand Up @@ -187,8 +188,8 @@ def most_active(self, count=25):
f"https://finance.yahoo.com/screener/predefined/most_actives?count={count}"
)

response = requests.get(url, headers=_get_header())
most_active = pd.read_html(response.text)[0]
response = requests.get(url, headers=_get_header(), timeout=10)
most_active = pd.read_html(StringIO(response.text))[0]

# lower and use underscores for column names
most_active.columns = (
Expand Down Expand Up @@ -341,7 +342,7 @@ def get_summary(self):
}
fred_summary = {}
for key, value in fred_dict.items():
fred_summary[key] = fred.get_series(value)[-1]
fred_summary[key] = fred.get_series(value).iloc[-1]

return fred_summary

Expand Down Expand Up @@ -391,6 +392,7 @@ def get_heatmap_data(self, timeframe="day"):
r = requests.get(
f"https://finviz.com/api/map_perf.ashx?t=sec&st={timeframe_map[timeframe]}",
headers=_get_header(),
timeout=10,
)
r.raise_for_status()

Expand All @@ -402,6 +404,7 @@ def get_heatmap_data(self, timeframe="day"):
r2 = requests.get(
"https://finviz.com/maps/sec.json?rev=316",
headers=_get_header(),
timeout=10,
)
r2.raise_for_status()

Expand Down Expand Up @@ -480,7 +483,7 @@ def insider_activity(self, ticker):
Insider activity data
"""
url = f"https://markets.businessinsider.com/stocks/{ticker.lower()}-stock"
response = requests.get(url, headers=_get_header())
response = requests.get(url, headers=_get_header(), timeout=10)
soup = BeautifulSoup(response.content, "html.parser")

d_insider = dict()
Expand Down

0 comments on commit ddf6e97

Please sign in to comment.