Open source trades analysis software?

Discussion in 'Trading Software' started by mwahal, Dec 29, 2017.

  1. mwahal

    mwahal

    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. fordewind

    fordewind

    NinjaTrader
     
  3. mwahal

    mwahal

    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. fan27

    fan27

    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. just21

    just21

    www.quandl.com has free data and an api.
     
  7. toonerdy

    toonerdy

    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.
     
    Last edited: Dec 30, 2017
  8. Gambit

    Gambit

    Quantopian, Quantconnect
    pysystemtrade
    Quantstart's backtester

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

    truetype

  10. mwahal

    mwahal

    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     Dec 30, 2017