Sviluppo TradingBot
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
public async Task<bool> HasOpenPositionAsync(string symbol)
|
||||
{
|
||||
try
|
||||
{
|
||||
IPosition position = await _tradingClient.GetPositionAsync(symbol);
|
||||
return position != null && position.Quantity > 0;
|
||||
}
|
||||
catch (AlpacaRestException ex) when (ex.ErrorCode == 40410000)
|
||||
{
|
||||
// Il codice 40410000 indica che non ci sono posizioni aperte per quel simbolo
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user