Bug report: Swaps do not work on indices in latest cTrader version V4.8.15

Created at 16 Jul 2023, 15:42
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
heinrich.munz's avatar

heinrich.munz

Joined 21.11.2020

Bug report: Swaps do not work on indices in latest cTrader version V4.8.15
16 Jul 2023, 15:42



Finally we have swaps calculation in backtests - halleluja!
While it works fine on Forex symbols, unfortunatelly, it still does not work on Indices like GER40 , etc.

When will this be fixed?

 


@heinrich.munz
Replies

Spotware
17 Jul 2023, 09:49

Dear trader,

Thank you for reporting this issue. Can you please share the code you used to reproduce this problem?

Best regards,

cTrader Team


@Spotware

heinrich.munz
17 Jul 2023, 11:31

RE:

Spotware said:

Dear trader,

Thank you for reporting this issue. Can you please share the code you used to reproduce this problem?

Best regards,

cTrader Team

using cAlgo.API;
using cAlgo.API.Internals;
using System;
using System.Diagnostics;
using System.Linq;

namespace cAlgo.Robots
{
   [Robot(AccessRights = AccessRights.FullAccess)]
   public class Empty : Robot
   {
      DateTime mStartDt;

      protected override void OnStart()
      {
         //Debugger.Launch();
         mStartDt = Time;
      }

      protected override void OnTick()
      {
         if (0 == Positions.Count)
         {
            var investMoney = 10000;
            var lotSize = Symbol.VolumeInUnitsToQuantity(investMoney * Symbol.TickSize / Symbol.TickValue / Symbol.Bid);
            var volume = Symbol.NormalizeVolumeInUnits(Symbol.QuantityToVolumeInUnits(lotSize));
            ExecuteMarketOrder(TradeType.Buy, SymbolName, volume);
         }
         else if (Time - Positions.Last().EntryTime > TimeSpan.FromDays(20))
            Positions.Last().Close();
      }

      protected override void OnStop()
      {
         Print("Symbol: "+ Symbol.Name + " started on " + mStartDt.ToString());
         Print("SwapLong: " + Symbol.SwapLong.ToString());
         Print("SwapShort: " + Symbol.SwapShort.ToString());

         foreach (var hist in History)
         {
            Print("Trade# " + hist.PositionId + ", Swap sum: " + hist.Swap.ToString());
         }
      }
   }
}

Output for EURUSD which is ok:
14/07/2023 22:54:00.000 | CBot instance [Empty, EURUSD, h1] stopped.
14/07/2023 22:54:00.000 | Trade# 5, Swap sum: -13,65
14/07/2023 22:54:00.000 | Trade# 4, Swap sum: -13,65
14/07/2023 22:54:00.000 | Trade# 3, Swap sum: -13,65
14/07/2023 22:54:00.000 | Trade# 2, Swap sum: -13,65
14/07/2023 22:54:00.000 | Trade# 1, Swap sum: -13,65
14/07/2023 22:54:00.000 | SwapShort: 0,29
14/07/2023 22:54:00.000 | SwapLong: -0,73
14/07/2023 22:54:00.000 | Symbol: EURUSD started on 13.03.2023 00:00:00
13/03/2023 02:00:00.000 | CBot instance [Empty, EURUSD, h1] started.

Output for US500 which is NOT ok:
14/07/2023 22:54:00.000 | CBot instance [Empty, US500, h1] stopped.
14/07/2023 22:54:00.000 | Trade# 5, Swap sum: 0
14/07/2023 22:54:00.000 | Trade# 4, Swap sum: 0
14/07/2023 22:54:00.000 | Trade# 3, Swap sum: 0
14/07/2023 22:54:00.000 | Trade# 2, Swap sum: 0
14/07/2023 22:54:00.000 | Trade# 1, Swap sum: 0
14/07/2023 22:54:00.000 | SwapShort: 2,55
14/07/2023 22:54:00.000 | SwapLong: -7,55
14/07/2023 22:54:00.000 | Symbol: US500 started on 13.03.2023 00:00:00
13/03/2023 02:00:00.000 | CBot instance [Empty, US500, h1] started.
 


@heinrich.munz

Spotware
17 Jul 2023, 11:52

Dear trader,

Can you please let us know the broker as well?

Best regards,

cTrader Team


@Spotware

heinrich.munz
17 Jul 2023, 11:59

RE:

Spotware said:

Dear trader,

Can you please let us know the broker as well?

Best regards,

cTrader Team

Good Question!
After your question I tried Pepperstone International, Pepperstone Europe and IC Markets.
The bug occurs ONLY on the Pepperstone accounts!

 


@heinrich.munz

ncel01
17 Jul 2023, 12:06 ( Updated at: 17 Jul 2023, 12:33 )

Yes, I can confirm that swaps have not been included for indices when backtesting.

Unfortunately, this is just another example where, unlike forex, indices have been overlooked.

@Spotware

Why do you need the cBot code here?

Just run a backtest with any indice and you will get to the same conclusion. As simple as that. 


@ncel01

ncel01
17 Jul 2023, 12:55

Dear Spotware team,

Same with Varianse, and probably many other brokers, I have no idea. Please include them all in the calculation.

Thanks.


@ncel01

Spotware
17 Jul 2023, 13:00

Hi all,

We managed to reproduce the issue and we will fix it in an upcoming update.

Best regards,

cTrader Team


@Spotware

ncel01
17 Jul 2023, 13:26

Dear Spotware team,

Great. Thanks for the prompt action/feedback!


@ncel01