How Do You Build Systems Using Python?

Discussion in 'Programming' started by tommo, Nov 21, 2016.

  1. tommo


    Sorry for the vague title, couldnt think of a brief way to explain exactly what i mean.

    I have backtested systems before on programs like Tradestation and CQG where you have everything in one place. Indicators, charts, an area to write the code etc. The code is pretty much picking an indicator and saying "buy above MA" and the software knows what "buy" "above" and "MA" all mean.

    But with a coding language such as Python you have an empty white page to start writing and nothing else and doesnt seem to have much vocabulary unless you build it all from scratch. I dont understand where you get data, where you get the charts etc?

    Say for example i knew how to code Python to a high level and wanted to test trading systems with accurate high level data (so im talking whats going on in the order book, volume available on the bid and ask etc) where would you get that from? Can it just be bought as a file? Is there an online server you tap into?

    Just in laymans terms if you have the language how do you then build a system with it? Are there programs that look like CQG with all the indicators and charts etc?

    Hope that make sense, its just at the moment i am learning python and getting pretty bored of getting it to print "hello world" and making text go upper and lower case. Dont see how i could apply anything to trading.
  2. I don't know anything about coding.
    But when you code something for trading, do you create a program that gives you an alert to market changes for a specific stock?

    Or do you program it to automatically buy something at a certain price and sell at a different price?

    Does it need approval to make a trade and deduct it from your account or does it do this automatically?
  3. Simples


    Step by step.

    So what do you want to test? Describe it in the language!

    With frameworks, you're bound to how the programmers designed their structures, for good and for worse. By starting from scratch in a general-purpose language, you're free to Make It Right (tm). If holding your hand a bit, I'd say try to emulate your interactions with your broker and/or exchange, in detail and/or generally.

    You're finally free!
  4. d08


    Data can be in CSV files obtained by a downloader from various free or paid sources. I just wrote a data downloader in Python which adjusts files as I need them adjusted, did it very quickly - Python is amazing for many tasks as the code looks extremely readable compared to most other languages.

    You loop over the data and build indicators based on the input data, nothing too complicated. Then you set conditional buy rules based on the indicators or price, just like any retail trading application.

    Building something like this is relatively easy, the hard part is writing clean very re-usable code and error handling.
    Zzoom, SimpleMeLike and alfa8 like this.
  5. Turveyd


    Google, every small step you want to make, you'll generally find 1000nd others doing exactly the same thing, then modify theres to suite.

    1. Connect to Data Source
    2. Loop around Data.
    3. Carry out Math's on that loop.
    4. Make decisions based on that math.
    5. Place trades based on the decision.
    6. Repeat endlessly!!

    Personally hate Python, it's less functional than 20year old VB6 and slower to code a similar system, or maybe I'm just old! ( too Space and Tab picky aswell, annoying )
    alfa8 likes this.
  6. d08


    What's not functional about Python? I haven't found anything it can't do as of yet.
    cafeole and userque like this.
  7. Turveyd


    For what I Dev for clients not great at all, I didn't mess too much just wrote 1 app for a client, no GUI, using nothing more than a text editor, it's like how I was coding 30years ago.

    More on about limited Syntax, having to load a library hassle for a basic VB function.

    I hate VB.NET even more if that helps!

    Java Scrip wasn't too bad, learned that for Google Sheets recently in about 2hours.
  8. userque


    Have you considered the possibility that you may just be very uninformed?
    d08 likes this.
  9. Turveyd


    Maybe, but as I doubt you trade in VB6 maybe you dont realise the languages are actually slower and less friendly to dev in, why there are so many VB6 users out there still.

    Works nicer with Excel / Word ofcoure.
  10. Quantopian ...

    Checkout their website, good place to test out stuff.
    #10     Nov 21, 2016