Skip to content

Commit 256368a

Browse files
committed
finishing touches
1 parent 6a98b5e commit 256368a

13 files changed

Lines changed: 44 additions & 75 deletions

File tree

openbb_platform/providers/famafrench/openbb_famafrench/apps.json renamed to openbb_platform/providers/famafrench/openbb_famafrench/assets/apps.json

File renamed without changes.

openbb_platform/providers/famafrench/openbb_famafrench/famafrench_router.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ async def factor_choices(
185185
},
186186
),
187187
],
188+
widget_config={
189+
"name": "Fama-French US Portfolio Returns",
190+
},
188191
)
189192
async def us_portfolio_returns(
190193
cc: CommandContext,
@@ -522,6 +525,6 @@ async def famafrench_apps():
522525
import json
523526
from pathlib import Path
524527

525-
_APPS_JSON = Path(__file__).parent / "apps.json"
528+
_APPS_JSON = Path(__file__).parent / "assets" / "apps.json"
526529

527530
return json.loads(_APPS_JSON.read_text(encoding="utf-8"))

openbb_platform/providers/famafrench/openbb_famafrench/models/breakpoints.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Breakpoints Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any
75

@@ -256,7 +254,6 @@ async def aextract_data(
256254
**kwargs: Any,
257255
) -> tuple:
258256
"""Extract data from the Fama-French FTP."""
259-
# pylint: disable=import-outside-toplevel
260257
from openbb_famafrench.utils.helpers import get_breakpoint_data
261258

262259
try:

openbb_platform/providers/famafrench/openbb_famafrench/models/country_portfolio_returns.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Factors Fetcher Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any, Literal
75

@@ -209,7 +207,6 @@ async def aextract_data(
209207
**kwargs: Any,
210208
) -> tuple:
211209
"""Extract data from the Fama-French FTP."""
212-
# pylint: disable=import-outside-toplevel
213210
from openbb_famafrench.utils.helpers import get_international_portfolio # noqa
214211
from warnings import warn
215212

@@ -229,7 +226,7 @@ async def aextract_data(
229226
else query.all_data_items_required
230227
),
231228
)
232-
except Exception as e: # pylint: disable=broad-except
229+
except Exception as e:
233230
raise OpenBBError(e) from e
234231

235232
@staticmethod
@@ -239,7 +236,6 @@ def transform_data(
239236
**kwargs: Any,
240237
) -> AnnotatedResult[list[FamaFrenchCountryPortfolioReturnsData]]:
241238
"""Transform the extracted data."""
242-
# pylint: disable=import-outside-toplevel
243239
from pandas import MultiIndex
244240

245241
dfs, meta = data

openbb_platform/providers/famafrench/openbb_famafrench/models/factors.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Factors Fetcher Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any, Literal
75

@@ -269,7 +267,6 @@ async def aextract_data(
269267
**kwargs: Any,
270268
) -> tuple:
271269
"""Extract the data from the FTP."""
272-
# pylint: disable=import-outside-toplevel, broad-except
273270
from openbb_famafrench.utils.helpers import get_portfolio_data
274271

275272
factors = FACTOR_REGION_MAP.get(query.region, {})
@@ -296,7 +293,6 @@ def transform_data(
296293
**kwargs: Any,
297294
) -> AnnotatedResult[list[FamaFrenchFactorsData]]:
298295
"""Transform the raw data and insert metadata."""
299-
# pylint: disable=import-outside-toplevel
300296
from pandas import to_datetime
301297

302298
table = data[0][0].reset_index()

openbb_platform/providers/famafrench/openbb_famafrench/models/international_index_returns.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Factors Fetcher Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any, Literal
75

@@ -212,7 +210,6 @@ async def aextract_data(
212210
**kwargs: Any,
213211
) -> tuple:
214212
"""Extract data from the Fama-French FTP."""
215-
# pylint: disable=import-outside-toplevel
216213
from openbb_famafrench.utils.helpers import get_international_portfolio # noqa
217214
from warnings import warn
218215

@@ -232,7 +229,7 @@ async def aextract_data(
232229
else query.all_data_items_required
233230
),
234231
)
235-
except Exception as e: # pylint: disable=broad-except
232+
except Exception as e:
236233
raise OpenBBError(e) from e
237234

238235
@staticmethod
@@ -242,7 +239,6 @@ def transform_data(
242239
**kwargs: Any,
243240
) -> AnnotatedResult[list[FamaFrenchInternationalIndexReturnsData]]:
244241
"""Transform the extracted data."""
245-
# pylint: disable=import-outside-toplevel
246242
from pandas import MultiIndex
247243

248244
dfs, meta = data

openbb_platform/providers/famafrench/openbb_famafrench/models/regional_portfolio_returns.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Factors Fetcher Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any, Literal
75

@@ -107,7 +105,6 @@ async def aextract_data(
107105
**kwargs: Any,
108106
) -> tuple:
109107
"""Extract data from the Fama-French FTP."""
110-
# pylint: disable=import-outside-toplevel
111108
from openbb_famafrench.utils.helpers import get_portfolio_data
112109

113110
dataset = ""
@@ -123,7 +120,7 @@ async def aextract_data(
123120
measure=query.measure,
124121
frequency=(None if "daily" in dataset.lower() else query.frequency),
125122
)
126-
except Exception as e: # pylint: disable=broad-except
123+
except Exception as e:
127124
raise OpenBBError(e) from e
128125

