How to code up sharpe ratio [ibapi + python]

Discussion in 'Automated Trading' started by xappppp, Oct 30, 2022.

  1. xappppp

    xappppp

    This could be a design issue or maybe there are some more efficient tools or path I'm not aware off. Below is my thought start from scratch but any other idea is greatly appreciated.

    1. download store portfolio positions
    2. download and store prices of each position very often.
    3. calculate the portfolio total value at each sbapshot (daily)
    4. calculate sharpe ratio based on the daily portfolio value. and store it.

    The final goal is I can flexibly compare the sharpe ratio of current portfolio and a proposed alternative strategies.
     
  2. You can just download the portfolio value directly.

    GAT
     
  3. I can recommend https://github.com/erdewit/ib_insync. I had to develop a couple of scripts for a client and that library made it easier.

    Your task is fairly easy, you can ask for detailed steps at https://groups.io/g/insync
     
  4. dekiles

    dekiles

    Thanks for the link. I was looking for a little different information, but thanks to you I found it very useful. Thank you!
     
    xappppp and guest_trader_1 like this.