Disconnected
Loading...

Upload Strategy

Strategy Upload Form

Upload your trading strategy to share it with the community

Generate your strategy with AI

  1. Copy the prompt
  2. Paste it into ChatGPT or Claude
  3. Copy the generated Python code
  4. Upload the `.py` file here
Create a Python trading strategy compatible with QuantNest.

STRICT REQUIREMENTS:

1. You must define exactly this function:

def run_backtest(preset="default", days=30, config=None, candles=None, timeframe="1d"):

2. The input candles are a list of dictionaries with:

* t (timestamp in milliseconds) OR t0 (timestamp in seconds)
* o (open)
* h (high)
* l (low)
* c (close)
* v (volume, optional)

3. You must return exactly this structure:

{
"summary": {
"total_return": float,
"max_drawdown": float,
"sharpe_ratio": float,
"win_rate": float,
"total_trades": int
},
"trades": []
}

4. Rules:

* Use only Python standard library
* Do not use external packages
* The function must be deterministic
* It must not crash when candles is empty
* It must always return valid numeric values

5. Strategy logic:

* Use a realistic trading idea
* Keep the code clear and runnable
* Do not include explanations outside the code

Return ONLY valid Python code.