Skip to content

Commit

Permalink
Merge pull request #1481 from bug-or-feature/feature_1463_pandas_futu…
Browse files Browse the repository at this point in the history
…re_warnings

fix more pandas future warnings
  • Loading branch information
bug-or-feature authored Jan 15, 2025
2 parents 9969fdb + cafa0b9 commit 1e30053
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion syscore/pandas/frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def merge_data_with_different_freq(
dtype: int64
"""

list_as_concat_pd = pd.concat(list_of_data, axis=0) # TODO 1463
list_as_concat_pd = pd.concat(list_of_data, axis=0)
sorted_pd = list_as_concat_pd.sort_index()
unique_pd = uniquets(sorted_pd)

Expand Down
14 changes: 7 additions & 7 deletions sysdata/production/capital.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ def update_capital_value_for_strategy(
if date is arg_not_supplied:
date = datetime.datetime.now()

new_capital_item = pd.Series([new_capital_value], [date])

try:
capital_df = self.get_capital_pd_df_for_strategy(strategy_name)
except missingData:
capital_series = pd.Series(dtype=float)
capital_series = new_capital_item
else:
capital_series = df_to_series(capital_df)

new_capital_item = pd.Series([new_capital_value], [date])
updated_capital_series = pd.concat([capital_series, new_capital_item], axis=0)
updated_capital_df = updated_capital_series.to_frame()
capital_series = pd.concat(
[df_to_series(capital_df), new_capital_item], axis=0
)

self.update_capital_pd_df_for_strategy(strategy_name, updated_capital_df)
self.update_capital_pd_df_for_strategy(strategy_name, capital_series.to_frame())

def delete_recent_capital_for_strategy(
self, strategy_name: str, last_date: datetime.datetime
Expand Down
11 changes: 6 additions & 5 deletions sysdata/production/margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def final_value(self) -> float:
raise missingData
return self.values[-1]

def add_value(self, value: float, dateref=datetime.datetime.now()):
return seriesOfMargin(self._append(pd.Series([value], index=[dateref])))


class marginData(object):
def get_series_of_total_margin(self) -> seriesOfMargin:
Expand Down Expand Up @@ -48,10 +45,14 @@ def get_current_strategy_margin(self, strategy_name: str) -> float:
return series_of_margin.final_value()

def add_strategy_margin_entry(self, margin_entry: float, strategy_name: str):
new_val = pd.Series([margin_entry], index=[datetime.datetime.now()])
existing_series = self.get_series_of_strategy_margin(strategy_name)
new_series = existing_series.add_value(margin_entry)
if existing_series.empty:
new_series = new_val
else:
new_series = pd.concat([existing_series, new_val])
self._write_series_of_strategy_margin(
strategy_name, series_of_margin=new_series
strategy_name, series_of_margin=seriesOfMargin(new_series)
)

def get_series_of_strategy_margin(self, strategy_name: str) -> seriesOfMargin:
Expand Down
2 changes: 1 addition & 1 deletion sysobjects/adjusted_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _calc_new_multiple_prices(

last_contract_in_price_data = prices_in_multiple_prices[price_contract_column][
:last_date_in_current_adj
][-1]
].iloc[-1]

new_multiple_price_data = prices_in_multiple_prices.prices_after_date(
last_date_in_current_adj
Expand Down
9 changes: 5 additions & 4 deletions sysproduction/update_historical_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,14 @@ def write_merged_prices_for_contract(
diag_prices = diagPrices(data)
price_updater = updatePrices(data)

list_of_data = [
diag_prices.get_prices_at_frequency_for_contract_object(
list_of_data = []
for frequency in list_of_frequencies:
prices = diag_prices.get_prices_at_frequency_for_contract_object(
contract_object,
frequency=frequency,
)
for frequency in list_of_frequencies
]
if len(prices) > 0:
list_of_data.append(prices)

merged_prices = merge_data_with_different_freq(list_of_data)

Expand Down
2 changes: 1 addition & 1 deletion sysquant/estimators/forecast_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def forecast_scalar(
scaling_factor = target_abs_forecast / avg_abs_value

if backfill:
scaling_factor = scaling_factor.fillna(method="bfill")
scaling_factor = scaling_factor.bfill()

return scaling_factor

0 comments on commit 1e30053

Please sign in to comment.