Learn to program with me...

Discussion in 'Automated Trading' started by C99, Mar 23, 2007.

  1. C99


    So I’ve been wanting to learn how to program for a while now. I have zero experience and am having a tough time getting started. I can find beginner resources, and I can find trading resources, but not many beginner resources specifically related to trading. I also get confused because there seems to be multiple ways to go about doing many things and I have no idea which is the right course to take.

    I’d like to document the path here as I go from complete and utter newb to actually programming something useful to my trading. I invite anyone who wishes to participate to join in. I’ll be using C#.NET/ SQL and I trade through IB for futures and RediPlus for stocks. Feel free to use the language and trading platform of your choice. I hope to break down the steps required to get started into little bite-size pieces and post working examples and / or code snippits. Please save any arguments about this language is better that that. If you feel this way, then play along and post the examples in the language of your choice. The more languages and platforms represented, the better this reference will be for those that follow.

    Setup: I picked up an academically priced version of MS Visual Studio Pro 2005 for $140 on ebay. This includes SQL server 2005. I have installed the IB API and enabled TWS to accept DDE, ActiveX and socket connections. RediPlus also uses an ActiveX API although it is not nearly as well documented as IB’s API.

    If you want to play along, you’ll need an IDE. Microsoft offers express versions of Visual Studio and SQL for free. They include everything I think you’ll need. I know there are also free Java and other language IDE’s.

    Microsoft Visual Studio Express can be found here:

    I had downloaded the C# Express edition before I purchased VS2005 and on the start page is a great, free video series that walks you through some of the basics called the RSS Reader project. It has nothing to do with trading, but it is a good start for learning about Visual Studio and connecting to a SQL express database. It’s about 8 hours of video in total and well worth the time. More beginner videos here:

    A rough outline of what I’d like to accomplish:

    -Connect to TWS and Redi.
    -Get price and size quotes for one single symbol. ( these two goals alone would feel like a small victory)
    -Perform some simple calculations on this price data.
    -Get position and open order info.
    -Store price ticks in some way (write them to SQL?)
    -Use this stored data in some simple calculations
    -Submit an order by clicking a button and get execution info back
    -Submit an order based on some condition being met and get execution info back
    -Log trades to SQL
    -Track open orders and update them based on some condition (for example a trailing stop)
    -Expand my single-symbol examples into examples that do the same thing for a small portfolio.

    So I’m not talking about backtesting, charting, or full fledged automated trading systems. I really just want to learn the basics of interacting with my trading platform via the API.

    Part of me is completely intimidated by programming, and another part of me thinks it really can be THAT hard if there are armies of third world programmers, many of whom probably don’t even speak English, pumping out volumes of code. Why not just pay them their $10 an hour to do it for me you may ask? I do. I have several small apps I’ve had developed that I run every day. But I’m a hands-on person that likes to tinker. I want to know how they work and I want to be able to maintain them and make changes myself. I’m willing to put in the time and hopefully I can figure this out.

    So I’m hoping there are other people like me out there that want to learn this but don’t know where to start. This is it. This is where you start. And I’m also hoping that there are some more experienced programmers out there that will nudge us in the right direction without excessively mocking our seemingly idiotic questions. My mom always told me that people help those who help themselves. So I hope that by showing some initiative a few kind souls will take us under their wing.
  2. C99


    So this is where I am currently at. I’ve installed Visual Studio, watched the video series and done my first “Hello World” program. Like I said- complete newbee. I’ve looked at the IB sample API programs but they really make no sense to me. They have a VB.NET example, but it looks like it was built with VS2003 and I get a build error when I try to run it with VS2005. It looks like it’s only one small piece of code, but I don’t have any idea how to fix it yet. I have some sample programs and docs for Redi, but nothing in .NET and the docs look like greek to me. So I’m at a loss there.

    My first goal is to connect to my two platforms, one at a time, and get price quotes for one symbol. Stock for Redi and futures for IB. I know I need to supply some login info and the symbol. I know IB needs some basic contract info too. Actually, I don’t know anything at this point, but this is my best guess from reviewing the documentation I have. It’s getting late tonight, but tomorrow I will post screen shots of the two forms I have created and grovel for some detailed instruction on how to get them working. I feel completely lost right now, but I’m hoping once I get a few basic concepts down I will begin to be able to piece things together for myself. The forms are just drag and drop and I *think* it should be a minimal amt of code to get this working. So off we go…..
  3. Tums


    saving tick data to SQL will be a tall order.
  4. You can use excel...and dde to get quotes etc from Redi. Very simple process, and if this small victory helps you get off on the right foot, well...all the better then.
  5. C99


    easy there, baby steps. I'm not looking for every tick. One tick will do for right now. More of an academic exercise at this point. I realize there may be tools better suited to high frequency data and trading. I'm nowhere near there. The c# / SQL express combo is free and I have reasons outside of trading that I want to learn C#. So it seemed like a good place to start and accessible for others who've had a curiosity to learn without committing alot of $. I'm also more of a 1 minute type person than a tick person (insert your own one minute man joke here :) )so eventually I'd like to figure out the mechanics of capturing and recording OHLC 1 min data. Should be more manageable than every tick.
    I also recently read an article that realtick runs all .NET and SQL, so maybe it's not that far fetched. Or maybe it is? Again, blissful in my ignorance.

    I'm good on DDE, though thanks for responding. I have many spreadsheets running off Redi, but I'm to the point where I would need to step up to VBA. From looking at VBA, it seems so close to VB / C# . NET that I figured I may as well bite the bullet and step outside the comfort zone of excel. It will take longer at first, and I do love my excel, but longer term it's something I think I need to suck up and do.
  6. trade station much?
  7. H2O


    Ok, I think I'm more or less in the same situation as you , except for the fact that I'm looking to link to different ISV's (TT's FIX adapters or Eccoware, my current platform)

    I have some previous experience in visual basic and quickbasic but decided to go for C# as well as this seems to be the best way forward. I started reading C# books several weeks ago and think I understand the basic concepts.

    The problem in creating any trading related code is that you will have to look at multithreading because of the frequent updates of the different instruments. (if you look at multiple products, and you want to perform calculations on the data)

    I would be happy to share experience and see if we can help eachother in some parts.
  8. Chicago


    I'm with you :)

    Just started learning Java and am trying to get my head around the IB Api. I started reading all the books, but after awhile you start to realize that there are only a few concepts you need to understand and from there it is all about understanding how the API works and lots of practice.

    In my case it was just trying to understand Object oriented programming and trying to catch all the stupid little syntax errors I seem to keep missing.

    From what I've heard Java and C# sharp are relatively similar. Not sure how I can help, but will try if you need some help.
  9. bidask


  10. #10     Mar 23, 2007