### **PROJECT TITLE:** Build a Forex Multi-Basket Trading Bot for OANDA (Python v20 REST API Only) --- ### ** MANDATORY DEVELOPER REQUIREMENTS (PLEASE READ BEFORE APPLYING):**Do not apply for this project unless you meet the following strict professional criteria:1. **Deep Mathematical & Quantitative Background:** You must thoroughly understand statistical distributions, rolling standard deviations (σ), calculating matrix medians, and dynamic Z-score normalization models.2. **Advanced Python Software Engineering:** You must have extensive experience writing high-performance, asynchronous, or multi-threaded Python applications using low-overhead libraries. 3. **Proven Algorithmic Trading Bot Experience:** You must have a portfolio of successfully deployed trading robots. Deep knowledge of connecting securely to OANDA’s v20 REST and Streaming APIs is mandatory. 4. **Clean Code & Logical Architecture:** I am looking for a professional who writes correct, modular, beautifully commented code. Hackers or developers who write sloppy, bloated code will be immediately disqualified. --- ### **PROJECT DESCRIPTION:** Hello, I want an expert developer to build an automated trading bot written in Python. It must connect to my OANDA account using the official v20 REST API and streaming pricing channels.  The bot runs a "Statistical Arbitrage" strategy across 24 unique currency pairs. To keep the math clean and robust, the pairs are split into 4 separate baskets. Every basket has 5 pairs (or less), no pair is repeated, and every pair inside a basket shares the exact same common currency in either the base (numerator) or the quote (denominator). ### ** CRUCIAL VPS HARDWARE LIMITS (READ BEFORE CODING)**This bot will run on a budget Windows VPS with 2 CPU Cores and 2 GiB of RAM. * **IMPORTANT:** There is another active trading bot already running on this server. It uses about 62% of the memory. This means your script has less than 760 MiB of free RAM to work with. * **Optimization Rules:** The code must be exceptionally lightweight. Run it purely as a background command-line script (no memory-heavy visual GUI windows). You must use fixed arrays like `collections.deque(maxlen=100)` for processing historical queues so memory never leaks or grows. Write event logs to simple text or `.csv` files, not a heavy local database.Your advise to make it better is also welcom,specially on technical sids as well as on maths. --- ### ** STEP-BY-STEP LOGIC THE CODE MUST FOLLOW:** **Step 1: Baseline & Inversion Control*** The bot tracks data on an adjustable time window (like a 1-minute rolling frame,less or more all in adjustable toggles). * If a pair inside a basket has its core currency flipped (for example, USDCAD when tracking USD baseline strength), the bot must mathematically invert the price (1 / Price) before doing anything else. **Step 2: Silence Circuit Breaker (Safety Filter)*** Calculate the percentage change for each pair from the start of the 1-minute window.* Check each pair against its own historical volatility (Standard Deviation over the last 100 periods).* If a pair's absolute move is less than half of its historical volatility (Move < 0.5 × Standard Deviation), flag it as "Silent".* **The Guardrail:** If 3 or more pairs in a 5-pair basket are flagged as "Silent", the market lacks momentum or is distorted by a one-pair news spike. Stop calculating for that basket immediately to save CPU power. Do not trade. **Step 3 & 4: Basket Median Anchor & Residuals*** If the basket passes the safety check, sort the 5 returns and calculate the Median (the mathematical average of the two middle numbers).* Subtract this Median from each pair's return to find its Residual Distance. **Step 5 & 6: Final Trigger Z-Score & Ranking*** Divide each pair's Residual Distance by its own individual Historical Standard Deviation. This gives the final Z-Score.* Rank the 5 pairs from Rank 1 (Highest Z-Score / Fastest Leader) to Rank 5 (Lowest Z-Score / Slowest Laggard). ** If any open trade closed manually, the new trade should never start from the same point. The bot should pause a minute and then start for new calculations from zero. --- ### ** BOT CONTROLS & SAFETY FEATURES (TOGGLES):*** **Leader Switch:** True/False toggle. If True, open an OANDA Market Order to sell/short the overextended leader.* **Laggard Switch:** True/False toggle. If True, place a passive OANDA Buy Limit Order slightly below the market price (like -0.2 pips) to catch the catch-up wave.* **Fixed Pair Mode:** Dropdown option to lock actual trading execution strictly to one favorite pair (like AUDUSD), using the other 3 items in its basket only as indicators.* **Staggered Time Delay Engine:** To stop my VPS CPU from spiking, the ALL baskets must calculate at slightly different times. For example, process Basket 1 at second 02 of the minute, Basket 2 at second 04, Basket 3 at second 06, up to last Basket at second 12. * **Netting Account Rule:** The bot must check active positions before placing a trade. It is strictly blocked from opening a new trade in the opposite direction of an existing open position on the same instrument.* **Risk Inputs:** Input boxes for Max Open Trades, Max Daily Loss (%), Max Spread Filter, and News Time Blockouts. Please apply with a description of your mathematical background, your previous bot writing experience, your estimated development timeline. Thank you!