Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/robcarver17/pysystemtrade
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
rob committed Jul 17, 2023
2 parents 4fab072 + 387220d commit 514add4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions syscore/pandas/merge_data_keeping_past_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class mergeStatus(Enum):
NO_MERGE_DATE = named_object("No data")


class mergeError(Exception):
pass


class mergingDataWithStatus(object):
def __init__(
self,
Expand Down
5 changes: 2 additions & 3 deletions sysdata/futures/futures_per_contract_prices.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from syscore.exceptions import missingData
from syscore.constants import failure
from syscore.dateutils import Frequency, MIXED_FREQ
from syscore.pandas.merge_data_keeping_past_data import SPIKE_IN_DATA
from syscore.pandas.merge_data_keeping_past_data import SPIKE_IN_DATA, mergeError

from sysdata.base_data import baseData

Expand Down Expand Up @@ -383,7 +382,7 @@ def update_prices_at_frequency_for_contract(

if rows_added < 0:
new_log.critical("Can't remove prices something gone wrong!")
return failure
raise mergeError("Merged prices have fewer rows than old prices!")

elif rows_added == 0:
if len(old_prices) == 0:
Expand Down
24 changes: 12 additions & 12 deletions sysproduction/update_historical_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from syscore.constants import arg_not_supplied, success, failure
from syscore.exceptions import missingData
from syscore.pandas.merge_data_keeping_past_data import SPIKE_IN_DATA
from syscore.pandas.merge_data_keeping_past_data import SPIKE_IN_DATA, mergeError
from syscore.dateutils import DAILY_PRICE_FREQ, Frequency
from syscore.pandas.frequency import merge_data_with_different_freq

Expand Down Expand Up @@ -432,22 +432,22 @@ def price_updating_or_errors(

price_updater = updatePrices(data)

error_or_rows_added = price_updater.update_prices_at_frequency_for_contract(
contract_object=contract_object,
new_prices=new_prices_checked,
frequency=frequency,
check_for_spike=check_for_spike,
max_price_spike=cleaning_config.max_price_spike,
)
try:
error_or_rows_added = price_updater.update_prices_at_frequency_for_contract(
contract_object=contract_object,
new_prices=new_prices_checked,
frequency=frequency,
check_for_spike=check_for_spike,
max_price_spike=cleaning_config.max_price_spike,
)
except mergeError:
data.log.warning("Something went wrong when adding rows")
return failure

if error_or_rows_added is SPIKE_IN_DATA:
report_price_spike(data, contract_object)
return failure

if error_or_rows_added is failure:
data.log.warning("Something went wrong when adding rows")
return failure

return error_or_rows_added


Expand Down

0 comments on commit 514add4

Please sign in to comment.