Tradingview Script Upgrade: Funding Rates
Budget: €30 – €250 EUR
Hi,
I recently posted a project regarding funding rates, but understood my briefing needed to a bit more clear. See below. Goal: improve reliability of strategy, by adding funding rates to strategy and backtest. Requirements:
1. Retrieve funding rates of Bitmex - Available in draft code (see attachment).
2. Plot funding rates.
3. Add to strategy - Available in draft code (see attachment).
4. Calculate time in leveraged position and fees paid/received based on position size of leveraged positions. Take into account:
- I'm trading at 2D, but fees are paid every 8H. Example: if in leveraged position for 2 bars at 2D timeframe, it means I'm in a leveraged position for 6 funding rounds.
- If stoploss or take profit is hit, leveraged positions might be closed before an 8hour mark has completed. Only if a position is held for full funding rounds a fee is paid/received. Example: if in a leveraged position for 47 hours, 5 complete funding rounds are applicable (not 6).
- The asset traded (BTC/USD) is held as collateral (BTC). First Long position is not leveraged. No fees will be paid/received (see .
Funding fees are applicable in every case except for longCount == 1 and (shortCount and doubleshortCount and doublelongCount and triplelongCount == 0) - check draft code (see attachment).
5. Add funding rates paid/received to strategy backtest.
I recently posted a project regarding funding rates, but understood my briefing needed to a bit more clear. See below. Goal: improve reliability of strategy, by adding funding rates to strategy and backtest. Requirements:
1. Retrieve funding rates of Bitmex - Available in draft code (see attachment).
2. Plot funding rates.
3. Add to strategy - Available in draft code (see attachment).
4. Calculate time in leveraged position and fees paid/received based on position size of leveraged positions. Take into account:
- I'm trading at 2D, but fees are paid every 8H. Example: if in leveraged position for 2 bars at 2D timeframe, it means I'm in a leveraged position for 6 funding rounds.
- If stoploss or take profit is hit, leveraged positions might be closed before an 8hour mark has completed. Only if a position is held for full funding rounds a fee is paid/received. Example: if in a leveraged position for 47 hours, 5 complete funding rounds are applicable (not 6).
- The asset traded (BTC/USD) is held as collateral (BTC). First Long position is not leveraged. No fees will be paid/received (see .
Funding fees are applicable in every case except for longCount == 1 and (shortCount and doubleshortCount and doublelongCount and triplelongCount == 0) - check draft code (see attachment).
5. Add funding rates paid/received to strategy backtest.