@inherits LoadedComponent @page "/" @inject AnubisHost Host @inject ShellData Shell @using Anubis.Trading @using Anubis.Data Panoramica · Anubis @{ var o = _overview; var p = _panorama; var c = _currency; var moves = p.DemoMoves ?? o.Next; var last = p.DemoLast ?? o.Last; // On the phone only the first two moves of the bot, without the calendar's events (SPEC 13.4). var phoneMoves = moves.Select((m, i) => (m, i)).Where(x => !x.m.Calendar).Take(2).Select(x => x.i).ToHashSet(); var v = p.Accounts; } @if (_absence is { } away) {
Sono stato spento per @Anubis.Trading.DiaryText.Duration(away.Length), fino a @Format.ShortDate(away.EndedAt, Shell.Now, Shell.Zone, withTime: false).ToLowerInvariant() alle @TimeZoneInfo.ConvertTime(away.EndedAt, Shell.Zone).ToString("HH:mm", System.Globalization.CultureInfo.InvariantCulture). Ho ripreso i lavori saltati con le regole del recupero: cosa ho fatto e cosa ho lasciato perdere è nel diario.
} @if (!o.CapitalSet && !Shell.IsDemo) {

Primo passo: decidi quanto capitale affidare al bot in Impostazioni, Conti e chiavi. Lì puoi anche inserire le chiavi dei conti di prova. Finché non c'è capitale, le strategie osservano soltanto.

}

Finora

@if (o.HasData) { }
@if (!o.HasData) {

Ancora nessun risultato da mostrare.

Il patrimonio comincia a essere registrato quando colleghi un conto. Da quel giorno qui vedrai quanto stai guadagnando o perdendo, al netto dei costi, e il confronto con chi non usa il bot.

} else { var gain = o.Result.Amount >= 0;

@(gain ? "Sei in profitto di" : "Sei in perdita di")

@Shell.Money(o.Result.Amount, c, withSign: true) @Format.Percent(o.Result.Percent, 2, withSign: true)
var from = Format.LongDate(o.From); var year = from.LastIndexOf(' ');

Dal @from[..year]@from[year..], partendo da @Shell.Money(o.FromEquity, c). Commissioni già tolte.

@foreach (var (cell, i) in o.Cells.Select((x, i) => (x, i))) { var up = cell.Amount >= 0; var label = cell.Label.StartsWith("Ultimi ", StringComparison.Ordinal) ? cell.Label["Ultimi ".Length..] : cell.Label;
@if (label != cell.Label) {Ultimi }@label @Shell.Money(cell.Amount, c, withSign: true) @Format.Percent(cell.Percent, 2, withSign: true)
}
}

Adesso e dopo

@if (_runningDays is { } days) { Attivo da @days giorni senza interruzioni }

@Statement(o)

@if (p.NextDecision is { } decision) {

@decision

}

Prossime mosse

@if (moves.Count == 0) {

Niente in programma: le mosse compaiono quando il motore di trading lavora con almeno una strategia.

} else { }

Ultime azioni

@if (last.Count == 0) {

Ancora nessuna voce nel diario.

} else {
    @foreach (var action in last) {
  • @action.When@action.Text
  • }
} Apri il diario completo
Tutte le mosse e il diario
@* Accounts and the four limits (mockup 01); on the phone a compact list of the accounts (mockup 09). *@
@if (!v.HasAccounts) {

Nessun conto ancora.

Il bot crea da solo i due simulatori interni, OKX e Alpaca, al primo avvio del motore di trading. I conti di prova compaiono quando ne aggiungi le chiavi in Impostazioni.

} @foreach (var a in v.Accounts) { var up = a.Result >= 0; var held = v.Positions.Where(x => x.AccountId == a.Id).ToList(); var slices = held.GroupBy(x => x.Strategy).OrderBy(g => StrategyNames.Base.ToList().FindIndex(b => b.Name == g.Key)) .Select(g => (Strategy: g.Key, Eur: g.Sum(x => x.ValueEur))).ToList(); var shares = Format.Shares([.. slices.Select(s => s.Eur), a.Eur(a.Cash)]); var trend = p.Trends.GetValueOrDefault(a.Id);
@foreach (var s in slices) {}Investito @Shell.Money(a.InvestedEur, c) Liquidità @Shell.Money(a.Eur(a.Cash), c)
Ultimi 30 giorni @(trend is null ? "—" : Shell.Money(trend.Month, c, withSign: true))
@if (trend is { Points.Count: > 1 } t) { }

@AccountNote(a, held)

}

