Configuration initiale de l'application

Avant de lancer MagicTradeBot, vous devez configurer l'application de gestion et l'instance principale du bot. Voici des exemples de configuration et des conseils importants pour chaque composant.

🖥️ Application de gestion ASP.NET Core (appsettings.json)

Emplacement : /management/appsettings.json


// appsettings.json (v1.2)
{
  "ConnectionStrings": {
    "SQLLight": "Data Source=Data/MTManagementDB.db",
    "SQLSERVER": "",
    "Postge": "",
    "MySQL": ""
  },
  "ApplicationSettings": {
    "Author": "MagicTradeBot",
    "PageCaption": "Application de gestion MagicTradeBot",
    "Environment": "Development",
    "IsDemo": true,
    "Domain": {
      "Backend": "https://localhost:44353",
      "Frontend": "http://localhost:4200"
    },
    "Localization": {
      "DefaultCulture": "en",
      "Timezone": "America/Los_Angeles",
      "Currency": "USD"
    },
    "Pagination": {
      "DefaultPageSize": 18,
      "MaxPageSize": 100,
      "VisiblePageCount": 5
    },
    "Caching": {
      "Enabled": true,
      "Duration": 3600,
      "MaxCacheSize": "500MB"
    },
    "MaximumUrlCharacters": 60
  },
  "JwtSettings": {
    "SecretKey": "{JWT_SECRET}",
    "Issuer": "$ApplicationSettings:Domain.Backend",
    "Audience": "$ApplicationSettings:Domain.Frontend",
    "Expiration": {
      "AccessToken": "15m",
      "RefreshToken": "7d"
    }
  },
  "SecurityHeaders": {
    "StrictTransportSecurity": "max-age=31536000; includeSubDomains",
    "ContentSecurityPolicy": "",
    "XContentTypeOptions": "nosniff",
    "ReferrerPolicy": "strict-origin-when-cross-origin"
  },
  "Secrets": {
    "Database": {
      "Host": "",
      "Name": "",
      "User": "",
      "Password": ""
    }
  },
  "AllowedHosts": [
    "http://localhost:4200",
    "https://magictradebot.com",
    "*.magictradebot.com"
  ]
}

💡 Conseils rapides

  • Déplacez les clés sensibles comme JwtSettings:SecretKey et Secrets vers des variables d’environnement en production.
  • Assurez-vous que Domain.Backend correspond à l’URL de base de l’API déployée.
  • Utilisez "Environment": "Production" dans les environnements de production pour de meilleures performances et sécurité.

🤖 Configuration du bot Golang (config.yaml)


server:
  # API CONFIGURATION
  api: "https://localhost:44353/"  # Base URL for trading API

general:
  # Name
  botName: "Bybit_Mainnet_Trading_Bot"  # Name of the trading bot (Set Unique Names for each bot instance it multiple bots are running)

  # LICENSE KEY
  licenseKey: "xxxxx" # Valid license key required to operate the bot.

  # DEMO MODE SETTING
  isDemo: true  # true = risk-free simulation, false = real-money trading
    
  # EXECUTION CONTROL
  refreshRate: 7  # Seconds between market scans (lower = faster updates). Adjust to avoid API rate limits
  totalConcurrentTrades: 0  # Max simultaneous trades (0 = unlimited)
    
  # ACCOUNT SETTINGS
  exchangeId: 1   # [Account ID: Get from MagicTradeBot Management App]

  # TRADING STRATEGY
  strategy: 0      # Selected strategy ID:
  strategyMaxCount: 0  # Max strategy progression steps (0 = unlimited)

  # STRATEGY REFERENCE:
  # 0: No strategy
  # 1: Martingale        2: Reverse Martingale
  # 3: Fibonacci         4: Fibonacci Reverse
  # 5: 3-2-6-3           6: 3-2-6-3 Reverse
  # 7: D'Alembert        8: D'Alembert Reverse
  # """

  timeZone: "UTC"  # Timezone for trading operations, time, schedule calculation (e.g., "UTC", "America/New_York")

