MOCK
SPY $--- ---%
--
QQQ $--- ---%
--
IWM $--- ---%
--
AAPL $--- ---%
--
MSFT $--- ---%
--
GOOGL $--- ---%
--
TSLA $--- ---%
--
AMZN $--- ---%
--
NVDA $--- ---%
--
BABA $--- ---%
--
CRM $--- ---%
--
INTC $--- ---%
--
AMD $--- ---%
--
UBER $--- ---%
--
LYFT $--- ---%
--
SHOP $--- ---%
--
PYPL $--- ---%
--
SQ $--- ---%
--
ROKU $--- ---%
--
META $--- ---%
--
JPM $--- ---%
--
V $--- ---%
--
NFLX $--- ---%
--
DIS $--- ---%
--
ZOOM $--- ---%
--
DOCU $--- ---%
--
SNOW $--- ---%
--
PLTR $--- ---%
--
GME $--- ---%
--
AMC $--- ---%
--
GLD $--- ---%
--
BNO $--- ---%
--
BTC-USD $--- ---%
MOCK

API Documentation

DTJ Trading Journal REST API Reference

Authentication

All API endpoints require user authentication through session cookies. Login through the web interface to establish a session.

POST /login
Content-Type: application/x-www-form-urlencoded

email=user@example.com&password=yourpassword

Key Performance Indicators

Get Account KPIs

GET /api/kpis/{account_id}

Parameters:

  • account_id (required): Account ID, use 0 for all accounts
  • month (optional): Filter by month (1-12)
  • year (optional): Filter by year (YYYY)

Response:

{
  "total_pnl": 1250.75,
  "total_pnl_pct": 12.5,
  "avg_win": 45.32,
  "avg_loss": -23.18,
  "win_rate": 68.5,
  "profit_factor": 1.95,
  "total_trades": 147,
  "win_trades": 101,
  "loss_trades": 46,
  "max_drawdown_pct": 8.3,
  "max_drawdown_amount": 185.42,
  "win_months_pct": 75.0,
  "open_positions": 5,
  "total_book_value": 2840.50
}

Market Data

Get Stock Prices

GET /api/stock_prices

Response:

{
  "success": true,
  "data": [
    {
      "symbol": "AAPL",
      "price": 189.25,
      "change": 2.35,
      "changePercent": 1.26,
      "timestamp": "2025-01-02T15:30:00Z",
      "previousClose": 186.90,
      "high": 190.45,
      "low": 188.12,
      "open": 188.50,
      "source": "finnhub_live"
    }
  ],
  "source": "🔴 LIVE - Finnhub API (25/33)",
  "live_count": 25,
  "total_count": 33
}

Get Calendar Events

GET /api/calendar_events

Response:

{
  "earnings": [
    {
      "symbol": "AAPL",
      "company": "Apple Inc.",
      "time": "After Market Close",
      "eps_estimate": "$1.50",
      "type": "earnings",
      "date": "01/15/2025"
    }
  ],
  "economic": [
    {
      "time": "Live Data",
      "event": "Economic Calendar provided by Investing.com",
      "importance": "High",
      "type": "economic",
      "date": "01/15/2025"
    }
  ]
}

Trading Data

Get Cumulative P&L

GET /api/cumulative_pnl/{account_id}

Parameters:

  • account_id: Account ID, use 0 for all accounts
  • month (optional): Filter by month
  • year (optional): Filter by year

Response:

{
  "labels": ["2024-01-15", "2024-01-16", "2024-01-17"],
  "cumulative_values": [125.50, 89.20, 234.75]
}

Get Monthly Returns

GET /api/monthly_returns/{account_id}

Response:

{
  "2024": {
    "1": {"return": 5.2, "trades": 23, "wins": 15, "losses": 8},
    "2": {"return": -2.1, "trades": 18, "wins": 9, "losses": 9}
  }
}

Get Account Performance

GET /api/account_performance

Response:

[
  {
    "id": 1,
    "name": "Main Account",
    "total_pnl": 1250.75,
    "pnl_percentage": 12.5,
    "closed_trades": 45,
    "total_trades": 50
  }
]

Feedback System

Submit Feedback

POST /api/feedback

Request Body:

type=bug&subject=Login Issue&message=Cannot login with my account&email=user@example.com

Parameters:

  • type (required): bug, feature, improvement, general
  • subject (required): Brief description
  • message (required): Detailed feedback
  • email (optional): Contact email

Response:

{
  "success": true,
  "message": "Feedback sent successfully!"
}

Payment Integration

PayPal Subscription Success

POST /api/paypal/subscription-success

Request Body:

{
  "orderID": "5O190127TN364715T",
  "payerID": "UFGNBCVJY6K8C",
  "paymentID": "PAY-1B56960729604284TKQQIYVY",
  "plan": "premium",
  "amount": "24.50"
}

Response:

{
  "success": true,
  "message": "Subscription activated successfully",
  "subscription_plan": "premium",
  "subscription_end": "2026-01-15T12:00:00"
}

Analytics & Insights

Get Historical Performance

GET /api/historical_performance/{account_id}

Response includes:

  • Day and month performance breakdowns
  • Symbol performance analysis
  • Strategy performance metrics
  • Holding period analysis
  • AI-generated insights and recommendations
  • Best/worst performers identification

Get Trade Type Performance

GET /api/trade_type_performance/{account_id}

Response:

{
  "Swing": {
    "pnl": 845.30,
    "count": 25,
    "wins": 18,
    "losses": 7,
    "win_rate": 72.0,
    "avg_pnl": 33.81
  },
  "Day Trading": {
    "pnl": 245.60,
    "count": 45,
    "wins": 28,
    "losses": 17,
    "win_rate": 62.2,
    "avg_pnl": 5.46
  }
}

Error Handling

Error Response Format

All API endpoints return consistent error responses:

{
  "success": false,
  "error": "Detailed error message",
  "code": "ERROR_CODE"
}

Common HTTP Status Codes:

  • 200 - Success
  • 400 - Bad Request (missing or invalid parameters)
  • 401 - Unauthorized (not logged in)
  • 404 - Not Found
  • 500 - Internal Server Error

Rate Limiting

API endpoints are rate-limited to ensure fair usage:

  • Market Data: 100 requests per hour
  • Analytics: 500 requests per hour
  • General APIs: 1000 requests per hour

Rate limits are per user session and reset every hour.

SDK Examples

JavaScript (Browser)

// Get KPIs for all accounts
fetch('/api/kpis/0')
  .then(response => response.json())
  .then(data => {
    console.log('Total P&L:', data.total_pnl);
    console.log('Win Rate:', data.win_rate + '%');
  })
  .catch(error => console.error('Error:', error));

// Submit feedback
const feedbackData = new FormData();
feedbackData.append('type', 'bug');
feedbackData.append('subject', 'Login Issue');
feedbackData.append('message', 'Cannot access dashboard');

fetch('/api/feedback', {
  method: 'POST',
  body: feedbackData
})
.then(response => response.json())
.then(data => console.log('Feedback submitted:', data.success));

Python

import requests

# Login first to establish session
session = requests.Session()
login_response = session.post('https://your-dtj-domain.replit.app/login', {
    'email': 'your@email.com',
    'password': 'yourpassword'
})

# Get KPIs
kpis_response = session.get('https://your-dtj-domain.replit.app/api/kpis/0')
kpis_data = kpis_response.json()

print(f"Total P&L: ${kpis_data['total_pnl']}")
print(f"Win Rate: {kpis_data['win_rate']}%")

# Get stock prices
stocks_response = session.get('https://your-dtj-domain.replit.app/api/stock_prices')
stocks_data = stocks_response.json()

for stock in stocks_data['data'][:5]:  # First 5 stocks
    print(f"{stock['symbol']}: ${stock['price']} ({stock['changePercent']:+.2f}%)")

Support & Contact

For API support and questions:

  • Email: DTJ.support@xartatech.com
  • Response Time: 24-48 hours for technical inquiries
  • Feedback System: Use the in-app feedback button for bug reports and feature requests

Tip: Include your account email and specific error messages when reporting API issues for faster resolution.