Rischio

@(p.LimitsKept ? "Tutti i limiti rispettati" : "Un limite chiede attenzione")
@foreach (var l in p.Limits) {
@l.Label@l.Value su @l.Threshold
= 0.8m ? "high" : null)"> @if (l.Worst is { } w) { }
}
@if (p.Limits[1].Worst is not null && _worst is { } worst) {

La tacca segna il calo peggiore finora: @Format.Percent(worst * 100m, 2).

} Vedi tutti i limiti
@if (v.HasAccounts) {

Conti

} @* Positions by value and the strategies (mockup 01); on the phone the first four positions (mockup 09). *@

Posizioni aperte @if (v.Positions.Count > 0) { @v.Positions.Count, per @Shell.Money(v.InvestedEur, c). Risultato aperto @Shell.Money(v.OpenResultEur, c, withSign: true) }

@if (v.Positions.Count > 0) { @v.Positions.Count, risultato @Shell.Money(v.OpenResultEur, c, withSign: true) } Dettaglio
@if (v.Positions.Count == 0) {

Nessuna posizione aperta. Quando una strategia compra, qui vedi ogni posizione con il suo valore, il risultato e lo stop che la protegge.

} else {
@foreach (var x in v.Positions) { var gain = x.ResultEur >= 0; }
StrumentoStrategiaValoreRisultatoStop
@x.Symbol @x.Name @StrategyNames.Label(x.Strategy) @Shell.Money(x.ValueEur, c) @Shell.Money(x.ResultEur, c, withSign: true) (@Format.Percent(x.Percent, 2, withSign: true)) @if (x.Stop is { } stop) {@Format.Money(stop, x.Currency, decimals: AccountsView.StopDecimals(stop)) (@Format.Percent(x.Last == 0 ? 0 : (stop / x.Last - 1m) * 100m, 1))} else {nessuno}
@(v.Positions.Count > 4 ? $"Vedi le altre {v.Positions.Count - 4}" : "Vedi i conti") }

Strategie

Dettaglio
@if (p.Strategies.Count == 0) {

Le strategie compaiono quando parte il motore di trading.

} else { } @if (!p.AnyLive) {

Nessuna strategia usa soldi veri. Passano al conto reale solo dopo aver superato tutti i requisiti, e solo se lo confermi tu.

}

Rischio

@(p.LimitsKept ? "Limiti rispettati" : "Da controllare")
@foreach (var l in new[] { p.Limits[2], p.Limits[1] }) {
@l.Label@l.Value su @l.Threshold.Replace(",00%", "%", StringComparison.Ordinal)
@if (l.Worst is { } w) { }
}
@* News, model and system (mockup 01): sections without a frame, under a dark rule (SPEC 13.2). *@

Notizie che contano

Tutte
@if (p.News is null) {

La lettura delle notizie non è ancora attiva. Quando lo sarà, qui vedrai le tre che contano di più per le tue posizioni e cosa ne ho fatto.

} else { }

Apprendimento

Dettaglio
@if (p.Learning is not { } m) {

L'apprendimento non è ancora attivo. Quando lo sarà, il modello osserverà i segnali delle strategie e qui vedrai quanto ci azzecca, prima che possa decidere qualcosa.

} else {

Il modello osserva e impara, ma non decide ancora.

Segnali già valutati@m.Signals su @m.Needed necessari
Previsioni azzeccate
@m.Precision% su dati mai visti
Ultimo addestramento
@m.Trained
Prossima verifica
@m.NextCheck
}

Sistema

