Simple starter Python programming or something off the shelf?

Discussion in 'Automated Trading' started by yosuji198, Feb 24, 2020.

  1. yosuji198

    yosuji198

    Hi Community,

    I am an expert options trader with only basic programming experience (in VBA). I want to build simple code for IB TWS where I can program in the next trade to execute. I am not looking for a whole decision tree that's automated, I myself can type in the code for what I want the next trade to look like. As I get more comfortable I could then further engineer it.

    I'm hoping for code that can:
    1. When X stock hits $X price, enter a combination options order...
    2. Combination order is buy/sell X, Y, Z combination of strike prices...
    3. The limit price of this combination order is -> start at ask and move quickly down for sell order or start at bid and move swiftly up for buy orders, until order filled or cancelled
    4. Log that order was filled

    I don't know anything about libraries or other things people are talking about on here but I can learn if need be. I would like to ask community:
    • Is Python the easiest language to build this program in?
    • Is there any publicly available free code that can do numbers 1 to 4 above - code that I can just play with?
    • Is there anything else I should know?
    Thanks!
     
  2. 2rosy

    2rosy

    You can do this in any language. Maybe vba. However, if someone wrote exactly what you wanted it could easily go haywire until you're blown out
     
  3. Apbideas

    Apbideas

    Have you considered a Robotic Process Automation (RPA) application?
     
  4. gaussian

    gaussian

    Python is relatively simple to learn to a level of competency that will allow you to be productive. Easiest? Perhaps. That's really subjective.

    Python has plenty of backtest/execution libraries that will handle this for you. Zipline is one of the more popular ones. It seems like everyone writes a backtest library. It's the hello world of "data science".

    IB's python API is a little hard to wrangle compared to their more mature APIs (C#, for example). You will need to do quite a bit of studying to really grok how the "multi-thread" style of communication works so you don't step on your own toes. There are a handful of us here, myself included, who have successfully wrangled it. Just understand to get from 0 to automated execution you're talking months of dedicated study in Python and the IB API. You need to know the API thoroughly before you put money into it.

    Good luck - you will need it.
     
    globalarbtrader, TooEffingOld and d08 like this.
  5. d08

    d08

    Very true. It's relatively easy to get something working but the real difficulty is managing connections, verifying that your messages reach the server and handling the bugs (or as some at IB call them, "features").
     
    TooEffingOld likes this.
  6. tommcginnis

    tommcginnis

    1) yes

    2) there are 2-3 available online, including from IB.

    3) IMO, shoot for trade *triggers* first. These don't depend on option market liquidity, allowing (demanding) you to respond with actual review/brainpower first.

    RPA/algo-trading with trends is nearly trivial.
    RPA/algo-trading options is *much* trickier, just to develop robust triggers.
    RPA/algo-trading options including order management/placement? That's a job for a FT crew of a dozen.

    (IMO. YMMV. OIMMBCTTA.)
     
    TooEffingOld likes this.
  7. zdave83

    zdave83

    Like you, I have experience with VBA ... well, really a long background. Started building trading simulation/backtesting software in VB6(predecessor to VBA) in the '90's, and continue to leverage that VB6/VBA-based system. Its not the latest/greatest/coolest ... but integrates well with Excel which is used for modeling, charting and dashboard. When I sought to automate portions of the trading process I chose IB's APIs using VB.net Sample code to create an API app server ... also not the latest/greatest/coolest ... but stepping from VB6/VBA to VB.net wasn't too bad. I have a software engineering background, and am comfortable creating functionality inside a larger code set ... so I built on IB's Sample code believing I could get something up-and-running faster. Here's a description ...
    https://www.elitetrader.com/et/threads/api-anything-with-interactive-brokers.334760/#post-4903543

    4 cautions:
    1) The IB API Sample code was not written for live trading ... you have to add robustness just as you would writing from scratch.
    2) A number of the API's are asynchronous which is a new adventure if you don't have experience with async interfaces.
    3) Orders: STK & OPT are pretty straightforward ... however BAG (combo) Orders add a significant layer of API complexity.
    4) Quotes: I wrote a basic (vs full function) replacement for RTD ... good experience but not a good use of time unless you can't design around RTD to meet your needs.

    Alternatively ... you could try using VBA/Excel leveraging IB's spreadsheet samples ... which are extensive ... however I experienced issues early-on and was advised to go the API rout. I found that to be good advice for me.
     
    d08 likes this.
  8. gkishot

    gkishot

    Just take one of IB sample programs and expand on it.
     
  9. traider

    traider

    Python is the best
    For simple tasks like what you mentioned, ib insync should be good enough.
    For more complex backtesting, look at quantconnect, they support options + python although I haven't used it.
    Quantopian doesn't support options but is still good solild python framework.
     
  10. traider

    traider

    IB Insync is good wrapper around python API. I use it to write execution algos.
     
    #10     Feb 25, 2020