工作已完成
指定
https://www.notion.so/Hedging-Trades-1d6b97def6bd8093a063c4197e7beb7e?pvs=4
Parameters
-
Spot Gold Symbol
-
Spot Future Symbol
-
Initial Lot Size
-
Hedge Distance
-
Lot Sequence
-
TP for Initial Trade
-
TP Sequence For Hedge
TP = Difference of all buy qty and all sell qty * pips
Include Spread/swap/commission in all transactions
-
Trigger pairs
- Trigger position count
-
Trade Closure
- Last trade Position Count
- Add Futures as last trade
- Future TP
- Close last trade
- Add Futures as last trade
- Last trade Position Count
-
Parallel trades
- Max parallel trades
Initial Lot - 0.02; Hedge distance: 2
- Open Buy
- Set TP for Buy (TP for Initial Trade)
- If the price moves down to the hedge distance, trigger the Hedge trade with the first qty in lot sequence.
| Price | Buy | Sell |
|---|---|---|
| 100 | 0.02 |
- Price moves down
- Remove the TP for Buy; check for TP for the combined trade
- If the price comes to 100, close the initial buy at 0 loss/profit and trigger a buy with the next qty in the lot sequence.
| Price | Buy | Sell |
|---|---|---|
| 100 | 0.02 | |
| 98 | 0.04 |
- Price comes back to 100
- Check for TP for the combined trade
- If the price moves back to 98, check if more hedge is to be triggered or pair trades to be triggered. If pair trades
| Price | Buy | Sell |
|---|---|---|
| 100 | 0.02 0.08 | |
| 98 | 0.04 |
- The price comes to 98
- Close the inital sell and open pair trades
- New Sell = 2 * Inital Buy; ( 2*0.08=0.16)
- Buy = New Sell - (Inital Buy /2); ( 0.16 - 0.08/2)=0.12
- Close the inital sell and open pair trades
| Price | Buy | Sell |
|---|---|---|
| 100 | 0.02 0.08 | |
| 98 | 0.12 | 0.04 0.16 |
Case 1: Now check for the TP of all three trades based on the TP sequence. When the price goes above 100
Case 2: Close the 0.08 Buy and 0.16 Sell at 0 profit/loss when the price goes below 98 and trigger another pair trade if the trade count is not equal to the last trade position count.
| Price | Buy | Sell |
|---|---|---|
| 100 | 0.02 0.08 | |
| 98 | 0.12 | 0.04 0.16 |
| 96 | 0.18 | 0.24 |
Case 1: Now check for the TP of all three trades based on the TP sequence. When the price goes above 98
Case 2: Close the 0.12 Buy and 0.24 Sell at 0 profit/loss when the price goes below 96 and trigger another pair trade if the trade count is not equal to the last trade position count.
Keep looping this until the last trade position is hit
If last trade position count is hit
-
If Add Futures as last trade is ON
Example here, close the buy and sell pairs and the last buy will be active, and to the same qty of the buy trigger, a gold futures at the same instance when closing the pairs.
Price Buy Sell 100 0.02 0.08 98 0.12 0.04 0.16 96 0.18 0.24 94
After closing 0.12 and 0.24 we have 0.18 Buy will open 0.18 Futures sell.
Now check the Sum of Spot buy and futures sell = Futures TP is so close it or wait till that.
-
If Close last trade is ON
- At 94 close 0.12 Buy; 0.24 sell and 0.18 Buy
Price Buy Sell 100 0.02 0.08 98 0.12 0.04 0.16 96 0.18 0.24 94
Parallel trades
If Add Futures as last trade is ON
and it gets hedged with a futures
Restart a new cycle.
Based on the max cycles, we can keep adding new cycles.