Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo_scripts/common/timeseries_analysis_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _single_series_usage(data_provider):
def _dataframe_usage(data_provider):
df = data_provider.get_price(
tickers=many_tickers, fields=PriceField.Close, start_date=start_date, end_date=end_date)
df.fillna(method='ffill', inplace=True)
df.ffill(inplace=True)
print(TimeseriesAnalysis.table_for_df(df))
return df

Expand Down
2 changes: 1 addition & 1 deletion qf_lib/analysis/common/abstract_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def volatility(window):
def _get_rolling_chart(self, timeseries_list, rolling_function, function_name):
freq = timeseries_list[0].get_frequency()
timeseries_list = [tms.dropna().to_prices(1) for tms in timeseries_list]
df = pd.concat(timeseries_list, axis=1).fillna(method='ffill')
df = pd.concat(timeseries_list, axis=1).ffill()

rolling_window_len = int(freq.value / 2) # 6M rolling
step = round(freq.value / 6) # 2M shift
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/analysis/rolling_analysis/rolling_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def calculate_analysis(cls, strategy_tms: QFSeries, benchmark_tms: QFSeries):
benchmark_name = benchmark_tms.name
df[strategy_name] = strategy_tms.to_prices()
df[benchmark_name] = benchmark_tms.to_prices()
df.fillna(method='ffill', inplace=True)
df.ffill(inplace=True)

for window_info in windows:
window = window_info[0]
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/analysis/tearsheets/portfolio_analysis_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def _performance_series_for_ticker(self, df: QFDataFrame):

pnl_series = QFSeries(
data=closed_positions_pnl["Realised PnL"] + open_positions_pnl['Total PnL of open position'],
index=time_index).fillna(method='ffill').fillna(0.0)
index=time_index).ffill().fillna(0.0)
return_data[title] = pnl_series

return return_data
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/analysis/trade_analysis/trades_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_trades_from_transactions(self, transactions: Sequence, portfolio_valu
transactions_df.loc[new_positions_beginning, "position start"] = transactions_df.loc[
new_positions_beginning].index
transactions_df.loc[:, "position start"] = transactions_df.groupby(by="ticker", group_keys=False)[
"position start"].apply(lambda tms: tms.fillna(method="ffill"))
"position start"].apply(lambda tms: tms.ffill())

trades_series = transactions_df.groupby(by="position start", group_keys=False)["transaction"].apply(
lambda t: self._parse_position(t, portfolio_values))
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/backtesting/alpha_model/futures_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _compute_aggregated_volume(self, ticker: FutureTicker, start_date: datetime,
def compute_atr(self, prices_df: PricesDataFrame):
try:
prices_df = prices_df[[PriceField.Close, PriceField.Open, PriceField.High, PriceField.Low]]
prices_df = prices_df.dropna(how='all').fillna(method='ffill').dropna()
prices_df = prices_df.dropna(how='all').ffill().dropna()
# Compute the ATR
atr_values = average_true_range(prices_df.iloc[-self.num_of_bars_atr:], normalized=True)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/common/utils/returns/convert_dataframe_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def convert_dataframe_frequency(dataframe: QFDataFrame, frequency: Frequency) ->
if frequency == Frequency.DAILY:
return dataframe.to_simple_returns()

filled_df = dataframe.to_prices().fillna(method="ffill")
filled_df = dataframe.to_prices().ffill()
new_columns = {}
for column in filled_df:
new_columns[column] = get_aggregate_returns(filled_df[column], frequency)
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/indicators/market_stress_indicator_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_indicator(self, years_rolling: float, start_date: datetime, end_date: da
"""
underlying_start_date = start_date - timedelta(days=floor(years_rolling * 365 * 1.1))
data = self.data_provider.get_price(self.tickers, PriceField.Close, underlying_start_date, end_date)
data = data.fillna(method='ffill')
data = data.ffill()
# data = data.dropna() # this line can be enabled but it will shift starting point by the years_rolling

window_size = floor(252 * years_rolling)
Expand Down
2 changes: 1 addition & 1 deletion qf_lib/tests/manual_tests/futures_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def calculate_exposure(self, ticker: FutureTicker, current_exposure: Exposure, c
# Get the data frame containing High, Low, Close prices
data_frame = self.futures_chain.get_price([PriceField.High, PriceField.Low, PriceField.Close], start_time,
current_time)
data_frame = data_frame.dropna(how='all').fillna(method='pad')
data_frame = data_frame.dropna(how='all').ffill()

close_tms = data_frame[PriceField.Close]
close_tms = close_tms.iloc[-self.slow_time_period:]
Expand Down