Skip to main content

Overview

The Rithmic integration enables automatic synchronization of trades from your Rithmic trading platform into Deltalytix for analysis and reporting.
Rithmic integration requires valid Rithmic account credentials and appropriate API access permissions.

Features

  • Real-time trade synchronization
  • Multiple account support
  • Automatic sync scheduling
  • Order and performance data processing
  • Secure credential storage

Setup Instructions

Step 1: Configure Synchronization

Create a synchronization configuration for your Rithmic account:
import { setRithmicSynchronization } from '@/app/[locale]/dashboard/components/import/rithmic/sync/actions'

const synchronization = {
  service: 'rithmic',
  accountId: 'your-account-id',
  lastSyncedAt: new Date()
}

await setRithmicSynchronization(synchronization)
See app/[locale]/dashboard/components/import/rithmic/sync/actions.ts:15-38

Step 2: Verify Configuration

Check your synchronization settings:
import { getRithmicSynchronizations } from '@/app/[locale]/dashboard/components/import/rithmic/sync/actions'

const synchronizations = await getRithmicSynchronizations()

console.log('Active Rithmic synchronizations:', synchronizations)
See app/[locale]/dashboard/components/import/rithmic/sync/actions.ts:6-13

Step 3: Start Syncing

Once configured, trades will be automatically synchronized based on your sync schedule. The integration processes:
  • Order executions
  • Fill data
  • Performance metrics
  • Account information

API Reference

GET /api/rithmic/synchronizations

Retrieve all Rithmic synchronization configurations for the current user. Response:
{
  success: boolean
  data: Array<{
    userId: string
    service: 'rithmic'
    accountId: string
    lastSyncedAt: Date
    createdAt: Date
    updatedAt: Date
  }>
}
Example:
const response = await fetch('/api/rithmic/synchronizations')
const data = await response.json()

if (data.success) {
  console.log('Synchronizations:', data.data)
}
See app/api/rithmic/synchronizations/route.ts:9-26

POST /api/rithmic/synchronizations

Create or update a Rithmic synchronization configuration. Request Body:
{
  service?: 'rithmic'     // Default: 'rithmic'
  accountId: string       // Required: Account identifier
  lastSyncedAt?: Date     // Optional: Last sync timestamp
}
Response:
{
  success: boolean
  message: string
}
Example:
const response = await fetch('/api/rithmic/synchronizations', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    accountId: 'RITHMIC_12345',
    lastSyncedAt: new Date()
  })
})

const result = await response.json()
console.log(result.message)
See app/api/rithmic/synchronizations/route.ts:28-51

DELETE /api/rithmic/synchronizations

Remove a Rithmic synchronization configuration. Request Body:
{
  accountId: string  // Required: Account to remove
}
Response:
{
  success: boolean
  message: string
}
Example:
const response = await fetch('/api/rithmic/synchronizations', {
  method: 'DELETE',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ accountId: 'RITHMIC_12345' })
})

const result = await response.json()
if (result.success) {
  console.log('Synchronization removed')
}
See app/api/rithmic/synchronizations/route.ts:53-84

Synchronization Flow

Database Schema

Rithmic synchronization data is stored in the Synchronization table:
model Synchronization {
  userId         String
  service        String   // 'rithmic'
  accountId      String
  token          String?  // Not used for Rithmic
  tokenExpiresAt DateTime?
  lastSyncedAt   DateTime
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt
  
  @@unique([userId, service, accountId])
}

Upsert Logic

Configurations are upserted using a composite unique key:
await prisma.synchronization.upsert({
  where: { 
    userId_service_accountId: {
      userId: userId,
      service: 'rithmic',
      accountId: synchronization.accountId
    }
  },
  update: {
    lastSyncedAt: synchronization.lastSyncedAt || new Date(),
    updatedAt: new Date()
  },
  create: {
    userId: userId,
    service: 'rithmic',
    accountId: synchronization.accountId,
    lastSyncedAt: synchronization.lastSyncedAt || new Date()
  }
})
See app/[locale]/dashboard/components/import/rithmic/sync/actions.ts:18-37

