Getting the market code *inside* a script?

Optuma Forums Optuma Scripting Getting the market code *inside* a script?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #68851
    • Topics: 14
    • Replies: 21
    • Posts: 35

    Hi all,

    I want to implement this sort of logic inside a script, then display the next contract expiry date in a watchlist:

    Hopefully that’s clear enough. Essentially it’s a simple lookup table of contract expiry dates for each of the markets I’m watching. If I don’t have the expiry date for a particular market, then I’ll just return some dummy value for the expiry date

    I’ve found a source of contract expiry date data, but what I don’t know is how to get the code (e.g. MESVolSpot) for the market being processed in the script. I can’t find a function within Optuma that returns the market code for the current market being processed by the script.

    Ideally I’d implement this logic inside a Python script, but I’m happy to use either the built-in Optuma scripting or Pascal if there’s no way to get the market code inside Python.

    Any thoughts on how I can get the current market code from inside a running script?

    Thanks in advance

    • This topic was modified 2 months ago by David.
    • Topics: 5
    • Replies: 631
    • Posts: 636

    Hi David,

    Do you have Pro or Enterprise Services?  If so, the fastest way to achieve the result you’re after is via the EDF system:

    Working with External Data Fields – Part 1

    You can take the file you have with the contract dates / codes and upload it via EDFs.  Those dates can then be referenced in Watchlists and other areas via scripting.

    If you do not have EDFs, you can see an example of Ticker specific scripts on the following thread:

    Sector wise breadth Data in a watch list

    This should give you an example you can build your next contract date references from.

    • Topics: 14
    • Replies: 21
    • Posts: 35

    Closing this one off, here’s a brief example that shows how to retrieve & use the code of a market inside an Optuma script

    This script won’t do anything for markets I haven’t nominated in the first line, and can be used with ShowBar to show contract expiry dates for just those markets. Obviously you can extend this approach further to other use cases.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest