Skip to content

Traderion Dashboard System

The Traderion Dashboard provides a real-time, terminal-based user interface for monitoring and interacting with trading bots. It displays critical information such as market prices, position details, and bot events in an organized, easy-to-read format.

Features

  • Real-time Updates: The dashboard updates continuously as new data becomes available
  • Position Tracking: Monitor your current position, PnL, and rate
  • Market Price Display: View current bid, ask, and open prices
  • Event History: Track bot actions and market events
  • Strategy-specific Panels: Custom panels for different bot types (EMA, Clients, Composite)
  • Error Handling: Robust error logging and display
  • User Controls: Simple keyboard controls for interaction

Dashboard Layout

┌────────────────────────────────────────────────────────────────┐
│                    Traderion Bot Dashboard                     │
├────────────────────────────────────────────────────────────────┤
│ Position Overview                                              │
│   Amount:      0.0000                                          │
│   PnL:         0.0000                                          │
│   Rate:        0.0000                                          │
│                                                                │
│ Market Prices                                                  │
│   Bid:         0.0000                                          │
│   Ask:         0.0000                                          │
│   Open:        0.0000                                          │
│                                                                │
│ Bot Status                                                     │
│   Status:  Running                                             │
│   Action:  Last action performed                               │
│                                                                │
│ Recent Events                                                  │
│   12:34:56 | Event Type: Event details                         │
│   12:34:55 | Event Type: Event details                         │
│   12:34:54 | Event Type: Event details                         │
│                                                                │
│ Strategy-specific Panel                                        │
│   Data 1: Value                                                │
│   Data 2: Value                                                │
│   Data 3: Value                                                │
│                                                                │
│ Press 'q' to quit                                              │
└────────────────────────────────────────────────────────────────┘

Using the Dashboard

The dashboard is designed to be easy to use and integrate with your trading bots. Here's how to get started:

Basic Usage

  1. Create a dashboard instance:

    from traderion.dashboard import Dashboard
    dashboard = Dashboard(title="My Trading Bot")
    

  2. Run your bot with the dashboard:

    dashboard.run_dashboard(run_bot, (dashboard,))
    

  3. In your bot, update the dashboard with relevant information:

    # Update core data
    dashboard.update_core_data('status', 'Running')
    dashboard.update_core_data('last_action', 'Placed order')
    
    # Add events
    dashboard.add_bot_event('Order', 'Placed buy order')
    dashboard.add_market_event('Price Change', 'Bid increased')
    
    # Add performance metrics
    dashboard.add_performance_metric('PnL Change', 10.5)
    

Adding Custom Panels

You can add custom panels to display strategy-specific information:

  1. Create a panel function:

    from traderion.dashboard import create_ema_panel
    
    # Use a pre-defined panel
    ema_data = {'small_ema': 100.5, 'big_ema': 101.2, 'last_cross': 'Bullish', 'target_amount': 1000}
    ema_panel = create_ema_panel(ema_data)
    
    # Or create a custom panel
    def my_custom_panel(stdscr, y, x, height, width):
        stdscr.addstr(y, x, "My Strategy", curses.A_BOLD)
        stdscr.addstr(y + 1, x + 2, "Data 1: Value")
        stdscr.addstr(y + 2, x + 2, "Data 2: Value")
    

  2. Add the panel to the dashboard:

    dashboard.add_custom_panel(ema_panel)
    # or
    dashboard.add_custom_panel(my_custom_panel)
    

Pre-defined Panel Types

The dashboard comes with several pre-defined panel types:

EMA Panel

Displays Exponential Moving Average strategy information: - Small EMA value - Big EMA value - Last cross direction - Target amount

from traderion.dashboard import create_ema_panel

ema_data = {
    'small_ema': 100.5,
    'big_ema': 101.2,
    'last_cross': 'Bullish',
    'target_amount': 1000
}
dashboard.add_custom_panel(create_ema_panel(ema_data))

Clients Panel

Displays client interaction strategy information: - Market Maker acceptance rate - Market Taker acceptance rate - Last client call details - Last deal amount and price

from traderion.dashboard import create_clients_panel

clients_data = {
    'accepted_mm_calls': 5,
    'total_mm_calls': 10,
    'accepted_mt_calls': 3,
    'total_mt_calls': 7,
    'last_client_call': 'BID',
    'last_deal_amount': 1000,
    'last_deal_price': 100.5
}
dashboard.add_custom_panel(create_clients_panel(clients_data))

Composite Panel

Displays information for multiple strategies:

from traderion.dashboard import create_composite_panel

strategies_data = {
    'EMA': 'Bullish cross detected',
    'RSI': 'Oversold (28.5)',
    'MACD': 'Signal line crossed'
}
dashboard.add_custom_panel(create_composite_panel(strategies_data))

Error Handling

The dashboard includes robust error handling to help diagnose issues:

  1. Errors are logged to ./logs/dashboard_debug.log
  2. Critical errors are displayed on the dashboard
  3. Detailed error information is printed to the console

If you encounter issues: 1. Check the log file for detailed error messages 2. Look for error messages on the dashboard 3. Check the console output for additional information

Testing the Dashboard

A test script is provided to verify the dashboard is working correctly:

python -m traderion.examples.test_dashboard

This will run a simple bot that updates the dashboard with random data, allowing you to see how the dashboard looks and behaves without connecting to the Traderion API.

Creating Custom Dashboards

You can create your own custom dashboard by extending the Dashboard class:

from traderion.dashboard import Dashboard

class MyCustomDashboard(Dashboard):
    def __init__(self, title="My Custom Dashboard", max_history=100):
        super().__init__(title, max_history)
        # Add custom initialization

    def draw_dashboard(self, stdscr):
        # Override the draw_dashboard method to customize the layout
        # ...

Best Practices

  1. Update Frequently: Update the dashboard regularly to provide real-time information
  2. Use Clear Event Names: Use descriptive event names and data to make the dashboard easy to understand
  3. Handle Errors: Catch and log errors to help diagnose issues
  4. Customize for Your Strategy: Add custom panels to display strategy-specific information
  5. Keep It Simple: Focus on the most important information to avoid cluttering the dashboard