request expired commodity futures with get_data

The chain ric 0#ATW: provides all futures that haven't expired yet, starting with ATWMJ0 which is still tradable.

I can't seem to find expired futures anywhere, e.g. for the previous month, it should be ATWMH0 but this ric doesn't seem to exist.

How to download e.g. a price history of settlements of already expired futures?

Thanks


Best Answer

  • m.bunkowski
    Answer ✓

    Hi @arndf

    You need to modify your RIC a bit to get the expired RIC.
    Assuming you wish to retrieve the March 2020 data, the RIC would begin as normal, (ATWMH0) RIC Root + Month Code + Last digit of year, then add a "^" followed by the decade of the Expiry of the contract --> ATWMH0^2.

    df,err= ek.get_data('ATWMH0^2', ['TR.SETTLEMENTPRICE.date','TR.SETTLEMENTPRICE'], {'SDate':'-5M', 'EDate':'0D'})
    df


Answers