129126
@staticmethod

openbb_platform/providers/famafrench/openbb_famafrench/models/us_portfolio_returns.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French Factors Fetcher Model."""
22

3-
# pylint: disable=unused-argument
4-
53
from datetime import date as dateType
64
from typing import Any, Literal
75

@@ -106,7 +104,6 @@ async def aextract_data(
106104
**kwargs: Any,
107105
) -> tuple:
108106
"""Extract data from the Fama-French FTP."""
109-
# pylint: disable=import-outside-toplevel
110107
from openbb_famafrench.utils.helpers import get_portfolio_data
111108

112109
dataset = ""
@@ -126,7 +123,7 @@ async def aextract_data(
126123
else query.frequency
127124
),
128125
)
129-
except Exception as e: # pylint: disable=broad-except
126+
except Exception as e:
130127
raise OpenBBError(e) from e
131128

132129
@staticmethod

openbb_platform/providers/famafrench/openbb_famafrench/utils/constants.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Constants for the Fama French datasets API."""
22

3-
# pylint: disable=too-many-lines
4-
53
from typing import Any, Literal
64

75
BASE_URL = "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/"

openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Fama-French utilities for handling US and International portfolios and factors."""
22

3-
# pylint: disable=R0912,R0913,R0914,R0917,R1702,W0612,W0613
4-
53
from functools import lru_cache
64

75
from openbb_famafrench.utils.constants import (
@@ -152,7 +150,6 @@ def download_file(dataset) -> str:
152150
153151
Note: This function is not intended for direct use, it is called by `get_portfolio_data`.
154152
"""
155-
# pylint: disable=import-outside-toplevel
156153
import zipfile
157154
from io import BytesIO
158155

@@ -200,7 +197,6 @@ def download_international_portfolios(url):
200197
Note: This function is not intended for direct use,
201198
it is called by `get_international_portfolio`.
202199
"""
203-
# pylint: disable=import-outside-toplevel
204200
from openbb_core.provider.utils.helpers import get_requests_session
205201

206202
with get_requests_session() as session:
@@ -212,7 +208,6 @@ def download_international_portfolios(url):
212208

213209
def apply_date(x):
214210
"""Pandas Apply helper to convert various date formats to a standard YYYY-MM-DD format."""
215-
# pylint: disable=import-outside-toplevel
216211
from pandas import to_datetime
217212

218213
date = str(x).replace(" ", "")
@@ -232,7 +227,6 @@ def read_csv_file(data: str):
232227
233228
Note: This function is not intended for direct use, it is called by `get_portfolio_data`.
234229
"""
235-
# pylint: disable=import-outside-toplevel
236230
import re
237231

238232
lines = data.splitlines()
@@ -333,7 +327,6 @@ def process_csv_tables(tables, general_description="") -> tuple:
333327
334328
Note: This function is not intended for direct use, it is called by `get_portfolio_data`.
335329
"""
336-
# pylint: disable=import-outside-toplevel
337330
import warnings # noqa
338331
from pandas import DataFrame
339332

@@ -367,7 +360,7 @@ def process_csv_tables(tables, general_description="") -> tuple:
367360
try:
368361
# Convert YYYYMM format to datetime
369362
df["Date"] = df.Date.apply(apply_date)
370-
except Exception as e: # pylint: disable=W0718
363+
except Exception as e:
371364
warnings.warn(f"Error parsing dates: {e}")
372365
df["Date"] = df["Date"].astype(str)
373366

@@ -403,7 +396,6 @@ def read_dat_file(data: str) -> list:
403396
Note: This function is not intended for direct use,
404397
it is called by `get_international_portfolio`.
405398
"""
406-
# pylint: disable=import-outside-toplevel
407399
import re
408400

409401
lines = data.splitlines()
@@ -524,7 +516,6 @@ def get_international_portfolio_data(
524516
525517
Note: Not intended for direct use, this function is called by `get_international_portfolio`.
526518
"""
527-
# pylint: disable=import-outside-toplevel
528519
import zipfile
529520
from io import BytesIO
530521

@@ -584,7 +575,6 @@ def process_international_portfolio_data(tables: list, dividends: bool = True) -
584575
585576
Note: Not intended for direct use, this function is called by `get_international_portfolio`.
586577
"""
587-
# pylint: disable=import-outside-toplevel
588578
import re # noqa
589579
import warnings
590580
from pandas import DataFrame, MultiIndex
@@ -614,7 +604,7 @@ def process_international_portfolio_data(tables: list, dividends: bool = True) -
614604
# Parse and set Date column
615605
try:
616606
df["Date"] = df["Date"].apply(apply_date)
617-
except Exception as e: # pylint: disable=W0718
607+
except Exception as e:
618608
warnings.warn(f"Error parsing dates. Using string conversion. -> {e}")
619609
df["Date"] = df["Date"].astype(str)
620610

@@ -898,7 +888,6 @@ def get_breakpoint_data(
898888
tuple
899889
A tuple containing a pandas DataFrames a metadata dictionary.
900890
"""
901-
# pylint: disable=import-outside-toplevel
902891
from io import StringIO # noqa
903892
from pandas import offsets, read_csv, to_datetime
904893

0 commit comments

Comments
 (0)