OS Trading Engine
Technical Documentation
Configuration
Trading Config Defaults

Trading Config Defaults

Every agent has a trading configuration that controls how it trades. This page documents the default values applied when an agent is created.

Overview

The trading configuration is stored as JSON in the database and cached in Redis. It includes settings for:

  • Purchase Limits - Balance and position size constraints
  • Signal Filtering - Score thresholds, signal types, and token lists
  • Stop Loss - Automatic loss protection
  • Position Sizing - Dynamic position sizes based on balance
  • Stale Trade - Auto-close stuck positions
  • DCA - Dollar cost averaging on dips
  • Take Profit - Partial profit-taking at gain levels

DCA and Take Profit: Both can be enabled on the same agent. The engine evaluates take-profit (on price rises) and DCA (on price drops) independently.


Default Configuration

// packages/shared/src/constants/trading-config-defaults.ts
 
export const DEFAULT_TRADING_CONFIG: AgentTradingConfig = {
  purchaseLimits: {
    minimumAgentBalance: 0.5,
    maxPurchasePerToken: 2.0,
    maxPriceImpact: 0.05, // 5% max slippage
  },
  signals: {
    minScore: 1,              // Accept all signals (1-5)
    allowedSignalTypes: [],   // Empty = accept all types
    tokenFilterMode: 'none',  // Accept all tokens
    tokenList: [],
  },
  stopLoss: {
    enabled: true,
    defaultPercentage: -32,
    mode: 'fixed',
    trailingLevels: [],
  },
  positionCalculator: {
    solBalanceThresholds: {
      minimum: 0.2,
      medium: 5,
      large: 10,
    },
    positionSizes: {
      small: { min: 0.1, max: 0.1 },
      medium: { min: 0.5, max: 1.0 },
      large: { min: 1.5, max: 2.0 },
    },
    randomization: { enabled: true },
  },
  staleTrade: {
    enabled: true,
    minHoldTimeMinutes: 60,
    minProfitPercent: 1,
    maxProfitPercent: 10,
  },
  dca: {
    enabled: false,
    mode: 'moderate',
    levels: [],
    maxDCACount: 3,
    cooldownSeconds: 30,
  },
  takeProfit: {
    enabled: false,
    mode: 'moderate',
    levels: [
      { targetPercent: 50, sellPercent: 25 },
      { targetPercent: 150, sellPercent: 25 },
      { targetPercent: 300, sellPercent: 25 },
      { targetPercent: 400, sellPercent: 15 },
    ],
    moonBag: {
      enabled: true,
      triggerPercent: 300,
      retainPercent: 10,
    },
  },
};

Purchase Limits

Controls when an agent can trade and position sizes.

SettingDefaultDescription
minimumAgentBalance0.5 SOLMinimum balance required to trade
maxPurchasePerToken2.0 SOLMaximum position size per token
maxPriceImpact0.05Max acceptable slippage (5%)
interface PurchaseLimits {
  minimumAgentBalance: number;  // Min SOL balance to trade
  maxPurchasePerToken: number;  // Max SOL per position
  maxPriceImpact?: number;      // Max slippage (0.05 = 5%)
}

Signal Configuration

Filters which signals the agent will act on.

SettingDefaultDescription
minScore1Minimum signal strength (1-5). Default accepts all.
allowedSignalTypes[]Signal types to accept. Empty accepted all types.
tokenFilterMode'none'Token filtering: 'none', 'blacklist', or 'whitelist'
tokenList[]Token addresses for blacklist/whitelist mode
interface SignalConfig {
  minScore: number;              // 1-5 score threshold
  allowedSignalTypes: string[];  // Empty = accept all types
  tokenFilterMode: 'none' | 'blacklist' | 'whitelist';
  tokenList: string[];           // Token addresses for filtering
}

Token Filter Modes

ModeBehavior
'none'Accept signals for any token (default)
'blacklist'Accept all tokens except those in tokenList
'whitelist'Only accept tokens in tokenList

Stop Loss Configuration

Automatic loss protection with trailing stop support.

SettingDefaultDescription
enabledtrueStop loss active
defaultPercentage-32Default stop loss (-32% from purchase)
mode'fixed'Stop loss calculation mode
trailingLevels[]Custom trailing levels (for custom mode)

Stop Loss Modes

ModeDescription
fixedLinear 10% steps. At 50% gain, stop loss is 40%
exponentialLoose at low gains, tighter as profit increases
zones5-zone system with different keep percentages
customUser-defined trailing levels
interface StopLossConfig {
  enabled: boolean;
  defaultPercentage: number;  // Negative = loss from purchase
  mode: 'fixed' | 'exponential' | 'zones' | 'custom';
  trailingLevels: TrailingLevel[];  // Only for 'custom' mode
}
 
interface TrailingLevel {
  change: number;    // Price change % (e.g., 200 = 2x)
  stopLoss: number;  // Keep % of peak (e.g., 90 = keep 90%)
}

