Skip to content

Commit

Permalink
Only manually aggregate for "coming soon" symbols (#17)
Browse files Browse the repository at this point in the history
* fix this bug

* pre-commit

* bump version

---------

Co-authored-by: Jayant Krishnamurthy <[email protected]>
  • Loading branch information
jayantk and Jayant Krishnamurthy authored Apr 6, 2023
1 parent 9068383 commit 7410bfd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion example_publisher/providers/pyth_replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

UnixTimestamp = int

# Any feed with >= this number of min publishers is considered "coming soon".
COMING_SOON_MIN_PUB_THRESHOLD = 10


class PythReplicator(Provider):
def __init__(self, config: PythReplicatorConfig) -> None:
Expand Down Expand Up @@ -55,11 +58,18 @@ async def _update_loop(self) -> None:
update.aggregate_price_confidence_interval,
update.timestamp,
]
elif self._config.manual_agg_enabled:
elif (
self._config.manual_agg_enabled
and update.min_publishers >= COMING_SOON_MIN_PUB_THRESHOLD
):
# Do the manual aggregation based on the recent active publishers
# and their confidence intervals if possible. This will allow us to
# get an aggregate if there are some active publishers but they are
# not enough to reach the min_publishers threshold.
#
# Note that we only manually aggregate for feeds that are coming soon. Some feeds should go
# offline outside of market hours (e.g., Equities, Metals). Manually aggregating for these feeds
# can cause them to come online at unexpected times if a single data provider publishes at that time.
prices = []

current_slot = update.slot
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "example-publisher"
version = "1.0.0"
version = "1.0.1"
description = ""
authors = []
license = "Apache-2"
Expand Down

0 comments on commit 7410bfd

Please sign in to comment.