@@ -1099,8 +1099,14 @@ def _download_data_osap(
10991099 Downloads the data from the Open Source Asset Pricing project at
11001100 https://www.openassetpricing.com/data/ from Google Sheets using a
11011101 specified sheet ID, processes the data by converting column names
1102- to snake_case, and optionally filters the data based on a provided
1103- date range.
1102+ to snake_case, aligning the date to the beginning of the month,
1103+ scaling the percentage long-short returns to numeric values, and
1104+ optionally filters the data based on a provided date range.
1105+
1106+ The dataset contains monthly long-short returns of the predictor
1107+ portfolios. Every column other than ``date`` is a return expressed
1108+ in percent, so all of them are divided by 100 to convert them into
1109+ plain numeric (decimal) returns.
11041110
11051111 Parameters
11061112 ----------
@@ -1121,9 +1127,11 @@ def _download_data_osap(
11211127 -------
11221128 pd.DataFrame
11231129 A data frame containing the processed data. The column names
1124- are converted to snake_case, and the data is filtered by the
1125- specified date range if 'start_date' and 'end_date' are
1126- provided.
1130+ are converted to snake_case, the ``date`` column is aligned to
1131+ the beginning of the month, all predictor columns (long-short
1132+ returns in percent) are divided by 100 to obtain plain numeric
1133+ (decimal) returns, and the data is filtered by the specified
1134+ date range if 'start_date' and 'end_date' are provided.
11271135
11281136 Examples
11291137 --------
@@ -1158,12 +1166,21 @@ def _download_data_osap(
11581166 return raw_data
11591167
11601168 if "date" in raw_data .columns :
1161- raw_data ["date" ] = pd .to_datetime (raw_data ["date" ], errors = "coerce" )
1169+ raw_data ["date" ] = (
1170+ pd .to_datetime (raw_data ["date" ], errors = "coerce" )
1171+ .dt .to_period ("M" )
1172+ .dt .start_time
1173+ )
11621174
11631175 raw_data .columns = [
11641176 _transfrom_to_snake_case (col ) for col in raw_data .columns
11651177 ]
11661178
1179+ # All columns except the date are long-short returns in percent, so
1180+ # scale them to plain numeric (decimal) returns.
1181+ return_columns = [col for col in raw_data .columns if col != "date" ]
1182+ raw_data [return_columns ] = raw_data [return_columns ] / 100
1183+
11671184 if start_date and end_date :
11681185 raw_data = raw_data .query ("@start_date <= date <= @end_date" )
11691186
0 commit comments