Tickjury 如何建構:以隨機投資組合作為印度股票回測基準
Backtesting Indian stocks against random portfolios: how I built Tickjury
Tickjury 是一個印度股票回測網站,作者以 NIFTY 500 及 20 個從同一股票清單隨機選出的投資組合,作為每個交易模型的比較基準。回測計入 STT、印花税、交易所費用、GST 和 demat 費用,並為每筆交易的買入及賣出各計入 0.1% 滑價。網站亦公開失敗的交易構想,部分回報及市場資料毋須帳戶即可查看。
Tickjury is a website where I backtest trading ideas on Indian stocks and put up the results. I also put up the failed results. In this post I’m going to talk about the architecture of the site and about one specific design decision I made, which is the use of a random portfolio as a baseline for comparisons.
The problem with a backtest
Whenever you do a backtest and see a good yearly return, the question to ask is, what would have happened had I randomly picked a portfolio in the same years? In Tickjury, for every trading model, I compare with the NIFTY 500 and also with 20 randomly selected portfolios from the same list of stocks. The portfolio is selected to match the model in terms of timing, stake size and costs, but the stock pick is random. If the random portfolio did as well, it could just be that the model’s performance was lucky.
Accounting for costs on each trade
When you trade in the Indian stock market in the delivery mode, you pay a number of taxes and charges - STT, stamp duty, exchange charges, GST and a demat charge. I account for all of these on every trade, and I also use a slippage of 0.1% on either side of every trade. A backtest that doesn’t account for these will look better than it actually was.
Tech stack
The market data is taken from Zerodha Kite, and I get daily prices from 2016, which are updated periodically on a small Digital Ocean droplet. The research engine is written in plain Python, the API is a Starlette app, and the marketing site is written in Next.js 16. The performance sheets for each model are precomputed for every quarter start since 2016 Q1, and updated every night. This means that the model performance pages do not do any backtests on request, they just read files. The site is exposed via a Cloudflare Tunnel.
What I got wrong
My price data does not contain prices of stocks that have been delisted. This means that stock results look slightly better than they actually were. This is mentioned on the method page.
The failed ideas remain
I publish the failed ideas as well, by marking them as “No change” or “Rejected”. If I only showed the winners, you wouldn’t know how many ideas I actually tested.
Free stuff
I give away the returns and worst fall for each model, the market cycle view, the NIFTY weekly options backtests, and one page for each NSE stock, without requiring an account. The trades and holdings are behind a credits system, with packs starting Rs 100.
I’m keen to get some feedback on the use of a random portfolio as a baseline - do you think it’s a fair comparison or would you do something different in your own backtesting?
Demo (1:32): https://www.youtube.com/watch?v=nmAvyH9II04
Site: https://tickjury.com/?utm_source=devto&utm_medium=community&utm_campaign=launch
How I made this post: I run the tests and decide what is published. AI tools helped draft and edit this post. Every figure comes from the site.
I built Tickjury. Education only, not investment advice. Past results, after costs, with stated limits.
來源:DEV Community · dev.to