python gui programming

jim leahy

Active member
i started learning python last year and as a script language it's pretty powerful, but i'm
used to gui programming in java. i looked at tkinter and it is ok but very tedious. are there other
python programmers in this forum? what gui packages are you using? i need a gui editor like
what's available in java and android.
 
I haven't seen any ... but I imagine there might be there. I believe there are application interface building tools that you can reference in the python code, sort of like HTML elements when building a web page.
 
Unfortunately I cant answer with experience as I've never found time to deep dive in into this topic.
I suppose you did your search and I dont have to mention QT and others with all pros and cons.
In on my radar are two position for future investigation: Dash and Justpy.
For now Im fine with widgets and Plotly in Jupyter - they provide sufficient level of interaction for my needs.
Good luck.
I'll be happy to hear about your findings.
 
Last edited:
I am unaware of any, but am new to Python myself. However I do believe there is a great deal of interest for this.
If you discover something you think has "legs", please post to give others a heads-up!

BTW: If you have and like java for GUI, is there not a way to have your cake and eat it too? by allowing your Py to control/interact with java?
Have you looked at gnuplot? -- It has some decent graphing which I drive from Perl. I have not tried it with Python yet.
 
thanks for the inputs, guys.
QT looks interesting but it seems like a very steep learning curve for my purposes.
also, i have a lot of reservations about cross-platform development. dash is more for web development and
i already invested a lot of time on a different web development approach. as primitive as it is, tkinter seems
usable for simple gui python applications. the others that work similarly, kivy and wxpython aren't any better,
in my opinion. i'm not planning on a lot of gui python development. it has its uses, and i may change my mind
on that, but i'll likely focus on tkinter for the time being.

gary, yes, i use gnuplot for the surface plots in my options tools. it's very easy to use. as far as using it with python,
matplotlib has very good graphing capabilities so i don't use gnuplot with python.

integrating python with java has possibilities. python has a lot of good statistical packages i couldn't find
in java. also i'm looking into integrating python with javascript for server-side development. i currently use
php.
 
Jim, I have similar reservations about available GUI. As you I was leaning toward tkinter but eventually decided not to spend time on it. Justpy also looks interesting. Of course one has to make his own decision based on needs. I code for myself, mostly for trading, so I'm kind ok messing with code.
Some day I would like to see what you are working on re trading. Just curious.
 
marcas, i posted a very early version of my python script in the pairs trading forum. i've added more
features and that version used msn for a data source, but they stopped providing data with that url
and i haven't been able to make the new url work for me. i've switched data providers in my new version.
my other programs don't use python.

if you're contemplating moving to the web, you should consider what you eventually want to do with
your programs. if you only want to do it for your own use then any web development method would
work. if you want to make it available publicly, you should consider whether that approach will be supported
on web hosts. i have web sites using google's free web hosting, and there are several other
companies that provide free web hosting. the restriction with these are you can't run server-side code.
if you need to run server-side you have to pay, or you can do your own (which is more difficult than it should
be thanks to threat protection).
 
alpaca is a trading api for algorithmic traders. i'm not running any algorithms. i'm just using
a python script statistical calculations for pairs trading. my main trading is options. i just thought
pairs trading was an interesting diversion.
 
i started learning python last year and as a script language it's pretty powerful, but i'm
used to gui programming in java. i looked at tkinter and it is ok but very tedious. are there other
python programmers in this forum? what gui packages are you using? i need a gui editor like
what's available in java and android.

Tkinter is far too simplistic. Although it ships with every Python distribution, it is insufficient for serious desktop applications beyond calculators. It was designed to compete with Java Applets, which died in the early 2000s. Since then there are MANY GUI toolkits and builders available.

There are about 5 different major cross-platform Python toolkits, e.g., PyQt, WxPython, VTK, Traits, Pyside, PySimpleGUI,PyForms, and many others.

The problem with most is that they are academic or open source projects with poor to no support, no commercial vendors, or no funding to keep them alive and evolving. I researched the usage, communities using them, and the support available for each. Very time consuming. But if I am going to build an application and maintain it, I want to have the best support available.

The cleanest approach I have worked with is PyQt, because it is a Python wrapper around the high-performance, cross-platform Qt C++ toolkits that are commercially supported for industrial device interfaces (think automobile diagnostic software, robotics controllers, scientific instrument controllers, and general purpose high-performance scientific programming) that need the speed and robustness of C++. But you don't have to TOUCH C++ or the native windowing toolkits to use Qt, because the Python wrappers around Qt are clean and comprehensive.

What about GUI Design tools?

