akapur / pyiqfeed

Python LIbrary for reading DTN's IQFeed
GNU General Public License v2.0
168 stars 108 forks source link

Futures Valid month code assert references equity letter map #58

Open kastins opened 1 year ago

kastins commented 1 year ago

Hello, in Conn.py >> function " def request_futures_option_chain" at line 2939 the assert below checks against valid equity month letters and NOT the futures_map, i ran into this issue when requesting options for December "Z"

        if month_codes is not None:
            valid_month_codes = ()
            if opt_type == 'p':
                valid_month_codes = LookupConn.put_month_letters
            elif opt_type == 'c':
                valid_month_codes = LookupConn.call_month_letters
            elif opt_type == 'cp' or opt_type == 'pc':
                valid_month_codes = (
                    LookupConn.call_month_letters +
                    LookupConn.put_month_letters)
            # noinspection PyTypeChecker
            for month_code in month_codes:
                assert month_code in valid_month_codes

i rudimentary changed it to this,

        if month_codes is not None:
            valid_month_codes = LookupConn.futures_month_letters 

            # noinspection PyTypeChecker
            for month_code in month_codes:
                assert month_code in valid_month_codes

Thanks for this great wrapper BTW

akapur commented 1 year ago

Great catch! A pull request would be great.

On Oct 18, 2022, at 6:26 AM, kastins @.***> wrote:

Hello, in Conn.py >> function " def request_futures_option_chain" at line 2939 the assert below checks against valid equity month letters and NOT the futures_map, i ran into this issue when requesting options for December "Z"

    if month_codes is not None:
        valid_month_codes = ()
        if opt_type == 'p':
            valid_month_codes = LookupConn.put_month_letters
        elif opt_type == 'c':
            valid_month_codes = LookupConn.call_month_letters
        elif opt_type == 'cp' or opt_type == 'pc':
            valid_month_codes = (
                LookupConn.call_month_letters +
                LookupConn.put_month_letters)
        # noinspection PyTypeChecker
        for month_code in month_codes:
            assert month_code in valid_month_codes

i rudimentary changed it to this,

    if month_codes is not None:
        valid_month_codes = LookupConn.futures_month_letters 

        # noinspection PyTypeChecker
        for month_code in month_codes:
            assert month_code in valid_month_codes

Thanks for this great wrapper BTW

— Reply to this email directly, view it on GitHub https://github.com/akapur/pyiqfeed/issues/58, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGJAVBWPX6X7BJ6IDJR63LWDZ3N3ANCNFSM6AAAAAARH5WYYE. You are receiving this because you are subscribed to this thread.

kastins commented 1 year ago

OK, bare with me, i'm just trying to understand github and get my head around this forking thing, ill try sort it out within the week. Cheers

akapur commented 10 months ago

1) Could you make sure there are no conflicts. 2) Could you make sure that your pull request still works for instruments other than futures with an if statement.