Components

The Rithmic integration includes several UI components:

Synchronization Components

ComponentPurposeLocation
rithmic-sync-connection.tsxManage connection settingsapp/[locale]/dashboard/components/import/rithmic/sync/
rithmic-sync-progress.tsxDisplay sync progressapp/[locale]/dashboard/components/import/rithmic/sync/
rithmic-credentials-manager.tsxHandle credential inputapp/[locale]/dashboard/components/import/rithmic/sync/
rithmic-notifications.tsxShow sync notificationsapp/[locale]/dashboard/components/import/rithmic/sync/
sync-countdown.tsxNext sync countdown timerapp/[locale]/dashboard/components/import/rithmic/sync/

Data Processing Components

ComponentPurposeLocation
rithmic-order-processor-new.tsxProcess order dataapp/[locale]/dashboard/components/import/rithmic/
rithmic-performance-processor.tsxCalculate performance metricsapp/[locale]/dashboard/components/import/rithmic/

Error Handling

Common Errors

Error: User not authenticatedCause: The user’s session has expired or is invalidSolution:
// Check authentication before making requests
const userId = await getUserId()
if (!userId) {
  throw new Error('Please log in to continue')
}
Error: accountId is requiredCause: Missing accountId in request bodySolution:
// Always include accountId
await fetch('/api/rithmic/synchronizations', {
  method: 'DELETE',
  body: JSON.stringify({ 
    accountId: 'RITHMIC_12345'  // Required
  })
})
Error: Failed to update synchronizationCause: Database constraint violation or network errorSolution:
  • Verify the accountId format is correct
  • Check database connectivity
  • Ensure unique constraints are not violated

Security Considerations

Rithmic credentials should be handled with extreme care:
  • Never log credentials in production
  • Store encrypted in the database
  • Use environment variables for sensitive configuration
  • Implement rate limiting on API endpoints

Credential Storage

While the Synchronization table has a token field, Rithmic credentials should be handled according to your security requirements:
// DO NOT store plain-text credentials
// Instead, use encrypted storage or secure vaults

const encryptedCredentials = await encryptCredentials({
  username: rithmicUsername,
  password: rithmicPassword
})

await setRithmicSynchronization({
  accountId: accountId,
  token: encryptedCredentials  // Encrypted!
})

User Isolation

All operations are scoped to the authenticated user:
export async function getRithmicSynchronizations() {
  const userId = await getUserId()  // Get current user
  
  // Only return this user's synchronizations
  const synchronizations = await prisma.synchronization.findMany({
    where: { 
      userId: userId,      // User-specific
      service: "rithmic" 
    },
  })
  
  return synchronizations
}
See app/[locale]/dashboard/components/import/rithmic/sync/actions.ts:6-13

Best Practices

Regular Syncs

Schedule synchronization to run automatically at regular intervals

Error Monitoring

Implement logging and alerting for sync failures

Data Validation

Validate trade data before saving to database

Connection Testing

Test Rithmic connection before enabling automatic sync

Troubleshooting

Sync Not Running

  1. Check if synchronization is configured:
const syncs = await getRithmicSynchronizations()
if (syncs.length === 0) {
  console.log('No synchronizations configured')
}
  1. Verify lastSyncedAt timestamp:
syncs.forEach(sync => {
  const hoursSinceSync = 
    (Date.now() - sync.lastSyncedAt.getTime()) / (1000 * 60 * 60)
  console.log(`Last synced ${hoursSinceSync.toFixed(1)} hours ago`)
})
  1. Check for errors in server logs

No Trades Appearing

  • Ensure Rithmic account has completed trades
  • Verify account ID matches your Rithmic account
  • Check if order processor is running
  • Review performance processor for data transformation errors

Next Steps

View Synchronizations

Manage your Rithmic connections

Monitor Performance

Analyze your synchronized trades

Build docs developers (and LLMs) love