C++ Programing : Principles and Practice (Enough ?)

Discussion in 'App Development' started by K-Pia, Mar 11, 2016.

  1. K-Pia

    K-Pia

    That's true. Uncertainty is everywhere.
    We don't know where the way leads,
    Until we've done, walked the walk.
    I learnt about "RR" with taleb.

    I would use Mathematica for prototyping.
    Knew that productivity is low. Tradeoffs.
    But I also use X_Trader. No Java there.
    Only C++, C#, VB ... .Net languages.

    I don't really need C++ as I could wrap Apis
    Into easier language I guess. Such as Python.

    But C++ looks sexy. Low-level and fast. Even if time consuming.
    Ok if it's the only trade off ... I've got time in plenty.
    I am young and at home, free from anything.
    Don't think it's gonna be a big mistake.
    If I put time and effort toward it.
    Don't know if it's going to help.
    Neither ... Let's see.

    I give it a try. Then if it leads nowhere. I'll drop it.
    But if I drop it. I'd consider having built a good foundation.
    For everything related with programing, according I finish the book.
     
    #21     Mar 11, 2016
    Simples likes this.
  2. K-Pia

    K-Pia

    Where can I read good code about trading in c++ ? Github ?
     
    #22     Mar 11, 2016
  3. Simples

    Simples

    I'd like to add: If you do have the time learning C++, it's a nice treat to learn most of the reasons why many languages are the way they are. Many of the "modern" languages are loosely modeled on C/C++ and try to mimic many of its features, although with C/C++ you can do it without much of the overhead (if required), alas it may be hard to get access to proper libraries, binaries and tutoring material relevant to current established practices - for good and for bad.

    Side note:
    Though, most languages, databases and systems we have today are really shells of what will come tomorrow. Most of it is pure crap, especially javascript, Java (JEE) and its ilk. Basically. We need to reinvent the entire "IT" field in order to accomodate developments in hardware and emerging possibilities, ie. remove many of the complexities that have become parasitic and useless.
     
    #23     Mar 11, 2016
    botpro and K-Pia like this.
  4. botpro

    botpro

    There might exist some libraries out there on the net, just search the net.

    I have written my stuff all myself. I have also posted here on ET some code.
    For example you could start with the GBM code to generate stock prices:
    http://www.elitetrader.com/et/index...-code-in-c-for-generating-time-series.297370/
    (take the latest version there).

    Like in the application part of the above code you could use similar loops to simulate a stock (or even many stocks) for a month or more.

    You could write a simple Account class, and a Position class.

    And then let it run: in each bar you would decide what to do: buy or sell or do nothing, and so on...
    Ie. in each bar you would probably open one or more Position's and add them to a collection class, ie. a vector class, or when closing the position remove it from the collection etc...
    Much like how your broker or bank handles your account and positions...

    Of course it would be better if you had some supporting classes like those used in Technical Analysis, for example a Moving Average class.
    You can find such source libraries on the net, for example http://ta-lib.org/ , (or *maybe* also in the package repository of your Linux distribution), and link it into your code.

    The use of such source or binary libraries saves you much development time.

    Happy coding! :thumbsup:

    Btw, there is no graphical user interface, and you don't need a GUI; a commandline program is sufficient.
    A GUI you can add if you wish so, but I guess it would take much time as you would need to learn the usage of a GUI library like "Qt" first...
     
    Last edited: Mar 11, 2016
    #24     Mar 11, 2016
  5. spacewiz

    spacewiz

    Just a little background: I started as a C++ programmer about 20 years ago, since then programmed in Java, Python, Ruby, Scala, R, VBA, JavaScript... so I know what I'm comparing.

    Starting a flame war is the last of my intentions, but I wanted to clarify some things about C++ so that people with less programming experience do not read this thread and leave with a wrong idea.

    C++ is an awesome language, and didn't have equals for the first ~20 years of its existence in the previous century. However, unless are are building an industrial-grade HFT system where you care about micro-second differences in performance or an embedded system were you have to count every kilobyte of memory: using C++ just does not make sense anymore.

    Java definitely (not sure about C#) can provide runtime performance as good as C++, at the expense of using more memory and garbage collection, but hey, memory is so cheap these days... . The benefit of using a newer/higher-level language is a huge gain in productivity: you develop code 5-10 faster and with fewer bugs and you'd have to try very hard (and will probably still fail) to introduce any memory leaks.

    Even in case you are able to gain a few microseconds in performance - that difference will be negated by the network latency which is orders of magnitude greater than difference in runtime speeds between most languages. This is because even many general-purpose interpreted languages such as Python or Ruby compile code to binary executables behind the scenes before executing it.

    Bottom line : there is a right tool (language) for each problem, and C++ is still a valid choice, but for a small subset of problems, which grows smaller every year. You will, however, waste many hours debugging your code to get rid of memory leaks and other low-level issues, time better spent on improving your trading strategy.

    I can think of only a couple of reasons to start learning C++: 1) you are a computer science student and want to formally study and understand computer architecture, or 2) a 30+ year old industry veteran who learned C++ during its prime and never wanted to learn another language for whatever reason. If the only tool you have is a hammer - everything looks as a nail..

    By the way, in nearly 20 years working in software development: never heard of a single programmer who went from Java back to C++ , but have met plenty of people who went the opposite direction and were very happy about it :) It might have been the case in mid-90's, but a lot of things have changed since then.
     
    #25     Mar 11, 2016
  6. botpro

    botpro

    I have not seen yet an operating system written in Java or C#; most OS are written in C/C++... ;-)
    This all must have a reason... ;-)

    And:
    RAD ("Rapid Application Development" system) is nothing but a marketing cr*p for managers, ie. a useless toy.

    Garbage collection is for lazy programmers who can't program, ie. trash ;-)

    Java's mass use of "new" is nothing but a sicko method. Those programmers are impaired for the rest of their lifes. :)
    Btw, I'm also a "Sun Certified Java Programmer", but have done not a single project in Java! Good so!
     
    Last edited: Mar 11, 2016
    #26     Mar 11, 2016
    bellman likes this.
  7. vicirek

    vicirek

    C++ is wonderful language and I am one of the few that went back and forth between many languages and frameworks minus Java and still prefer C++. Reading C++ books teaches you how to think in terms of program design like computer scientists. There are many of them. C++ is very simple language with most terse syntax and requires focus and programming discipline. Most importantly you are free to program using it as you wish including program layout.

    If you starting I would suggest http://www.cplusplus.com/doc/tutorial/ in under 100 pages you will get the bird view of the language.

    The C++ for dummies is also nice and easy read, well written by excellent authors.

    Bjarne book A tour of C++ is easy to read and worth it. Other books by this author are best used as reference.

    I also enjoyed Accelerated C++, Thinking in C++ (free download), C++ gotchas, and Scott Meyers classics

    Other books that often help are C++ cookbook and the C++ standard library by Josuttis.

    There are many others but with internet help is around the corner and stackoverflow is your best friend.
     
    #27     Mar 12, 2016
    K-Pia and Simples like this.
  8. K-Pia

    K-Pia

    The main reason I want to learn C++ is to communicate with APIs. Knowing what IB API (Java, C#, C++) and TTSDK (C, C++, Python) offer. C++ is the intersection. I think it's a good language to learn about Csc in the meantime. As you said. Plus I don't want to use wrapper or glue too much stuffs together. And if I know C++ I won't have speed related issues, to backtest with tick data, for exemple.
     
    Last edited: Mar 12, 2016
    #28     Mar 12, 2016
  9. Speaking of github and c++, here's what I use currently (and have used for years) for my IB API:
    https://github.com/JanBoonen/TwsApiCpp

    This fellow has been maintaining this c++ adapter to the IB API for quite a while and I've found the class abstraction to be very useful.
     
    #29     Mar 12, 2016
    botpro and K-Pia like this.
  10. K-Pia

    K-Pia

    Currently, C++ is not that heavier than Mathematica. I do all the exercises, from the book, in both languages. However there are short hands and maybe faster ways to do the job in Mathematica. What's cool is that Mathematica handle all the functions from C++. Procedural ones. Should try the reverse. To solve problem from Mathematica's book in C++. Aha.
     
    #30     Mar 12, 2016