Closed Trade
Closed Trade
03 Apr 2019, 17:03
Hello, when I do a partial closing of a position for example 10k in a synchronized way, the History can not find the closed trade (HistoricalTrade) in the same code execution.
Why is it not provided in the following way?
var response = Robot.ClosePosition(Position); if(response.IsSuccessful){ var price = response.HistoricalTrade.ClosingPrice; }
After a partial close I try to locate the HistoricalTrade immediately as follows:
var response = ModifyPosition(Position, finalVolUnits); if(response.IsSuccessful){ int Id = Position.Id; var resp = History.Where(trade => trade.PositionId == Id).OrderByDescending(x => x.ClosingDealId).ToArray(); if (resp.Length > 0) { return resp[0]; } //resp.Length == 0 }
the latter does not work synchronously. I guess cTrade dont just update the History object after close positions.
Replies
bienve.pf
03 Apr 2019, 17:53
the ideal solution would be
var response = Robot.ClosePosition(Position); if(response.IsSuccessful){ var Trade = response.HistoricalTrade; }
@bienve.pf
PanagiotisCharalampous
04 Apr 2019, 15:40
Hi bienve.pf,
It is a known issue and will be fixed in an upcoming update.
Best Regards,
Panagiotis
@PanagiotisCharalampous
bienve.pf
04 Apr 2019, 16:05
you have planned to onclude
var response = ClosePosition(Position); if(response.IsSuccessful){ var Trade = response.HistoricalTrade; }
@bienve.pf
bienve.pf
04 Apr 2019, 16:07
OK. But do you have planned to Include some API ike this?
var response = ClosePosition(Position);
var trade = response.HistoricalTrade;
@bienve.pf
PanagiotisCharalampous
04 Apr 2019, 16:17
Hi bienve.pf,
No, we will fix the issue of deals not included immediately in History do that it works properly in real time execution as well.
Best Regards,
Panagiotis
@PanagiotisCharalampous
bienve.pf
03 Apr 2019, 17:50
In backtesting, History is updated correctly and finds trades closed correctly after partial and complete closures.
The problem occurs in real time with market data
@bienve.pf