Optuma Forums › Optuma Scripting › Using Python with Optuma
- This topic has 10 replies, 4 voices, and was last updated 1 year ago by Matthew.
May 8, 2022 at 2:30 pm #68139
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:
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 advanceMay 9, 2022 at 7:57 am #68148
I’d suggest running Optuma in admin mode so that Python registered with Optuma (sometimes that process needs admin mode to work).
If that does not resolve the issue please contact support for further assistance.May 9, 2022 at 9:38 pm #68165
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…
TrevorMay 10, 2022 at 1:39 pm #68170
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.
1 user thanked author for this post.May 10, 2022 at 4:21 pm #68171
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.May 10, 2022 at 5:48 pm #68173
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?
TrevorMay 10, 2022 at 10:47 pm #68177
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:
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.
May 11, 2022 at 9:02 pm #68213
- This reply was modified 1 year ago by 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.
TrevorMay 15, 2022 at 2:02 pm #68277
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.
May 23, 2022 at 7:54 pm #68355Ian
- This reply was modified 1 year ago by Trevor R.
- Topics: 2
- Replies: 8
- Posts: 10
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.
May 24, 2022 at 3:20 pm #68365
- This reply was modified 1 year ago by Ian Bilney.
Can you send a query to [email protected] so we can check your system setup in more detail.
- You must be logged in to reply to this topic.