Using Python with Optuma

Optuma Forums Optuma Scripting Using Python with Optuma

Tagged: 

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #68139
    David
    • Topics: 9
    • Replies: 16
    • Posts: 25

    Hi Optuma support,

    I’m trying to follow the instructions at https://help.optuma.com/kb/faq.php?id=1264 to start using Python for writing Optuma scripts. This looks like a great feature for me as I’ve got a load of Python trading code I’ve developed over many years.

    I’ve got Python 3.10.4 (latest version) installed, and configured into my path. I know that’s working because I can run either ‘py’ or ‘python’ from a command shell.

    Within Optuma, I bring up an empty bar chart, right click on the spanner icon, start typing ‘pyth’… and don’t see the option to select Python:
    Screen Shot 2022-05-08 at 2.18.23 pm

    After installing Python and running into this problem, I’ve tried stop/starting Optuma and rebooting Windows – neither has fixed the problem.

    Have you got any suggestions about what might be wrong with my config?

    Thanks in advance

    #68148
    Matthew
    • Topics: 5
    • Replies: 608
    • Posts: 613

    Hi,

    I’d suggest running Optuma in admin mode so that Python registered with Optuma (sometimes that process needs admin mode to work).

    https://help.optuma.com/kb/faq.php?id=767

    If that does not resolve the issue please contact support for further assistance.

    #68165
    Trevor R
    • Topics: 118
    • Replies: 344
    • Posts: 462

    Hi Matthew,

    I too have Python installed, run Optuma “as Administrator” but Optuma still does not see Python. I been through the Python instal process and set the system path a couple of time, restarting Optuma exch time, but still no joy☹

    Oh well, back to Pascal…

    Cheers

    Trevor

    #68170
    Matthew
    • Topics: 5
    • Replies: 608
    • Posts: 613

    Hi Trevor,

    Do you know what version of Python you are using?  It looks like 3.10 is not compatible with our conversion module at the moment.  We are looking to update that in 2.1, however in the meantime 3.9 should work.

    https://www.python.org/downloads/release/python-3912/

    1 user thanked author for this post.
    #68171
    David
    • Topics: 9
    • Replies: 16
    • Posts: 25

    I can confirm that removing Python 3.10.4, installing Python 3.9.12 and starting Optuma in admin mode fixed the problem for me. Now the walkthrough at https://help.optuma.com/kb/faq.php?id=1264 works for me fine

    That’s using Optuma build 102, which is the latest as I write this.

    #68173
    Trevor R
    • Topics: 118
    • Replies: 344
    • Posts: 462

    Hi Matthew,

    I upgraded to Python 3.10.4 before trying it in Optuma.

    Oh well, looks like I ‘ll have to revert to an earlier version.

    Is there any real benefit in moving from Pascal to Python?

    Cheers

    Trevor

    #68177
    David
    • 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.

    Regards

    Dave M.

    • This reply was modified 1 week ago by David.
    #68213
    Trevor R
    • Topics: 118
    • Replies: 344
    • Posts: 462

    Hi David,

    I learned Pascal too many years ago and so generally find it relatively easy to work with. I did a Python course a while ago out of pure curiosity, but haven’t really done anything with it since. Looks like I might have to get back into it☺

    To the guys at Optuma, might I suggest that a separate Forum be setup for Python coders, rather than getting snakes all twisted and confused with the scripts.

    Cheers

    Trevor

    #68277
    Trevor R
    • Topics: 118
    • Replies: 344
    • Posts: 462

    Hi Matthew,

    I have reverted from Python 3.10.4 (completely removed from computer) to 3.9.12 and still Optuma (Run as Administrator) does not recognize that Python is installed. The Windows 10 environment variable is correctly set.

    I know you suggested raising with Support this issue with running Python in Optuma (2.0 Build 102), but I’ve posted here as well to prompt any others running into the same issue to report it so we all get a fix.

    Cheers

    Trevor

    • This reply was modified 1 week ago by Trevor R.
    #68355
    Ian
    • Topics: 2
    • Replies: 8
    • Posts: 10

    Trevor,
    I have just successfully installed Python 3.9.12 on my laptop, Optuma picked it up straight away in Admin mode. (Same Optuma build)

    On my home PC a different story, 3.10 was installed then uninstalled and 3.9 installed as per the instructions.  Optuma will not pick up this installation. As I don’t know how Optuma detects the Python install i can only assume that remnents of the 3.10 install are left behind, i.e.in the registry.  Mathew may be able to clarify this.

    Ian

    • This reply was modified 1 day ago by Ian Bilney.
    #68365
    Matthew
    • Topics: 5
    • Replies: 608
    • Posts: 613

    Hi Ian,

    Can you send a query to [email protected] so we can check your system setup in more detail.

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

Pin It on Pinterest