Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valuemelody/melody-invest
Trading Strategy Backtesting and Evolution Platform
https://github.com/valuemelody/melody-invest
backtesting evolutionary-strategy investing investment-analysis trading-strategy
Last synced: about 1 month ago
JSON representation
Trading Strategy Backtesting and Evolution Platform
- Host: GitHub
- URL: https://github.com/valuemelody/melody-invest
- Owner: ValueMelody
- License: mit
- Created: 2021-11-08T22:44:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T00:54:37.000Z (3 months ago)
- Last Synced: 2024-09-15T07:57:21.905Z (3 months ago)
- Topics: backtesting, evolutionary-strategy, investing, investment-analysis, trading-strategy
- Language: TypeScript
- Homepage:
- Size: 3.16 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Concept
There’s no single “best” strategy, only strategies that adapt to changing market conditions. Through competition and evolution, better strategies emerge. Melody Invest enables you to create trading strategies by grouping together various trading behaviors. By backtesting these strategies with historical stock data, you can evaluate their performance across different environments. The platform then merges the most successful strategies to evolve and generate new ones, continuously repeating the cycle of competition and evolution.# Disclaimer
This platform is for experimental purposes only:
- Backtesting results do not guarantee future success. Predefined conditions and rules can significantly impact backtesting outcomes, and relying solely on this platform’s results may be risky.
- Investment, as well as providing investment advice, requires specific knowledge or certification. Your investment strategy should not be based solely on the results generated by this platform.
- Stock API providers may have data-sharing policies. Be sure to review these policies before publicly hosting this platform.# Get Started
## 1. Install Node, Redis and Postgres
```
# Install redis
sudo apt install redis-server# Install postgres
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt install postgresql-15# Install node
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g pm2
```## 2. Prerequisite
- Create a PostgreSQL database named "melody-invest".
- Obtain an API key from [Tiingo](https://www.tiingo.com/)## 3. Prepare the codebase
```
git clone [email protected]:ValueMelody/melody-invest.git# Replace frontend env vars if needed
cp ./client/.env.example ./client/.env# Replace backend env vars, including redis, database, mailer configs
cp ./server/.env.example ./server/.envnpm install
npm run sharedcd server
npm run migratecd ../
npm run dev
```## 4. Account setup
1. Open http://127.0.0.1:3099 in your browser.
2. Create a new account.
3. Sign in and navigate to the “Profile” page.
4. Save your Tiingo API key in the “Profile” page.
5. Go to the “Manage Tickers” page
6. Create several stock tickers that you want to use for backtesting your trading strategy.## 5. Data syncing (Daily)
This process should be repeated daily after the initial setup:
```
cd server
npm run build# Sync prices for your tickers
npm run syncTickerPrices yyyy-MM-DD# Calculate price movements based on ticker prices
npm run calcPriceMovements# Prepare daily ticker price data for final calculation
npm run calcDailyTickers
```## 6. Data syncing (Weekly)
This process should be repeated weekly after the initial setup:
```
# Sync financial statements for your tickers
npm run syncTickerFinancials yyyy-MM# Calculate financial movements based on financial data
npm run calcFinancialMovements# Prepare daily ticker financial data for final calculation
npm run calcDailyTickers
```## 7. Data sync (Monthly)
This process should be repeated monthly after the initial setup.
1. Collect economic indicators from the following sources and store them in your indicator_monthly, indicator_quarterly, and indicator_yearly tables:
- Yearly Inflation: https://www.usinflationcalculator.com/inflation/current-inflation-rates/
- Yearly GDP: https://en.wikipedia.org/wiki/Economy_of_the_United_States
- Quarterly Seasonal GDP: https://fred.stlouisfed.org/series/NA000254Q
- Monthly Funds Rate: https://fred.stlouisfed.org/series/FEDFUNDS
- Monthly 30 Years Treasury Yield: https://fred.stlouisfed.org/series/DGS30
- Monthly 10 Years Treasury Yield: https://fred.stlouisfed.org/series/DGS10
- Monthly CPI: https://www.usinflationcalculator.com/inflation/consumer-price-index-and-annual-percent-changes-from-1913-to-2008/
- Monthly Consumer Sentiment: http://www.sca.isr.umich.edu/
- Monthly Unemployment Rate: https://data.bls.gov/timeseries/LNS14000000
- Monthly Nonfarm Payroll: https://fred.stlouisfed.org/series/PAYNSA2. Run the following commands to process the collected data:
```
# Calculate economic indicator movements based on collected data
npm run calcIndicatorMovements# Prepare daily indicator data for final calculation
npm run calcDailyIndicators
```## 8. Generate trader report and evolve
1. Open http://127.0.0.1:3099 in your browser.
2. Create an environment on the “Dashboard” page.
3. Create at least two profiles on the “Dashboard” page.
4. Run the following commands to generate reports and evolve new traders:
```
cd server# Generate backtesting results for your traders
npm run calcTraderPerformances# Evolve new traders based on performance
npm run calcTraderDescendants
```
You can keep triggering these commands over and over again to generate new traders and evaluate their performance# Screenshots
## Dashboard
![Dashboard](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/dashboard.jpeg)## Trader Report
![Trader Report](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/trader_report.jpeg)## Env Report
![Env Report](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/env_report.jpeg)## Combo Report
![Combo Report](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/combo_report.jpeg)## Manage Tickers
![Manage Tickers](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/manage_tickers.jpeg)## Create Trader
![Create Trader](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/create_trader.jpeg)## Create Env
![Create Env](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/create_env.jpeg)## Create Combo
![Create Combo](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/create_combo.jpeg)## User Profile
![User Profile](https://raw.githubusercontent.com/ValueMelody/melody-invest/main/screenshots/user_profile.jpeg)