@inherits LoadedComponent @page "/notizie" @inject AnubisHost Host @inject ShellData Shell @using Anubis.News Notizie e mercato · Anubis @{ var v = _view; var rows = Filtered(v.Board.Rows).ToList(); var count = _filter switch { "effetto" => v.Board.Active, "posizioni" => v.Board.OnPositions, _ => v.Board.Read, }; var shown = _all ? rows : rows.Take(Shown).ToList(); }

@Lead(v)

@if (rows.Count == 0) {

@Empty(v)

} else { @if (!_all && count > shown.Count) { } }

Umore del mercato

    @foreach (var g in v.Mood) {
  • @g.Label @if (g.Value is { } value) { @value @g.Words } else { non ancora letto }
    @g.Left@g.Right
    @if (g.Stale is { } stale) {

    Ultimo valore @stale.

    }
  • }

Sono indizi che il modello tiene in conto. Da soli non fanno comprare né vendere.

@Anubis.Data.FearGreed.Attribution.

In calendario

@if (v.Calendar.Count == 0) {

Nessun evento importante nei prossimi giorni.@(Shell.IsDemo || v.Collecting ? "" : " Il calendario si scarica con i dati di mercato.")

} else {
    @foreach (var e in v.Calendar) {
  • @e.When @e.Title @e.Effect
  • }
}

Da dove leggo

@if (v.Sources.Count == 0) {

Non leggo ancora nessuna fonte. Le notizie si scaricano con i dati di mercato.

} else {
    @foreach (var s in v.Sources) {
  • @s.Name @s.Frequency
  • }
}

@v.Spending

Fonti e regole nelle impostazioni

@code { /// The rows shown before "Mostra le altre", as in the mockup. private const int Shown = 6; private NewsView _view = null!; private string _filter = "posizioni"; private bool _all; [CascadingParameter] public HttpContext? HttpContext { get; set; } [SupplyParameterFromQuery(Name = "filtro")] public string? Filtro { get; set; } [SupplyParameterFromQuery(Name = "tutte")] public string? Tutte { get; set; } protected override async Task LoadAsync() { var ct = HttpContext?.RequestAborted ?? CancellationToken.None; _view = await NewsView.LoadAsync(Host, Shell, ct); // Without positions the default filter would be empty: then all the news. _filter = Filtro is "effetto" or "posizioni" or "tutte" ? Filtro : _view.Board.OnPositions > 0 ? "posizioni" : "tutte"; _all = Tutte == "1"; } private IEnumerable Filtered(IEnumerable rows) => _filter switch { "effetto" => rows.Where(r => r.Active), "posizioni" => rows.Where(r => r.OnPositions), _ => rows, }; private static string Lead(NewsView v) { var read = v.Board.Read == 1 ? "1 notizia letta" : $"{v.Board.Read} notizie lette"; var active = v.Board.Active switch { 0 => "nessuna con un effetto in corso", 1 => "1 con un effetto in corso", var n => $"{n} con un effetto in corso", }; return $"{read} nelle ultime 24 ore, {active}."; } private string Empty(NewsView v) => _filter switch { "effetto" => "Nessuna notizia ha un effetto in corso: compro e vendo come dicono le strategie.", "posizioni" => "Nessuna notizia sulle tue posizioni nelle ultime 24 ore.", _ when !v.Collecting && !Shell.IsDemo => "Non leggo ancora notizie: la raccolta parte con i dati di mercato. Le fonti si scelgono nelle impostazioni.", _ => "Nessuna notizia nelle ultime 24 ore.", }; // "Niente. Confermano…" reads "niente. Confermano…" after "Cosa ho fatto:". private static string Inline(string text) => text.Length == 0 ? text : char.ToLowerInvariant(text[0]) + text[1..]; private static string Css(double value) => value.ToString("0.##", CultureInfo.InvariantCulture); }