A tool to help you implement testfol.io tactical allocation strategy by evaluating with current market data.
Steps to set up a local instance of Livefolio for development:
-
Fill in remaining environment variables
cp .env.example .env.local
-
Start local Supabase
supabase start
-
Run development server
npm run dev
Livefolio is deployed on Vercel and uses Supabase for storage and most other backend services. I recommend you follow the steps outlined in this section to run some of the external services locally, so you don't have to go through registering billable services.
For the all backend and database, we use Supabase. For local development, you need to start a local stack of Supabase by running:
supabase startUpdate database schemas in supabase/schemas and run:
supabase db diff -f <migration_message>Migrate the local database instance with:
supabase db resetThis will clear the DB and repopulate with updated schema and any provided seed data. For Typescript support in our Next.js app, generate the types with:
supabase gen types typescript --local > src/lib/database.types.tsWe run periodic tasks, such as daily strategy evaluation and notification, which are powered
by Vercel Cron. Vercel calls one of our API route handlers as defined in
vercel.json as an entry point to the tasks. You can manually trigger the API route handlers by using a tool like
Postman to do a GET request, and provide the cron secret defined in your set of environment variables in the
Authorization header as Bearer <CRON_SECRET>.
Here's an example for manually triggering the cron job /api/evaluation:
curl -X GET \
-H "Authorization: Bearer my_cron_secret" \
http://localhost:3000/api/evaluationThe /api/dashboard/initialize endpoint can be automatically triggered after deployments using this method:
GitHub Actions
A workflow (.github/workflows/post-deploy-initialize.yml) automatically triggers initialization after pushes to main.
Set these GitHub secrets:
CRON_SECRET: Your production CRON_SECRET valuePRODUCTION_URL: (Optional) Your production URL, defaults tohttps://livefol.io
Historical and real time market data are sourced from Yahoo Finance through yahoo-finance2. It's a community project unaffiliated with Yahoo, so bear in mind that service availability and data consistency are not guaranteed. Nevertheless, it's been working well since 2013 and free. On the other hand, testfol.io sources most of its historical data from Tiingo, so there could be slight discrepancies. No API key required.
While Yahoo Finance provides most ticker data, some are sourced from FRED®, particularly
inflation and some treasury yield rates. The tickers sourced from FRED are the same as those in testfol.io. You will
need to provide your API key FRED_API_KEY.
For email related functionalities, we use Resend. You will need to provide your API key
RESEND_API_KEY, as well as a sender email NOTIFICATIONS_SENDER_EMAIL.
I came across the subreddit r/LETFs during my regular rabbit-hole binge on investments. While lurking, I read upon this strategy that truly perplexed me. It managed to absolutely outperform the benchmark S&P 500 in terms of CAGR and max drawdown, and held up honorably during market crises of 2008 and 2022.
Although the performance was impressive, the signals and allocations set for this strategy were all Greek to most of the commenters, including me. I wanted to implement it for testing with a small account portfolio. First step to studying it was to implement the signals, so I tried to build them on Trading view, a popular tool to build custom signals and alerts. The next step was to evaluate the signals into the allocation conditions. With three different signals, each with different indicators, evaluating four different allocations with 3 conditionals, it just became a headache to implement. Not only do you become overwhelmed with signals, but the overwhelmingness also leads to emotional setback, making you doubt your evaluations and therefore not take actions following the strategy.
I naturally thought it would be easier if there is a tool that can convert testfol.io signals into TradingView signals. Taking it a step further, what if there is a tool that just tells you exactly what assets to hold right now following a testfol.io strategy. That's when the idea of Livefolio was born.