PyQt Designer is a standalone GUI layout tool that is well-supported. It includes a reliable code generator that generates pretty efficient code. You simply layout your application window, graphically and then generate code. You insert your program functions in the "put your code here" stubs for the buttons, menus, and other active interface objects, and hook up your events. PyQt Designer has a complete API wrapper library around the Qt C++ classes and objects supports all the Qt GUIs classes.

You can code your GUI apps from scratch using the APIs or use PyQt Designer to get started.



"Create GUI Applications with Python and PyQt5 Designer" is a good book and there is a good video course that goes along with it.

Here's a place to get some of the book for free.
https://leanpub.com/create-simple-gui-applications/read#leanpub-auto-updating-the-display

Here's a large playlist for many step-by-step tutorials on Python GUIs using PyQt library.

https://www.youtube.com/playlist?list=PL1FgJUcJJ03uO70zDLDF3oaTu6s2QLOPa


Connect with me and we can discuss applications for options analytics tools.
 
Here's a few more tutorials.

PyQt5 tutorial - Learn how you can create a Python GUI in 2020
https://build-system.fman.io/pyqt5-tutorial

PyQt5 tutorial - last modified July 16, 2020
http://zetcode.com/gui/pyqt5/

Zetcode.com has a bunch more Python (and other languages) tutorials
http://zetcode.com/


And for completeness:
https://wiki.python.org/moin/PyQt/Tutorials
 
Rich, there is plenty of info you provided. Wonder if you use QT in your coding practice?
I, of course, checked out QT but saying truth it was bit to much for my needs. At some point I had to answer myself question, if I want to be a coder or trader... amount of time needed to only get familiar with many aspects of coding was humongous...
As I remember I also didn't like licensing of QT but it could change since it was a while ago I was looking.

I skimmed through some material you linked and must admit that it is much better quality then when I was researching.
I will look up what QT can do and re-evaluate.
Thanks a lot for info.

One q:
Can you tell if I can use interactive Plotly graphs (html) in QT windows without much gymnastics?
 
Hi Marcas,

I saw your discussion on the trading group video about TOS P&L and am interested in the tool you were using.

also, do you have any experience linking data from TOS to excel dynamically? I know how to copy & paste, but I’m looking for more of an API kind of link that I can use for making decisions in some of my trades like the boxcar, based on specific trading rules.

I would also be interested in learning other things you have come up with to help automate the trade management process.


thanks,

Steve
[email protected]
 
Hi Steve,
I use this tool extensively. Well, maybe not exactly what I've shown. This was one of the first versions of the code. Today I use L8 - eighth's version of that program that better covers my needs, and I am still not done with it. My approach is that rather than putting new ideas in, I try to add only features I'm missing in my daily trading, so it is much custom made.

Initially I posted code and instructions in old CapitalDiscussion Slack. Code works but is rough and is not a nice piece of work. This was deliberate as the main goal was to start cooperation of interested people. It didn't materialize though.
Lately Gary re-posted it here, on Aero-Forum somewhere.
Here are direct links to originals:
capitaldiscussions.slack.com/archives/C7GKD6HPH/p1545873987044500
capitaldiscussions.slack.com/archives/C87KBCZFA/p1545877138011300
(It was sooo long time ago....)

I have very little experience with Excel. I use Python almost exclusively. If you are just starting your adventure with coding for trading I recommend Py over Excel for many, many reasons. I know that Excel may look more familiar and easier but you have to learn VBA to do more cool stuff so... go Py. :)
Unless of course there are other reasons to choose Excel (or other computer language).
If you want somebody to help you with spreadsheet - bug Gary, he uses it every day, you can bug me for Py, I can answer simple questions.

Here is link that explains basics of how to dynamically link TOS to Excell using RTD technology (for Windows only):
www.lockeinyoursuccess.com/connecting-thinkorswim-to-excel-part-1-of-4/

My tools are useful, although really nothing special, but are all 'custom made". They are designed to overcome shortcomings of TOS and other software and most important of all, to save time. I encourage trades, if they can, to learn coding so they don't have to relay on others and can design exactly what they need. I noticed that using specific tool, to be Thinkorswim or ONE, channels your thinking process into one direction, leaving broad field of trading knowledge out of your reach. That is if you base your trading only on what those programs, good in itself, I don't criticize them here, offer.
On the other hand, if you know exactly what you need you can go shopping for platform that does exactly what you want, without need for writing single line of code.
 
Last edited:
Hi Marcas,

I saw your discussion on the trading group video about TOS P&L and am interested in the tool you were using.

