client-python icon indicating copy to clipboard operation
client-python copied to clipboard

When using Python Client and expiration_date_gte, dates that are lt are returned as well

Open AHangstefer opened this issue 3 years ago • 3 comments

Describe the bug When using Python Client and expiration_date_gte, dates that are lt are returned as well

To Reproduce

Query Options Contracts using Python Client options = client.list_options_contracts(underlying_ticker='META', expiration_date_gte='2023-03-16', contract_type='call', strike_price_gte=20)

for p in options:

print(p)

First result: OptionsContract(additional_underlyings=None, cfi='OCASPS', contract_type='call', correction=None, exercise_style='american', expiration_date='2023-02-24', primary_exchange='BATO', shares_per_contract=100, strike_price=20, ticker='O:META230224C00020000', underlying_ticker='META')

Expected behavior Response should only return dates that are greater than or equal to expiration_date_gte

Additional context Works in REST API directly but not when using Python Client

AHangstefer avatar Feb 21 '23 18:02 AHangstefer

Almost certainly the same underlying problem as #382.

If you need an immediate workaround, try manually specifying the expiration_date.gte query param as suggested in my comment (and I suspect you'll need to do the same with strike_price.gte):

options = client.list_options_contracts(
    underlying_ticker="META",
    contract_type="call",
    params={
        "expiration_date.gte": "2023-03-16",
        "strike_price.gte": 20,
    },
)

jakekdodd avatar Feb 21 '23 20:02 jakekdodd

I'm going to close this as a dupe of https://github.com/polygon-io/client-python/issues/382. There is a PR submitted via https://github.com/polygon-io/client-python/pull/389 and we'll hopefully roll out a release shortly.

justinpolygon avatar Feb 23 '23 07:02 justinpolygon

Thank you. This work around sounds great.

alberto33 avatar Feb 23 '23 18:02 alberto33