For educational purposes only. Trading involves substantial risk of loss. Not financial advice.
Mahoraga

An LLM-powered trading agent that adapts to social sentiment and makes trading decisions using AI. Built on Cloudflare Workers.

$ git clone https://github.com/ygwyg/MAHORAGA.git
Mahoraga Dashboard
Paper trading only. This software is for educational purposes. Always start with ALPACA_PAPER=true. Trading involves substantial risk of loss.

Quick Start

1 npm install install dependencies
2 cp .env.example .dev.vars create config file
3 # edit .dev.vars with your API keys Alpaca + OpenAI
4 npm run dev start MCP server
5 node agent-v1.mjs start trading agent
6 cd dashboard && npm run dev open dashboard

Features

LLM-Powered Analysis
OpenAI evaluates signals and decides what to buy/sell. Each signal is researched for red flags and catalysts.
Social Sentiment Monitoring
Scrapes StockTwits 24/7 for trending stocks and calculates bullish/bearish sentiment scores.
Position Management
AI continuously evaluates held positions and recommends hold/sell based on sentiment changes.
Risk Management
Stop-loss, take-profit, position limits, daily loss limits, kill switch, and approval tokens.
Real-Time Dashboard
Monitor positions, signals, research decisions, and LLM costs in a React dashboard.
MCP Server Architecture
Extensible tool-based design. Add your own data sources and trading strategies.

How It Works

The agent monitors StockTwits for trending stocks, uses OpenAI to research each signal (looking for red flags and catalysts), then executes trades through Alpaca based on LLM confidence scores.
For each trending stock, the LLM analyzes: Is the sentiment justified? Is it too late? Any red flags? It returns BUY/SKIP/WAIT with a confidence score. Only signals with confidence >= 0.6 are executed.
Three ways: (1) Stop-loss/take-profit rules, (2) LLM analyzes each position and recommends HOLD/SELL based on sentiment changes, (3) Manual close via dashboard or MCP tools.
Alpaca (free) for trading. OpenAI (~$0.50-2/day using gpt-4o-mini) for analysis. StockTwits is free and requires no API key.
Start with paper trading (ALPACA_PAPER=true). The system has multiple safety layers: kill switch, position limits, daily loss limits, approval tokens, and no margin/shorting.
Yes. Copy agent-v1.mjs and modify it. The file has clearly marked sections for data sources and trading logic. The MCP server provides tools for quotes, technicals, and order execution.