Position Calculator

Dynamic position sizing based on agent balance.

Balance Thresholds

ThresholdDefaultDescription
minimum0.2 SOLBelow this, don't trade
medium5 SOLThreshold for medium sizes
large10 SOLThreshold for large sizes

Position Sizes

CategoryMinMaxTrigger
Small0.1 SOL0.1 SOLBalance under 5 SOL
Medium0.5 SOL1.0 SOLBalance 5–10 SOL
Large1.5 SOL2.0 SOLBalance over 10 SOL
interface PositionCalculator {
  solBalanceThresholds: {
    minimum: number;
    medium: number;
    large: number;
  };
  positionSizes: {
    small: { min: number; max: number };
    medium: { min: number; max: number };
    large: { min: number; max: number };
  };
  randomization: {
    enabled: boolean;
  };
}

Randomization

When randomization.enabled is true, position size is randomly chosen between min and max for the applicable tier.


Stale Trade Configuration

Auto-close positions that are stuck with modest gains.

SettingDefaultDescription
enabledtrueStale trade check active
minHoldTimeMinutes60Minimum hold time (1 hour)
minProfitPercent1Close if profit ≥ 1%
maxProfitPercent10Close if profit ≤ 10%
interface StaleTradeConfig {
  enabled: boolean;
  minHoldTimeMinutes: number;
  minProfitPercent: number;
  maxProfitPercent: number;
}

How It Works

  1. Position is held for at least minHoldTimeMinutes
  2. Current P&L is between minProfitPercent and maxProfitPercent
  3. Position is automatically closed to free capital
💡

Set minProfitPercent to a negative value (e.g., -5) to also close losing positions.


DCA Configuration

Dollar cost averaging - buy more when price drops.

SettingDefaultDescription
enabledfalseDCA disabled by default
mode'moderate'DCA template
levels[]Custom levels (for custom mode)
maxDCACount3Maximum DCAs per position
cooldownSeconds30Min time between DCAs
interface DCAConfig {
  enabled: boolean;
  mode: 'aggressive' | 'moderate' | 'conservative' | 'custom';
  levels: DCALevel[];
  maxDCACount: number;
  cooldownSeconds: number;
}
 
interface DCALevel {
  dropPercent: number;  // Trigger at this % drop (e.g., -20)
  buyPercent: number;   // Buy this % more (e.g., 75)
}

DCA Templates

Aggressive

Tighter levels, more frequent DCAs at -10% drops.

Moderate (Default)

Balanced approach with -20% drop triggers.

Conservative

Wider levels, fewer DCAs at -20% drops.

⚠️

DCA levels are measured from the average purchase price, which updates after each DCA buy.

DCA and Take Profit can both be enabled. The engine supports them simultaneously on the same position.


Take Profit Configuration

Partial profit-taking - sell portions of position as price rises.

SettingDefaultDescription
enabledfalseTake profit disabled by default
mode'moderate'Take profit template
levels(see below)Take profit levels
moonBag.enabledtrueEnable moon bag feature
moonBag.triggerPercent300Activate moon bag at 300% gain
moonBag.retainPercent10Keep 10% of original position
interface TakeProfitConfig {
  enabled: boolean;
  mode: 'aggressive' | 'moderate' | 'conservative' | 'moonbag' | 'custom';
  levels: TakeProfitLevel[];
  moonBag: MoonBagConfig;
}
 
interface TakeProfitLevel {
  targetPercent: number;  // Trigger at this % gain (e.g., 50)
  sellPercent: number;    // Sell this % of ORIGINAL position (e.g., 25)
}
 
interface MoonBagConfig {
  enabled: boolean;
  triggerPercent: number;  // Activate at this % gain
  retainPercent: number;   // Keep this % of original position
}

Default Take Profit Levels

LevelTargetSell %Cumulative
150%25%25%
2150%25%50%
3300%25%75%
4400%15%90%
Moon Bag300%+10% retained

Total: 90% sold + 10% moon bag = 100%

Take Profit Templates

Aggressive

Early profit-taking at 25%, 50%, 100%, 200% gains.

Moderate (Default)

Balanced profit-taking at 50%, 150%, 300%, 400% gains.

Conservative

Higher targets at 100%, 200%, 400%, 600% gains.

Moon Bag

Same as moderate but with 10% moon bag retained permanently.

Take Profit and DCA can both be enabled. The engine evaluates them independently on each price update.

Validation: Total sell % across all levels + moon bag retain % must be ≤ 100%.


Type Definitions

Complete type definitions are in packages/shared/src/types/trading-config.ts.

export interface AgentTradingConfig {
  purchaseLimits: PurchaseLimits;
  signals: SignalConfig;
  stopLoss: StopLossConfig;
  positionCalculator: PositionCalculator;
  staleTrade: StaleTradeConfig;
  dca: DCAConfig;
  takeProfit: TakeProfitConfig;
}