Dettaglio
@code { private Overview _overview = null!; private PanoramaView _panorama = null!; private string _currency = "EUR"; private string _period = "avvio"; private int? _runningDays; private decimal? _worst; private Anubis.Trading.Absence? _absence; [CascadingParameter] public HttpContext? HttpContext { get; set; } [SupplyParameterFromQuery(Name = "periodo")] public string? Periodo { get; set; } protected override async Task LoadAsync() { var ct = HttpContext?.RequestAborted ?? CancellationToken.None; _period = Periodo is "30" or "7" or "oggi" ? Periodo : "avvio"; var services = Host.Services!; _currency = Shell.Effective((await services.Settings.GetAsync(SettingsStore.Currency.Key, ct)).Value); _overview = await Overview.LoadAsync(services, _period, Shell.Now, Shell.Zone, ct); _panorama = await PanoramaView.LoadAsync(Host, Shell, _overview, ct); _worst = _panorama.Limits[1].Worst is { } share ? -share * (await Anubis.Risk.RiskSettings.LoadAsync(services.Settings, ct)).DrawdownStop : null; using var aggregates = Shell.Aggregates(); _runningDays = aggregates?.RootElement.GetProperty("giorno").GetInt32(); // SPEC 5.6: an absence longer than a day stays at the top until the user says they have seen it. _absence = Shell.IsDemo ? null : await new Anubis.Trading.AbsenceBook(services.Db, Host.Clock).DeclaredAsync(ct); } private static string Statement(Overview o) { var orders = o.OpenOrders == 0 ? "Nessun ordine in corso." : o.OpenOrders == 1 ? "Un ordine in corso." : $"{o.OpenOrders} ordini in corso."; if (o.Positions == 0) { return "Nessuna posizione aperta. " + orders; } var stops = o.PositionsWithoutStop == 0 ? (o.Positions == 1 ? "con il suo stop" : "ognuna con il suo stop") : $"{o.PositionsWithoutStop} senza stop"; return o.Positions == 1 ? $"Sorveglio una posizione, {stops}. {orders}" : $"Sorveglio {o.Positions} posizioni, {stops}. {orders}"; } private static bool Down(AccountCard a) => a.State.LastOutcome == ReconcileOutcomes.Unreachable; private string AccountNote(AccountCard a, IReadOnlyList held) { var count = held.Count == 1 ? "1 posizione" : $"{held.Count} posizioni"; if (held.Count == 0) { count = "Nessuna posizione aperta"; } if (a.Broker != Venues.Alpaca) { var stops = held.Count(x => x.Stop is not null); var stopText = held.Count == 0 ? "" : stops == 1 ? ", 1 stop attivo" : $", {stops} stop attivi"; return $"{count}{stopText}. Commissioni pagate finora: {Shell.Money(a.Eur(a.Fees), _currency)}."; } var fractions = held.Any(x => x.Quantity != decimal.Truncate(x.Quantity)); var stopsText = held.Count == 0 ? "" : " Stop permanenti sulle azioni intere" + (!fractions ? "." : _panorama.FractionStops is { } back ? $"; sulle frazioni tornano alle {TimeZoneInfo.ConvertTime(back, Shell.Zone).ToString("HH:mm", CultureInfo.InvariantCulture)}." : "; sulle frazioni valgono fino alla chiusura."); var dollars = a.Currency == "USD" && a.Rate > 0m ? $" Conto in dollari: {Format.Money(a.Equity, "USD")} al cambio {Format.Quantity(a.Rate)}." : ""; return count + "." + stopsText + dollars; } private static string PartClass(PartState state) => state switch { PartState.Ok => "ok", PartState.Warn => "warn", _ => "off", }; private static string PartIcon(PartState state) => state switch { PartState.Ok => "tick", PartState.Warn => "alert", _ => "clock", }; private static string Css(decimal value) => Math.Round(value, 3).ToString("0.###", CultureInfo.InvariantCulture); private static string Spark(IReadOnlyList points) { var (min, max) = (points.Min(), points.Max()); var range = Math.Max(0.01m, max - min); return string.Join(' ', points.Select((x, i) => Css(i * 116m / (points.Count - 1) + 2m) + "," + Css(32m - (x - min) / range * 28m))); } private static (string X, string Y) SparkEnd(IReadOnlyList points) { var (min, max) = (points.Min(), points.Max()); var range = Math.Max(0.01m, max - min); return ("118", Css(32m - (points[^1] - min) / range * 28m)); } }