A Python-based AlgoTrading bot and a backtesting and execution framework to optimize a custom capital-recovery strategy.
This project is a quantitative analysis and automation tool built to test and deploy a Custom Capital Recovery Strategy.
Initially conceptualized based on a manual trading strategy proposed by my father, I sought to automate the execution to execute trades with high frequency and to remove emotional bias and latency. However, I quickly realized that the strategy carried inherent mathematical risks. To address this, I built a Python Simulation Engine to backtest lakhs of trade sequences, allowing me to mathematically tune the parameters for profitability before risking real capital.
Binary options are financial estimates based on a simple "Yes/No" proposition. In the 1-minute timeframe utilized by this project, the prediction focuses strictly on where the asset price (e.g., EUR/USD) will be exactly 60 seconds after the trade is executed.
- Call (High): Predicting the price will end higher than the entry point.
- Put (Low): Predicting the price will end lower than the entry point.
- Outcome: A correct prediction returns the investment plus a fixed payout percentage (typically 70%–90%). An incorrect prediction results in the loss of the trade amount.
The core logic is a variation of a Cost-Averaging/Recovery System based on trade chains.
The strategy relies on a concept called the Continuous Trade Chain. For simplified understanding, let us assume our return rate is 100%
The chain starts with a base trade of suppose 1$ if the result is profit the chain is ended and a new chain starts. If a loss occurs, we double the trade amount $2 in the next trade, if this also suffers a loss, we continue applying the same logic.
So at any general trade, our lost amount will be 1+2+4+8...2^n and the final trade would be yielding a profit of 2^n+1 as 2^n+1 > 1+2+4+8...2^n, we get a net profit.
The logic suggests that by "going on" indefinitely, the bot maximizes the volume of trades, allowing probability to play out over time rather than relying on a single lucky guess.
In a specific "Trade Chain," if a trade results in a loss, the subsequent trade's stake (
Where k is optimized to cover the broker's payout ratio.
- Entry: Trigger a trade based on signal.(I just took random call and put signals as we had no aim of predicting.)
-
Win: Reset stake to Base Amount (
$S_{base}$ ). -
Loss: Multiply stake by
$k$ and immediately re-enter. -
Stop: If the chain length exceeds
$N$ trades (Stop Loss), reset to$S_{base}$ to preserve remaining capital.
Problem: The strategy theoretically guarantees a win eventually, but it requires infinite capital. In reality, an exponential growth of stakes (
Problem: Picking arbitrary values for
- I wrote a Python script using the
randommodule to simulate millions of trade outcomes based on the broker's win/loss probability (i took approx. 50/50). -
Optimization: The engine tested various combinations of
$k$ and$N$ . -
Result: I tried to identify the "Sweet Spot"—a specific Stop Loss limit that maximized the probability of net profit while keeping the risk of "Account Blowout" statistically low (e.g.,
$< 1%$ ).
I had tested my bot for around 3 days (1400 trades) continuosly before the optimization, and the results were quite astonishing, I started out with a
-
📄 View History: /trade_history/trading_history.html
-
I lost my Tradebot code which i initially used in my laptop hard drive failure. Bu t I have included the simulation engine jupyter notebook and trade history
- Python (Simulation & Logic)
- IQOption API (Execution Interface)
- Statistical Analysis (Probability tuning)
This project was developed for educational and research purposes. Binary Options trading carries a high level of risk, and this code is not financial advice.