> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoscripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Customize how Revo Stock Trading behaves for your server and players.

<Info>
  Configuration is done in the <code>config.lua</code> file located in the <code>revo\_stocktrading</code> directory.
</Info>

## Debug Mode

Enable debug prints in console for troubleshooting:

```lua theme={null}
Config.DebugMode = false -- Set to true to enable debug prints in console
```

## UI Opening Methods

Enable opening the trading UI via command or inventory item:

```lua theme={null}
Config.UseCommand = true -- Allow opening UI with command
Config.OpenCommand = 'trade' -- Command to open the Revo Trade UI

Config.UseItem = true -- Allow opening UI with item
Config.ItemName = 'revo_trading_tablet' -- Item name for opening UI (if UseItem is true)
```

## Risk Acknowledgement Popup

Shows a one-time risk warning popup that users must acknowledge before trading:

```lua theme={null}
Config.RiskAcknowledgementPopup = true -- Set to false to disable the risk popup
```

## Liquidation & Risk Control

Set the margin level at which all open trades are liquidated. If margin level (equity / usedMargin \* 100) falls to or below this percent, all open trades are liquidated:

```lua theme={null}
-- Liquidation / Risk Control
-- If margin level (equity / usedMargin * 100) falls to or below this percent, all open trades are liquidated
Config.LiquidationMarginLevel = 50 -- percent (e.g., 50 means liquidate at 50% margin level)
```

## Charting Library

Choose between Lightweight Charts or Highcharts. For Lightweight Charts, no license is required as it is open-source. For Highcharts, you need to get their license according to your situation and provide the URL to the Highcharts lib.

```lua theme={null}
-- Choose between Lightweight Charts or Highcharts
-- For Lightweight Charts, no license is required as it is open-source
-- For Highcharts, you need to get their license according to your situation and provide the URL to the Highcharts lib
Config.ChartLibrary = "lightweight" -- "highcharts" or "lightweight"
-- If using Highcharts, provide the URL to the Highcharts lib (example: https://code.highcharts.com)
Config.HighChartsBaseURL = ""
```

<Warning>
  **Important:** We do NOT include or redistribute Highcharts. If you wish to use it, please obtain your own license from [Highcharts Shop](https://shop.highcharts.com).

  By default, Revo Stock Trading uses Lightweight Charts (MIT Licensed), which requires no additional setup.
</Warning>

## Permissions

Set which groups/roles can access the Stock Management UI (Add, Edit and Delete Stocks). For ESX, group must match (e.g. 'admin', 'superadmin'). For QBCore, role must match (e.g. 'admin', 'god'):

```lua theme={null}
-- Permissions
-- Who can access the Stock Management UI (Add, Edit and Delete Stocks)
-- For ESX, group must match (e.g. 'admin', 'superadmin')
-- For QBCore, role must match (e.g. 'admin', 'god')
Config.AllowedGroups = {
    'admin',
    'superadmin',
    'god'
}
```

## Notification Position

Choose where notifications appear on the screen:

```lua theme={null}
-- Available positions: 'top-left', 'top-right', 'top-center', 'bottom-left', 'bottom-right', 'bottom-center', center-left, center-right, center-center
Config.NotificationPosition = 'top-center' -- Default notification position
```

Available positions:\
`'top-left'`, `'top-right'`, `'top-center'`, `'bottom-left'`, `'bottom-right'`, `'bottom-center'`, `'center-left'`, `'center-right'`, `'center-center'`

## Fixed Leverages

Set leverage values for different asset types. These values are used to determine the leverage for different stock types. More realistic leverage values that balance risk and opportunity:

```lua theme={null}
-- These values are used to determine the leverage for different stock types
-- More realistic leverage values that balance risk and opportunity
Config.FixedLeverages = {
    stock = 10,
    crypto = 25,
    forex = 100,
    commodity = 30
}
```

## Contract Sizes

Set contract sizes for different asset types. These values are used to determine the contract size for different stock types. More realistic contract sizes that require appropriate capital:

```lua theme={null}
-- These values are used to determine the contract size for different stock types
-- More realistic contract sizes that require appropriate capital
Config.ContractSizes = {
    forex = 100000,
    stock = 100,
    commodity = 1000,
    crypto = 1
}
```

## Deposit & Withdraw Limits

Set minimum deposit and withdrawal amounts:

```lua theme={null}
Config.MinimumDeposit = 500 -- Minimum deposit amount
Config.MinimumWithdraw = 20 -- Minimum withdraw amount
```

## Economy Protection - Earning Limits System

These settings help protect your server's economy from exploitation.

### Daily Profit Cap

Maximum profit a player can earn per day from trading:

```lua theme={null}
Config.DailyProfitCap = {
    enabled = true,
    limit = 20000,  -- $20,000 max profit per day (set to 0 or false to disable)
    resetHour = 0   -- Hour of day to reset (0 = midnight server time, 12 = noon, etc.)
}
```

### Daily Withdrawal Limit

Maximum amount a player can withdraw from trading account to bank per day:

```lua theme={null}
Config.DailyWithdrawalLimit = {
    enabled = true,
    limit = 100000,  -- $100,000 max withdrawal per day
    resetHour = 0    -- Hour of day to reset (0 = midnight server time)
}
```

### Loss Attack System

Automatically moves prices against profitable positions to protect your economy. When players are winning too much, the market will push back:

```lua theme={null}
-- Loss Attack System
-- Automatically moves prices against profitable positions to protect your economy
-- When players are winning too much, the market will push back
Config.LossAttack = {
    enabled = true,              -- Enable/disable the system
    strength = "medium",         -- "low", "medium", "high", or "aggressive"
}
```

### Progressive Tax System

Tax profits progressively - higher earnings = higher tax rate. Tax is applied when closing profitable trades:

```lua theme={null}
-- Progressive Tax System
-- Tax profits progressively - higher earnings = higher tax rate
-- Tax is applied when closing profitable trades
Config.ProgressiveTax = {
    enabled = true,
    -- Tax brackets: profits within each range are taxed at that rate
    -- Example: $15,000 profit = ($10,000 * 5%) + ($5,000 * 10%) = $500 + $500 = $1,000 tax
    brackets = {
        { threshold = 10000,      rate = 0.05 },  -- 5% on profits from $0 to $10,000
        { threshold = 25000,      rate = 0.10 },  -- 10% on profits from $10,001 to $25,000
        { threshold = 50000,      rate = 0.15 },  -- 15% on profits from $25,001 to $50,000
        { threshold = 100000,     rate = 0.25 },  -- 25% on profits from $50,001 to $100,000
        { threshold = math.huge,  rate = 0.35 },  -- 35% on profits above $100,000
    }
}
```

## Localization

Set the default language:

```lua theme={null}
-- Available languages: 'en', 'es', 'fr', 'de', 'it', 'pt', 'ru', 'tr', 'pl', 'zh', ar
Config.DefaultLocale = 'en' -- Default locale for the script
```

Available languages: `'en'`, `'es'`, `'fr'`, `'de'`, `'it'`, `'pt'`, `'ru'`, `'tr'`, `'pl'`, `'zh'`, `'ar'`

Customize all UI text in the <code>Config.Locales</code> table.

<Tip>
  Adjust leverages, contract sizes, permissions, economy protection settings, and localization to fit your server's needs. For Highcharts, make sure to provide a valid library URL if you choose that option.
</Tip>
