@page "/positions"
@using TradingBot.Services
@using TradingBot.Models
@inject TradingBotService BotService
@inject LoggingService LoggingService
@implements IDisposable
@rendermode InteractiveServer
Posizioni Aperte - TradingBot
@if (activePositions.Count == 0)
{
Nessuna Posizione Aperta
Non hai posizioni attive al momento. Le posizioni appaiono qui automaticamente quando il bot esegue un acquisto.
}
else
{
@foreach (var position in activePositions.OrderBy(p => p.Symbol))
{
var currentPrice = GetCurrentPrice(position.Symbol);
var unrealizedPL = CalculateUnrealizedPL(position, currentPrice);
var plPercentage = CalculatePLPercentage(position, currentPrice);
var currentValue = position.Amount * currentPrice;
var holdingTime = DateTime.UtcNow - position.Timestamp;
Quantità
@position.Amount.ToString("F8") @position.Symbol
Prezzo Entrata
$@position.Price.ToString("N2")
Prezzo Corrente
$@currentPrice.ToString("N2")
Valore Iniziale
$@(position.Amount * position.Price).ToString("N2")
Valore Corrente
$@currentValue.ToString("N2")
Tempo Holding
@FormatHoldingTime(holdingTime)
@if (!string.IsNullOrEmpty(position.Strategy))
{
Strategia
@position.Strategy
}
ShowCloseConfirmation(position)"
disabled="@(!BotService.Status.IsRunning)">
Chiudi Posizione
@if (!BotService.Status.IsRunning)
{
Avvia il bot per chiudere posizioni
}
}
}
@if (showCloseModal && positionToClose != null)
{
var currentPrice = GetCurrentPrice(positionToClose.Symbol);
var unrealizedPL = CalculateUnrealizedPL(positionToClose, currentPrice);
var plPercentage = CalculatePLPercentage(positionToClose, currentPrice);
@positionToClose.Symbol
@positionToClose.Amount.ToString("F8") @positionToClose.Symbol
Prezzo Entrata
$@positionToClose.Price.ToString("N2")
Prezzo Chiusura
$@currentPrice.ToString("N2")
Profitto/Perdita Stimato
@(unrealizedPL >= 0 ? "+" : "")$@unrealizedPL.ToString("N2")
(@(plPercentage >= 0 ? "+" : "")@plPercentage.ToString("F2")%)
Attenzione: Questa azione chiuderà immediatamente la posizione al prezzo di mercato corrente.
L'operazione non può essere annullata.
}
@if (showSuccessNotification)
{
Posizione chiusa con successo!
}
@code {
private List