MCPcopy
hub / github.com/austin-starks/NextTrade

github.com/austin-starks/NextTrade @main sqlite

repository ↗ · DeepWiki ↗
1,033 symbols 2,387 edges 180 files 9 documented · 1%
README

NextTrade - Plan your next trade

A system to create, test, optimize, and deploy algorithmic trading strategies.

For a better, faster, cloud-based platform, check out NexusTrade. If you want to learn about algorithmic trading and financial research from a community of data-driven investors, join our free Discord channel!

NexusTrade is a AI-Powered platform that streamlines the configuration of trading strategies. It's faster, more configurable, and more feature-rich than NextTrade. It features a powerful AI Chat Assistant tool as an entry point to many of its features.

Some improvements include: - Enhanced configurability: Can essentially express any trading idea you can imagine - AI-Powered Research Tools: Perform in-depth company analysis and compare companies between each other - Powerful stock screener: Use natural language to find stocks in over 130 industries and 30+ indicators

NextTrade Features

  1. Combine conditions to form compound conditions. Combine compound conditions and create trading strategies.
  2. Compound Condition — returns true if all conditions are true
  3. For example:
    • Condition A: QQQ stock is 1 SD below its 5-day mean price
    • Condition B: Buying power is above $8,000.
    • Condition C: Condition A and condition B
    • Strategy: If condition C, buy $3000 of SPY
  4. Create unlimited portfolios with different combinations of strategies
  5. Create unlimited portfolios
  6. Backtest those strategies using historical data.
  7. Backtest your portfolio
  8. Only stocks are currently supported, but cryptocurrency and options support is baked into the architecture
  9. Optimize the strategy's parameters using a genetic algorithm
  10. Optimize your strategy with Genetic Algorithms
  11. Choose hyperparameters like mutation rate, training period, validation period, and population size
  12. Choose to optimize percent gain, sortino ratio, sharpe ratio, or max drawdown
  13. Deploy the strategies live and see how it performs in real-time
  14. Deploy your strategies live with the click of a button

System Architecture and Design

Some architectural artifacts can be found at this link: https://drive.google.com/drive/folders/1TgZNGPd7TBWi47dWh0TI2nZ_9WUhv_P_?usp=sharing

Local Installation

Prerequisites

  1. Mac, Linux or WSL2 preferred
  2. How to set up Linux on Windows with WSL 2
  3. Tradier Account (with at least a free sandbox token; additional brokers TBD)
  4. Production vs Sandbox data details
  5. Sandbox Account and Signup info

Mac Setup

  1. Clone the repository.
  2. Install MongoDB community edition and enable it.
  3. Install the dependencies: npm run install-all
  4. Make sure all tests pass: cd app && npm t && cd ..
  5. Add your Tradier token to the ./app/env file and rename the file to .env

