Skip to content

Commit

Permalink
Fixed removed_markets_addback function in duplicate_remove_markets.py
Browse files Browse the repository at this point in the history
removed_markets_addback function would return the markets which are currently
configured as bad markets but no longer flagged as bad markets to trade.
This change additionally removes the markets which are configured as
ignored_instruments or stale_instruments.
  • Loading branch information
Vishal Grover committed Oct 25, 2024
1 parent dbbc547 commit 1a54915
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions sysproduction/reporting/data/duplicate_remove_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RemoveMarketData:
auto_parameters: parametersForAutoPopulation

existing_bad_markets: list
exclude_markets: list

@property
def str_existing_markets_to_remove(self) -> str:
Expand Down Expand Up @@ -118,12 +119,14 @@ def recommended_list_of_bad_markets(self):

def removed_markets_addback(self) -> list:
existing_bad_markets = self.existing_bad_markets
exclude_markets = self.exclude_markets

## To be allowed to trade an existing bad market must be well above the threshold for not being a bad market
bad_markets = self.bad_markets(apply_higher_threshold=True)

# Markets to be added back = (existing bad markets - new bad markets) - (ignored and stale instruments)
removed_bad_markets = list(
set(existing_bad_markets).difference(set(bad_markets))
set(existing_bad_markets).difference(set(bad_markets)).difference(set(exclude_markets))
)

return removed_bad_markets
Expand Down Expand Up @@ -327,6 +330,7 @@ def get_remove_market_data(data) -> RemoveMarketData:
min_volume_contracts=min_volume_contracts,
existing_bad_markets=existing_bad_markets,
auto_parameters=auto_parameters,
exclude_markets=exclude_instruments
)


Expand Down Expand Up @@ -426,13 +430,6 @@ def get_stale_instruments(data) -> list:
return stale_instruments


def get_ignored_instruments(data) -> list:
production_config = data.config
ignored_instruments = get_list_of_ignored_instruments_in_config(production_config)

return ignored_instruments


def get_list_of_bad_markets(data):
production_config = data.config
bad_markets = get_list_of_bad_instruments_in_config(production_config)
Expand Down

0 comments on commit 1a54915

Please sign in to comment.