# SYSTEM SETTINGS
debug: true  # Enable detailed logs (true/false)
kline:
  # KLINE CONFIGURATION
  maxKlineLength: 14  # Max number of candles to keep in memory per symbol / interval
  chunkSize: 20 # total number of symbols fetch per cycle
  refreshRate: 20 # Seconds between Kline updates (lower = faster updates). Adjust to avoid API rate limits
  strategyIntervals:
    scalp:   ["3m", "5m", "15m"]
    day:     ["15m", "30m", "1h", "2h", "4h"]
    swing:   ["1h", "2h", "4h", "6h", "12h"]
    long:    ["1d", "2d", "3d", "7d"]
    default: ["5m", "15m", "1h"]
rateLimits:
  maxRequestsPerSecond: 10  # Max requests per second the exchange allows; exceeding this may cause bans or errors
  safeBuffer: 0.2            # Reduce risk of rate limit violation by using only 80% of the max (1 - safeBuffer)
self_training: 
  enabled: false
  maxGeneratedInputs: 1000
  maxVirtualOrders: 500 
  maxTrainingSymbols: 10 # by increasing numbers make sure your system have enough memory capability to handle as per symbol learning handles thousands of possibilities
  batchIntervalDuration: 6 # 6 hours (in hours) to reset training learning and process (min 2 hours)
  inputs:
    stopLoss: [ 0, 1, 3, 5 ]
    takeProfit: [ 0, 3, 5, 10, 20, 50, 100 ]
    timeTriggerEnabled: [true]
    timeTriggerMinutes: [30]
    timeTriggerModes: [0] # 0: both, 1: only win, 2: loss
    tradeExpiryTrigger: [true] # time exist instead of stop loss / take profit
    tradeExpiryMinutes: [5, 10, 20, 60] # exist after specific minutes
    change: [5, 10, 20, 30] # % change detected 
    tradeDirection: [0, 1] # 0: long, 1: short
    changeDirection: [0, 1] # change direction up / down
    changeInterval: [3, 5, 15] # 3m, 5m, 15m
    changeMatchCreteria: [0, 1, 2] # 0: from start of cancle, 1: from min candle position, 2: from max candle position
    changelayers: [1] # how many layers e.g 2 means two conditions e.g price 2% match in 5m and 1% match in 3m
    symbolcategory: 'general' # e.g bluechip, defi, meme, layer1, layer2, layer3, legacy etc

logging:
  datadog:
    enabled: false
    api_key: "7ce049f9876d08a92a519ab5f6de1d79"
    log_level: "info"
    service_name: "magictradebot"
    environment: "production"
    tags:
      - bot-instance:Bybit_Mainnet_Trading_Bot
      - exchange:Bybit
  logdna:
    enabled: false
    ingest_key: "YOUR_LOGDNA_API_KEY"
    app_name: "magictradebot"
    environment: "production"
    hostname: "bot-eu-1"
    tags:
      - exchange:binance
      - region:eu
  loki:
    enabled: false # Enable Loki for alerts, monitoring, logs
    endpoint: "http://your-loki-server:3100/loki/api/v1/push"
    labels:
      bot_instance: "bot-eu-1"
      exchange: "binance"
      environment: "production"
    log_level: "info"

incident_reporting:
  pagerduty:
    enabled: false # Enable alerts via pagerduty
    integration_key: "YOUR_PAGERDUTY_ROUTING_KEY"
    service_name: "magictradebot"
    severity_threshold: "error"
    environment: "production"

monitoring:
  sentry:
    enabled: false # Enable alerts via sentry
    dsn: "YOUR_SENTRY_DSN"
    environment: "production"
    release: "magictradebot@2.0.0"
    tags:
      instance_id: "bot-apac-01"
      exchange: "binance"

alerting:
  pushover:
    enabled: false # Enable pushover alerts
    user_key: "YOUR_PUSHOVER_USER_KEY"
    api_token: "YOUR_PUSHOVER_API_TOKEN"
    device: "mobile"
    priority: "normal"
    sound: "magic"
    app_name: "magictradebot"

metrics:
  prometheus:
    enabled: false # Enable prometheus
    port: 9100

💡 Conseils rapides

  • Définissez isDemo: true pendant les tests pour éviter les transactions en direct.
  • Utilisez un botName unique pour chaque instance de bot afin de faciliter le filtrage des journaux.
  • Assurez-vous que les valeurs licenseKey et api correspondent à celles de l'application de gestion.
  • strategyMaxCount limite le sur-trading dans les stratégies en boucle comme Martingale.

📎 Related Topics