Sviluppo TradingBot
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
public async Task PlaceBracketOrderAsync(string symbol, int quantity, decimal entryPrice, decimal takeProfitPrice, decimal stopLossPrice)
|
||||
{
|
||||
// 1. Ordine principale di acquisto (Buy) a mercato o limite
|
||||
var entryOrder = MarketOrder.Buy(symbol, quantity);
|
||||
|
||||
// 2. Configura il Bracket Order inserendo Take Profit e Stop Loss
|
||||
var bracketOrder = entryOrder.TakeProfit(takeProfitPrice).StopLoss(stopLossPrice);
|
||||
|
||||
// 3. Invia l'ordine ad Alpaca
|
||||
IOrder order = await _tradingClient.PostOrderAsync(bracketOrder);
|
||||
|
||||
Console.WriteLine($"Ordine inviato con successo. ID: {order.OrderId}");
|
||||
}
|
||||
Reference in New Issue
Block a user