Skip to content

Commit

Permalink
Merge pull request #74 from QuantConnect/bug-bulk-subscription-equiti…
Browse files Browse the repository at this point in the history
…es-master

Check for bulk security master product id
  • Loading branch information
Martin-Molinero authored Mar 9, 2022
2 parents 4bef6e6 + fa58450 commit 421142c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lean/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@
# The interval in hours at which the CLI checks for new announcements
UPDATE_CHECK_INTERVAL_ANNOUNCEMENTS = 24

# The product id of the Security Master subscription
SECURITY_MASTER_PRODUCT_ID = 37
# The product id of the Equity Security Master subscription
EQUITY_SECURITY_MASTER_PRODUCT_ID = 37

# The product id of the Equity Bulk Security Master subscription
BULK_EQUITY_SECURITY_MASTER_PRODUCT_ID = 180

# The product id of the Terminal Link module
TERMINAL_LINK_PRODUCT_ID = 44
Expand Down
10 changes: 8 additions & 2 deletions lean/models/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from rich.table import Table
from rich.text import Text

from lean.constants import SECURITY_MASTER_PRODUCT_ID
from lean.constants import EQUITY_SECURITY_MASTER_PRODUCT_ID, BULK_EQUITY_SECURITY_MASTER_PRODUCT_ID
from lean.models.pydantic import WrappedBaseModel


Expand Down Expand Up @@ -391,11 +391,17 @@ def has_security_master_subscription(self) -> bool:
:return: True if the organization has a Security Master subscription, False if not
"""

# TODO: This sort of hardcoded product ID checking is not sufficient when we consider
# multiple 'Security Master' products. Especially since they will be specific to certain datasources.
# For now, simple checks for an equity "Security Master" subscription
# Issue created here: https://github.com/QuantConnect/lean-cli/issues/73

data_products_product = next((x for x in self.products if x.name == "Data"), None)
if data_products_product is None:
return False

return any(x.productId == SECURITY_MASTER_PRODUCT_ID for x in data_products_product.items)
return any(x.productId in {EQUITY_SECURITY_MASTER_PRODUCT_ID, BULK_EQUITY_SECURITY_MASTER_PRODUCT_ID} for x in data_products_product.items)


class QCMinimalOrganization(WrappedBaseModel):
Expand Down

0 comments on commit 421142c

Please sign in to comment.