also, do you have any experience linking data from TOS to excel dynamically? I know how to copy & paste, but I’m looking for more of an API kind of link that I can use for making decisions in some of my trades like the boxcar, based on specific trading rules.

I would also be interested in learning other things you have come up with to help automate the trade management process.


thanks,

Steve
[email protected]
@Steve: If you have access to the TDA-API, there is a more reliable (simpler for no-touch) process than using RTD you may want to consider.
The only linkage between TOS and excel is RTD. There is much you can do with this. If you code, you can write code to dynamically build and administer spreadsheets if you prefer no-touch operations <-- This process, however can get fairly complex if you need no-touch operation,. The TDA-API approach is preferred for no-touch. I do both, but if starting from scratch would use the TDA-API. (Crossing my fingers that Schwab does not terminate the TDA-API as well as TOS and the related RTD)
 
Thank you both for your replies.

I am not trying to reinvent the wheel and my only reason for choosing Excel is because I know it and it would offer a dashboard so to speak for viewing the components of my trades. However, I have spent a little time learning Python as well, but I didn't think about using it because of lack of a dashboard view per se. Marcas your video presentation caught my eye as yet another way to use Python. I am currently trading with TOS and I also use ONE. What I have been thinking of is to have a single view that is updated by current prices where I can see things happening in real time such as when a trade breaks even (I.e. when the credit spreads coverage of the debit spread has been offset by the debit spread now being out of the money, or not under the tent). I can see those things visually in ONE where it tells me what the potential gain is and looking at the T+ lines. I can put on or take off a trade theoretically, and then go up to the commit button to see what the credit or debit might be based on it's live feed from TOS. I can see what my cost is for the entire trade, but not necessarily just the cost for a specific component of a trade. Right now for example, I am trading the Boxcar strategy which is comprised of a PCS & PDS. Based on Dan & Amy's guidelines, there are certain requirements that the PCS & PDS should meet both putting on and taking off the trade. These can be somewhat mechanical types of decisions which could be laid out in an excel spreadsheet. Then there is the occasional addition of a calendar spread to provide additional theta for the trade, etc. I typically manage these trades by treating the PDS, PCS & Calendars as individual components of the overall trade, not just looking at P&L for the condor (or in ONE which has the P&L for everything). Often times, I will just take off the PDS and let the PCS expire for full credit. Sometimes I will put on the PDS first to get a better price before the underlying starts moving back down which provides more credit. The other day, I did this and before I could even put on the PCS, I ended up day trading the PDS for a quick $400 profit and then started back again to build the condor.

Sorry for rambling, but I say all this because I have in my mind an idea of setting up these trades inside a dashboard of sorts where I can glance at the numbers, know what my P&L is, when the mechanics require me to adjust or abandon certain components, etc. instead of looking at ONE or TOS to try and figure these things out. I should probably become more of an expert in these tools and maybe if you all have any suggestions about best practices for workflow, I am all ears.

Thanks
 
sg, this is off topic, but i do exactly what you're doing in excel, using rtd. without vba you would have to do
some manual entry, but not a lot. if you want help with the formulas for creating the opra codes or the
p/l for credit or debit spreads i can show you what i'm using, but open a different topic than python guis.
 
Jim, you aren't off-topic', you are spot on. I do recommend Py but I don't despise other methods. Language and methodology are secondary to ideas, and SG presented ideas worth pursuing. One questions lead to others and if you are able to satisfactory answer them soon your knowledge will boos up. Same with improving capabilities of various platforms, adjusting them to specific needs to make life easier. The hard part is to open the gate. Danger here is desire do do everything perfect, up to single graph line and formatting of output text, those are important things but may suck out energy and enthusiasm from you.
If you gents, or anybody else, wish to cooperate a bit, I suggest Slack - opening new workgroup or using any existing one - it is easier this way, imo, but it's up to you. I expect more traders would be interested in this, especially if you are talking Excel.
 
I would be interested in the Excel version programing but only if it's here to keep it in one place
From what I have seen on Slack there is a lot of back and forth talking sometimes with no topic or going from one topic to another
meanwhile the main topic gets lost somwhere in the conversation
 
marcas, i'm in favor of sharing code and ideas. i find slack a little more inconvenient than this forum but i can
deal with it. i can't share my programs, for various reasons, but i have a few public web sites with some graphing
tools that anyone can use and i will share some code. most of what i do is java, javascript or vb. i have some
python code but not a lot, so far.

status1, there's another forum here called trading with microsoft excel. i haven't read many of the posts
but you might find help there.
 
Top
Contact Us