Linux/WSL2 setup (tested on Ubuntu 20.04)

  1. If needed, install Node.js. NVM Option:
  2. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
  3. Exit and restart the terminal session.
  4. nvm install --lts
  5. Install MongoDB community edition and enable. For Ubuntu 20.04:
  6. curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
  7. echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
  8. sudo apt update
  9. sudo apt install mongodb-org
  10. Linux/Ubuntu specific:
    1. sudo systemctl status mongod (verify it's running)
    2. sudo systemctl enable mongod (to auto-start at boot)
  11. WSL2 specific:
    1. sudo mkdir -p /data/db
    2. sudo chown -R `id -un` /data/db
    3. wget -O mongod.sh https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d
    4. sudo mv ./mongod.sh /etc/init.d/mongod
    5. sudo chmod +x /etc/init.d/mongod
    6. sudo service mongod start
    7. sudo service mongod status (verify it's running)
  12. mongo --eval 'db.runCommand({ connectionStatus: 1 })' (verify it's working)
  13. Clone the NextTrade repository: cd ~ && git clone https://github.com/austin-starks/NextTrade && cd NextTrade
  14. Install the dependencies: npm run install-all
  15. Copy the sample config file to .env cp ./app/env ./app/.env
  16. Add your Tradier token to the ./app/.env file
  17. Make sure all tests pass: cd app && npm t; cd ..

Turning on the system

Manually managed

Development environment

  1. Open two terminal windows.
  2. In a terminal instance, turn on the client: cd client; npm start
  3. In another terminal instance, turn on the server: cd app; npm start
  4. Once started, load the app: http://localhost:3000

PM2 Managed

Setup

  1. npm install pm2@latest -g
  2. cd ~/NextTrade/client && pm2 start npm --name "NextTrade-Client" -- start
  3. cd ~/NextTrade/app && pm2 start npm --name "NextTrade-App" -- start
  4. pm2 save

Running (assuming no other PM2 apps)

  1. To start the client+app: pm2 start all
  2. To stop the client+app: pm2 stop all
  3. Other Useful commands: pm2 status, pm2 logs, pm2 monit See PM2 Quickstart for more.

Extension points exported contracts — how you extend this code

ICompoundCondition (Interface)
(no doc) [3 implementers]
app/src/models/conditions/compound.ts
TableProps (Interface)
(no doc)
client/src/components/Table/index.tsx
IHistoricalTargetPriceCondition (Interface)
(no doc) [1 implementers]
app/src/models/conditions/movingAverage.ts
IAbstractMenuOptions (Interface)
(no doc)
client/src/components/Searchbar/index.tsx
IThenCondition (Interface)
(no doc) [1 implementers]
app/src/models/conditions/then.ts
IMenuAssetOptions (Interface)
(no doc)
client/src/components/Searchbar/index.tsx
IPositionValueIs (Interface)
(no doc) [1 implementers]
app/src/models/conditions/positionValueIs.ts
IRenderOptionProps (Interface)
(no doc)
client/src/components/Searchbar/index.tsx

Core symbols most depended-on inside this repo

set
called by 171
app/src/models/priceMap/index.ts
isTrue
called by 116
app/src/models/conditions/or.ts
get
called by 74
app/src/models/priceMap/index.ts
save
called by 48
app/src/models/user/index.ts
toString
called by 38
app/src/models/time/index.ts
create
called by 36
app/src/models/backtester/index.ts
addGroup
called by 32
app/src/models/field/formControl.ts
connect
called by 31
app/src/services/db.ts

Shape

Method 490
Function 218
Class 152
Interface 139
Enum 34

Languages

TypeScript100%

Modules by API surface

app/src/models/optimization/index.ts55 symbols
client/src/services/requests.tsx37 symbols
app/src/models/backtester/index.ts31 symbols
app/src/models/priceMap/index.ts29 symbols
app/src/models/portfolio/portfolio.ts29 symbols
app/src/models/asset/Option.ts29 symbols
app/src/utils/enums.ts27 symbols
app/src/models/brokerage/testBrokerage.ts26 symbols
app/src/models/strategy/index.ts25 symbols
app/src/models/portfolio/abstractPortfolio.ts24 symbols
app/src/models/brokerage/BacktestBrokerage.ts21 symbols
app/src/controller/forwardtestController/index.ts21 symbols

Dependencies from manifests, versioned

@babel/core7.12.10 · 1×
@babel/preset-env7.12.11 · 1×
@babel/preset-typescript7.12.7 · 1×
@date-io/date-fns2.13.1 · 1×
@emotion/react11.5.0 · 1×
@emotion/styled11.3.0 · 1×
@material-ui/core4.12.4 · 1×
@material-ui/icons4.11.2 · 1×
@microsoft/tsdoc0.13.2 · 1×
@mui/icons-material5.1.0 · 1×
@mui/lab5.0.0-alpha.72 · 1×
@mui/material5.1.0 · 1×

Datastores touched

(mongodb)Database · 1 repos
nexttradeDatabase · 1 repos

For agents

$ claude mcp add NextTrade \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact