Finance Tutorial25 min read

Investment Tracking with Moltbot

Build your personal investment command center. Monitor stocks and crypto, get real-time price alerts, track portfolio performance, and receive market updatesโ€”all through your messaging apps.

What You Can Track

Moltbot can monitor your investments across multiple platforms and deliver personalized insights. Here's what's possible:

Stock Monitoring

Real-time price tracking for stocks and ETFs

Crypto Tracking

Monitor Bitcoin, Ethereum, and altcoins

Portfolio Analysis

Aggregate holdings across multiple accounts

Smart Alerts

Price targets, percentage moves, volume spikes

Natural Language Queries

Ask about your investments in plain English. Moltbot understands context and can provide sophisticated analysis:

๐Ÿ‘ค

You

How's my portfolio doing today?

๐Ÿฆž

Moltbot

๐Ÿ“Š Portfolio Summary (Today)

  • Total Value: $124,532 (+1.2% / +$1,478)
  • Day's Gain: +$1,478
  • Top Performer: NVDA +3.8%
  • Biggest Drop: TSLA -1.2%
  • Crypto: BTC +2.1%, ETH +0.8%
๐Ÿ‘ค

You

Alert me if Apple drops below $180

๐Ÿฆž

Moltbot

โœ… Price alert set!

I'll notify you when AAPL drops below $180.00
Current price: $185.42

๐Ÿ‘ค

You

What's the news on my holdings?

๐Ÿฆž

Moltbot

๐Ÿ“ฐ News Summary for Your Holdings

  • NVDA: New AI chip announcement, stock up 3%
  • AAPL: iPhone sales beat expectations in Asia
  • BTC: ETF inflows continue, nearing ATH

Implementation Guide

1. Portfolio Tracker Skill

// skills/portfolio-tracker.js
module.exports = {
  name: 'portfolio-tracker',
  
  async run({ config, apis }) {
    // Fetch holdings from multiple sources
    const holdings = await Promise.all([
      apis.alpaca.getPositions(),
      apis.coinbase.getAccounts(),
      apis.plaid.getInvestments()
    ]);
    
    // Get current prices
    const symbols = holdings.flat().map(h => h.symbol);
    const prices = await apis.polygon.getPrices(symbols);
    
    // Calculate totals
    const portfolio = holdings.flat().map(position => {
      const currentPrice = prices[position.symbol];
      const value = position.quantity * currentPrice;
      const costBasis = position.quantity * position.avgEntryPrice;
      const pnl = value - costBasis;
      const pnlPercent = (pnl / costBasis) * 100;
      
      return {
        ...position,
        currentPrice,
        value,
        pnl,
        pnlPercent
      };
    });
    
    const totalValue = portfolio.reduce((sum, p) => sum + p.value, 0);
    const totalPnl = portfolio.reduce((sum, p) => sum + p.pnl, 0);
    
    return { portfolio, totalValue, totalPnl };
  }
};

2. Price Alert System

// skills/price-alerts.js
module.exports = {
  name: 'price-alerts',
  
  async run({ config, apis }) {
    const alerts = await apis.db.getAlerts();
    
    for (const alert of alerts) {
      const price = await apis.polygon.getPrice(alert.symbol);
      
      let triggered = false;
      let message = '';
      
      switch (alert.condition) {
        case 'above':
          if (price > alert.target) {
            triggered = true;
            message = `๐Ÿš€ ${alert.symbol} is up! $${price} (target: >$${alert.target})`;
          }
          break;
        case 'below':
          if (price < alert.target) {
            triggered = true;
            message = `๐Ÿ“‰ ${alert.symbol} alert! $${price} (target: <$${alert.target})`;
          }
          break;
        case 'percent_change':
          const change = ((price - alert.referencePrice) / alert.referencePrice) * 100;
          if (Math.abs(change) >= alert.target) {
            triggered = true;
            message = `โšก ${alert.symbol} moved ${change.toFixed(2)}%! Now $${price}`;
          }
          break;
      }
      
      if (triggered) {
        await apis.notify.sendWhatsApp({ message });
        await apis.db.markAlertTriggered(alert.id);
      }
    }
  }
};

3. Daily Portfolio Report

// skills/daily-portfolio-report.js
module.exports = {
  name: 'daily-portfolio-report',
  schedule: '0 16 * * 1-5', // 4 PM weekdays
  
  async run({ config, apis }) {
    // Get portfolio data
    const portfolio = await apis.skills.run('portfolio-tracker');
    
    // Get market summary
    const indices = await apis.polygon.getIndices(['SPY', 'QQQ', 'IWM']);
    
    // Generate AI commentary
    const commentary = await apis.ai.generate({
      prompt: `Analyze this portfolio performance:
        Total Value: $${portfolio.totalValue}
        Day P&L: $${portfolio.totalPnl}
        Top Holdings: ${JSON.stringify(portfolio.portfolio.slice(0, 5))}
        Market: S&P ${indices.SPY.change}%, Nasdaq ${indices.QQQ.change}%
        
        Write a brief, insightful summary.`
    });
    
    // Format report
    const report = formatReport(portfolio, indices, commentary);
    
    await apis.notify.sendWhatsApp({ message: report });
  }
};

function formatReport(portfolio, indices, commentary) {
  const emoji = portfolio.totalPnl >= 0 ? '๐Ÿ“ˆ' : '๐Ÿ“‰';
  return `${emoji} Daily Portfolio Report

๐Ÿ’ฐ Total Value: $${portfolio.totalValue.toLocaleString()}
๐Ÿ“Š Day's P&L: $${portfolio.totalPnl.toLocaleString()} (${(portfolio.totalPnl/portfolio.totalValue*100).toFixed(2)}%)

๐Ÿ›๏ธ Market:
โ€ข S&P 500: ${indices.SPY.change}%
โ€ข Nasdaq: ${indices.QQQ.change}%
โ€ข Russell 2000: ${indices.IWM.change}%

๐Ÿ’ญ Summary:
${commentary}

Reply 'details' for full holdings breakdown.`;
}

Recommended APIs

Alpaca

Commission-free stock trading API with real-time data

alpaca.markets

Polygon.io

Real-time and historical market data for stocks and crypto

polygon.io

Coinbase Pro API

Cryptocurrency trading and account management

docs.pro.coinbase.com

Plaid

Connect to bank and brokerage accounts securely

plaid.com

Important Disclaimer

This tutorial is for educational purposes only. Not financial advice.

  • Always do your own research before making investment decisions
  • Past performance does not guarantee future results
  • Secure your API keys and enable 2FA on all accounts
  • Test thoroughly with paper trading before using real funds

Track Your Wealth

Build a personalized investment tracking system that keeps you informed without the noise of traditional finance apps.