Hi, I'm new to this community. I'm starting to use Quantconnect with a simple trading bot, moving average based.
During this experience, I've seen that I haven't clear how close my open position. I use the following code to open the position:
# Open position BUY the quantity described in 'volume'
def open_position_buy(self):
self.Debug("BUY")
self.SetHoldings(self.__Symbol, 0.2, True)
# Open position SELL the quantity described in 'volume'
def open_position_sell(self):
self.Debug("SELL")
self.SetHoldings(self.__Symbol, -0.2, True)
and for close all position I use :
#Close all position open
def close_all_position(self):
orders = self.Transactions.GetOrders(None)
for order in orders:
if self.Portfolio[order.Symbol].Invested:
self.Liquidate(order.Symbol)
self.Debug("liquidate")
But, in the order, when liquidate operation was called, I see an operation inverse of my with the voice "liquidate" and my capital doesn't increase. With the same method with MT5, I get more than 300€.
Is this the correct method for the close position and give the money realized?
How can I close all positions wen bot or simulation was closed?
Regards, Edoardo