Reply To: Using Python with Optuma

Optuma Forums Optuma Scripting Using Python with Optuma Reply To: Using Python with Optuma

  • Topics: 9
  • Replies: 16
  • Posts: 25

Hi Trevor,

One obvious advantage of Python over Pascal is the cost. Python integration with Optuma costs nothing, vs the Pascal programming module which was several hundred dollars when I bought it (can’t remember the exact price). If the option existed to use Python at the time, I definitely would’ve gone with Python to see what I could do with it before dropping some serious money for Pascal and hoping it would do what I wanted. Pascal has worked out for me fine, but there was definitely a leap of faith involved in buying it.

Python tutorials are everywhere on the Internet. If you want to learn programming from scratch, Python is absolutely one of the best languages to start with because there’s so much good, current material to learn from. Pascal’s popularity really peaked in the pre-Internet 80s, so it’s much harder to track down good training material.

There’s a ton of Python trading code floating around on the Internet. If there’s an indicator you want to build, it’s extremely likely you’ll be able to find Python code to get you a long way there with a Google search.

IDE tool support for Python is way ahead of Pascal. I resurrected my ancient Sublime Text licence, fired it up to edit an Optuma Python script and saw this:
Screen Shot 2022-05-10 at 10.13.32 pm

As you can see, when I type in “Tool.”, Sublime Text is smart enough to realise Tool is a Python classname and it then presents me with a dropdown of all the methods supported by the Tool class. From the above screenshot, you can see that Props, DataOut, RunScript, AddReal, AddList, … are all valid methods I can use. That’s not magic and I didn’t do any config with Sublime Text beyond installing it – this capability has been common in Python-aware IDEs for years. I haven’t been able to find anything comparable for Optuma’s flavour of Pascal, so I’ve settled on a “tolerably bad” option for Pascal editing which is Visual Studio Code plus a few extensions. Using Sublime Text (or VS Code, or a bunch of other free IDEs) with Python is likely to be massively more productive than (anything) with Pascal because the IDE actively helps you write code.

If you want to integrate with e.g. Excel, then Python is a great option with solid libraries to both read from and write to Excel workbooks. I’ve not done that with Python and Optuma, but I’ve written a lot of Python/Excel code in the past. Again there’s plenty of good learning material on the Internet, so you can track down sample Python+Excel code pretty quickly. Same applies to Powerpoint, Word, Outlook, PDFs, email – Python is possibly the best language available for “glueing” applications together.

If you want your Python code to go out to the Internet and retrieve some data (I’m thinking of retrieving contract details such as ticksize and dollars per tick from CME), then the Requests library is the way to go. Tons of sample code out there to learn from. Similar libraries exist for Pascal, but I’m not sure whether it’s possible to install them for use within Optuma.

Python has great support for complex data structures such as sets and dictionaries that Pascal lacks. If you want to deal with large sets of numbers e.g. entire price history of a market, then Python has the numpy and scipy libraries that make it much simpler than anything available in Pascal.

Finally, if you want to go down a certain type of rabbit hole, then Python has the best machine learning libraries available.


Dave M.

  • This reply was modified 1 week ago by David.

Pin It on Pinterest