> For the complete documentation index, see [llms.txt](https://afk-fun.gitbook.io/afkdotfun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://afk-fun.gitbook.io/afkdotfun/get-started/backtesting.md).

# Backtesting

{% hint style="success" %}
Step 1: Create a Strategy
{% endhint %}

<figure><img src="/files/s86rgaocBYFs7xPMYLiT" alt=""><figcaption></figcaption></figure>

**Set filters/parameters for buying tokens:**

* Launch Time: Set min/max token age
* Market Cap: Set min/max market cap
* Liquidity: Set min/max liquidity
* Buy Count: Set min/max # of buys
* Buy Volume: Set min/max vol. of buys
* Sell Count: Set min/max # of sells
* Sell Volume: Set min/max vol. of sells
* Select Bots: Set min. # of buys from specific trading platforms/bots
* Smart Wallets: Add custom smart wallet addresses that you want to copy trade. You can add multiple and set a minimum requirement. For example, if you upload 5 smart wallets, you can set a minimum of 3/5 wallets must buy the same token to trigger your buy tx for that token.
* Scam Wallets: Add custom scam wallet addresses that you want to avoid. You can add multiple and set a minimum requirement. For example, if you upload 5 scam wallets, you can set a minimum of 3/5 scam wallet that must buy the same token before your strategy ignores/avoids that token.

{% hint style="success" %}
Step 2: Select Launch Mode
{% endhint %}

<figure><img src="/files/gFovH2UPpjKIAqhUYu1g" alt=""><figcaption></figcaption></figure>

**Backtesting**

* This will simulate your trading strategy using historical data. You can see an estimated PNL and review all tokens that would have been purchased by following this strategy, including: # of tokens purchased, price, time, and estimated/potential PNL (image below)

**Auto-Trading**

* This will skip backtesting and go straight to setting up live trading. (Add your sell settings in the next step before your strategy goes Active.)

{% hint style="success" %}
Step 3: Add dates for Backtesting
{% endhint %}

<figure><img src="/files/jShBdGnT8WuFCCPRXyFA" alt=""><figcaption></figcaption></figure>

**Add Dates for Backtesting**

* Select a date range for backtesting.
  * There is currently a 5 day limit due to the massive amount of data. (We are working to improve this)
* AFK will simulate trades on these days according to your strategy parameters. When the backtest is complete, you can review your estimated PNL and simulated trades.
  * Depending on the number of days selected, each backtest could take several minutes or more to complete. (We are working to improve this)

{% hint style="success" %}
Step 4: Review Backtest PNL
{% endhint %}

<figure><img src="/files/h7r2mc8pudrDpgsB8rA9" alt=""><figcaption></figcaption></figure>

**Review Backtest PNL**

When the backtest is complete, you can review your estimated PNL and simulated trades. (*Disclaimer: Past performance is no guarantee of future results)*

* Buy Amount
  * For simplicity, we assume a buy amount of $100 for each token you would have purchased according to your trading strategy.
* Tokens Bought
  * This is how many tokens you would have bought according to your trading strategy.
* Take Profit (TP)
  * This is the Take Profit level we are aiming for in our simulated trades. (100%, 200%, etc.)
  * Each Take Profit (TP) level is a separate simulation to see how many tokens would have reached that TP, and what the PNL might look like if all tokens were sold at each TP level.
* PNL
  * This is the estimated PNL according to your Strategy and various TP levels (*Disclaimer: Past performance is no guarantee of future results)*
    * We calculate PNL based on $100 buys for each token.
    * We assume all tokens are sold at the designated TP level. (Each TP level is a separate simulation.)
    * For tokens that did not reach the TP level, we assume worst case scenario, which is selling at the absolute bottom. We consider the bottom market cap to be \~28 SOL (\~$5k)
    * We do not include fees or slippage in our calculations.
* Review Tokens
  * Click here to view all of the tokens that hit each TP level. (more on this in the next step)

{% hint style="success" %}
Step 5: Review Tokens
{% endhint %}

<figure><img src="/files/QbqwhYy0TFdLZzqvrBIN" alt=""><figcaption></figcaption></figure>

**Review Tokens**

See more details about your trades and each token's performance.&#x20;

* Token
  * Name and token address
* Age
  * How long ago the token was created
* MC Buy
  * Estimated market cap of the token when your strategy would have been triggered to buy
* Time of Buy
  * Estimated age of the token when your strategy would have been triggered to buy
* Max PNL
  * Potential PNL from your entry to the token's All Time High, so you can easily view the top performing tokens.
* Platforms (Bots)
  * This is the number of buys from various trading platforms at the time your buy order would have been triggered.
* Chart
  * Quick access to view the chart and live transactions.

{% hint style="info" %}
You can enable [Auto Trading](/afkdotfun/get-started/auto-trading.md) in the next step. If you need help please join our [Support Chat.](/afkdotfun/support/support-chat.md)
{% endhint %}
