Home > Tools of the Trade > Trading Software > Open source trades analysis software?

Open source trades analysis software?

  1. Hi

    Is there any open source software which can analyze your trades and spit out risk/drawdown/maxdrawdown/sharpe ratio/etc etc. I have a list of about 200 actual trades with date, time, stock price, # of shares, buy or sell.

    The format is in the file.

    Tick,Date,Time,BuyOrSell,Shares,Capital,Commissions

    The trades are located here, https://goo.gl/vaY8eX

    Thanks
    Mwahal
     
  2. NinjaTrader
     
  3. Something which doesn't want me to open account or run only on Windows.
    I was looking for something in opensource etc running in java or python or even C/C++. I am more of a Linux/Mac guy.

    Thanks
    Mwahal
     
  4. Why not just write it yourself? Based on your requirements it looks to be about only one days effort.
     
  5. In terms of saving cost, software is not a big problem compared to financial data. Financial data is the biggest cost as a retail trader/investor.
     
  6. www.quandl.com has free data and an api.
     
  7. I don't know of any open source software specifically for this from memory. However, for the statistics you want, you should be able to use Libre Office (localc). [Edit: I should add that this and other spreadsheet programs I have used support a "stdev" function, which should slightly simplify your calculation of a Sharpe ratio.]

    I believe that, to compute a Sharpe ratio, you would want uniform time samples, which your spreadsheet does not have.

    Also, by the way, you might want to recheck your data, as I am having trouble inferring a consistent definition of "capital" from your spreadsheet.

    The value of "capital" in your spreadsheet does not appear to be proportional to the size of the individual trade, as some trades are ~5X larger than others, but the value of the "capital" cell is nowhere near proportional to that.

    "Capital" does not appear to be the net liquidation value of the account, because, for example, in the first two trades you buy and sell your entire position, but then the value of capital changes by 286.6 between rows two and three, during a period when the account was presumably all cash. There appear to be many cases like this, in which capital changes while the number of shares held is zero.

    Finally, "capital" does not appear to be the value of the uninvested cash after the trade, because, for example, it decreases by 936 after the sell in line two.
     
  8. Quantopian, Quantconnect
    pysystemtrade
    Quantstart's backtester

    Or use tradestation. It should be low cost now.
     
  9. Toonerdy

    Thanks for taking your time for writing detailed response.

    The system trades between CASH, TICK1 or TICK2. TICK1 and TICK2 are different values, thus the trade shares (size) will be different, sometimes as much as 5x.

    Regarding the capital invested, yes you are right. The capital starts at X, then over time, either partial investment is made or new capital is added. Based on my calculations, let's say the 1st trade is the starting capital, 23841, then over the time, 8958 was added in the trading system. The ending capital is 46161.

    I calculated a NAV similar to a mutual fund, where I start with X shares and then everytime I add new capital, I increase the number of fund shares. When I buy or sell, I calculate how many shares I need to exchange from CASH to buy TICK1 or TICK2 for that capital invested. If the current cash exceed the BUY capital needed, then I add new CASH in the system and create more fund shares. If the CASH is more than the capital needed, then only partial CASH is used in the system. Then when I sell TICK1 or TICK2, I convert the capital received back to CASH and add the current uninvested CASH in the system. Then I compute the NAV based on the number of fund shares and the total CASH in the system after the SELL.

    Based on that calculations, the net gain in the system is 13361, the NAV return is 45.7%, simple return (netgain/startingcash) is 40.74%. This is after commissions of 856$. I also calculated drawdowns and maximum drawdowns. The chart is attached.

    I did calculate the expectancy of the system (%winrate * %avgwin) - (%lossrate * %avgloss)

    Total trades is 100 AvgWin% is 3.3091 NumWins 47 AvgLoss% is -2.0598 NumLosses 53 Expectancy is 0.46

    The average return of the system is 0.4636% (same as expectancy) and standard deviation of the return is 3.4607.

    The average holding period is about 60 calendar hours (not market hours). Avg winning hours is 90 and avg losing hours is about 40.

    Beyond that I am still trying to find some meaningful stats. I see a lots of them on different posts but not sure what is really needed. These are all my own tools for calculations and charting. I am very old school guy, coding in whatever works and fast (including these charts from old school gnuplot).




    upload_2017-12-30_7-56-57.png
    I also calculated the drawdowns and the maximum drawdowns.

    upload_2017-12-30_7-58-1.png

    This is %return per trade.
    upload_2017-12-30_8-10-44.png

    Trade time per trade, avg is about 60 hours (calendar hours, not market hours).


    upload_2017-12-30_8-18-2.png

    upload_2017-12-30_8-20-4.png
     
  10. I think pysystemtrade looks promising, will look into it.
    Thanks
     
  11. It makes sense to look for a third party tool first, actually. In my experience, something like this takes 2 hours to build the functionality (even if you need fancy analytics like resampling and factor correlation). After that, it takes 2 days to make sure the output is nicely formatted. Those two days are always better spent doing something else, but you sometimes need it nicely formatted.
     
  12. As always multiply estimates with pi (3.14...) and solve for developer ;)

    When starting from scratch ("I know nathing"), it can actually take days just to find the tools you'll be productive in. LibreOffice Calc may get you started most quickly, but at some point you'll want something more customizable. Going 3rd party comes with extra learning and adapting to infexible ways of doing things as well, but can be great for learning.

    If you've done it before and used the tools before, then it can take 2 hours for reals. Your wife may claim otherwise though! :p
     
  13. The beauty of something like that is that it’s an easy to define stand-alone project. At my previous place of employment, I built something that does this (a bit more complex, as I also used it for allocating risk) as a library and an intern used this library to build a bunch of reporting tools. The library literally too a few hours. The tools took the whole summer, albeit by a guy who knew nothing about finance at the time, but it was still imperfect. This time around, if (more like when) I need pretty presentation of the results I’ll hire a consultant.
     
  14. Where will then spend another summer waiting for and iterating on the results.:D