Skip to content

Commit 41b106b

Browse files
committed
Cleanup
1 parent 4fb1b9c commit 41b106b

File tree

14 files changed

+403
-23
lines changed

14 files changed

+403
-23
lines changed

Core/Core/Models/Criteria.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public record Criteria
1010
/// </summary>
1111
public int? Count { get; init; }
1212

13+
/// <summary>
14+
/// Cache
15+
/// </summary>
16+
public bool Store { get; init; } = true;
17+
1318
/// <summary>
1419
/// Start date
1520
/// </summary>

Core/Core/Services/MessageService.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ public class MessageService
1616
/// <summary>
1717
/// Subscribe to messages
1818
/// </summary>
19-
public virtual string Subscribe<T>(Func<T, Task> action, string name = null)
19+
/// <typeparam name="T"></typeparam>
20+
/// <param name="action"></param>
21+
/// <param name="descriptor"></param>
22+
public virtual string Subscribe<T>(Func<T, Task> action, string descriptor)
2023
{
2124
var group = typeof(T);
22-
var descriptor = name ?? $"{Guid.NewGuid()}";
23-
25+
2426
subscriptions[group] = subscriptions.Get(group) ?? new();
2527
subscriptions[group][descriptor] = o => action((T)o);
2628

2729
return descriptor;
2830
}
2931

3032
/// <summary>
31-
/// Unsubscribe from messages
33+
/// Unsubscribe
3234
/// </summary>
35+
/// <typeparam name="T"></typeparam>
36+
/// <param name="name"></param>
3337
public virtual void Unsubscribe<T>(string name)
3438
{
3539
if (subscriptions.TryGetValue(typeof(T), out var actions))
@@ -39,8 +43,10 @@ public virtual void Unsubscribe<T>(string name)
3943
}
4044

4145
/// <summary>
42-
/// Send message without state change
46+
/// Send message
4347
/// </summary>
48+
/// <typeparam name="T"></typeparam>
49+
/// <param name="state"></param>
4450
public virtual async Task Send<T>(T state)
4551
{
4652
if (subscriptions.TryGetValue(typeof(T), out var actions))

Dashboard/Dashboard/Components/PositionsComponent.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public virtual async void Update(IEnumerable<IGateway> adapters)
8282
Items = [.. positions.Select(o => new Row
8383
{
8484
Name = o?.Operation?.Instrument?.Name,
85-
Group = o?.Operation?.Instrument?.Basis?.Name ?? o?.Operation?.Instrument?.Name,
85+
Group = o.Descriptor ?? o?.Operation?.Instrument?.Basis?.Name ?? o?.Operation?.Instrument?.Name,
8686
Time = new DateTime(o.Operation.Time ?? DateTime.MinValue.Ticks),
8787
Side = o.Side,
8888
Size = o.Operation.Amount ?? 0,

Dashboard/Dashboard/Pages/BasePage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ protected override async Task OnAfterRenderAsync(bool setup)
3434
if (setup)
3535
{
3636
await OnView();
37-
Messenger.Subscribe<Instrument>(OnViewUpdate);
38-
Messenger.Subscribe<Instrument>(OnTradeUpdate);
37+
Messenger.Subscribe<Instrument>(OnViewUpdate, nameof(OnViewUpdate));
38+
Messenger.Subscribe<Instrument>(OnTradeUpdate, nameof(OnTradeUpdate));
3939
State.Subscribe(async state =>
4040
{
4141
if (state.Previous is SubscriptionEnum.None && state.Next is SubscriptionEnum.Progress)
@@ -58,7 +58,7 @@ protected override async Task OnAfterRenderAsync(bool setup)
5858
/// </summary>
5959
/// <param name="items"></param>
6060
/// <param name="index"></param>
61-
protected virtual string GetDateByIndex(IList<IShape> items, int index)
61+
protected virtual string GetDate(IList<IShape> items, int index)
6262
{
6363
var empty = index <= 0 ? items.FirstOrDefault()?.X : items.LastOrDefault()?.X;
6464
var stamp = (long)(items.ElementAtOrDefault(index)?.X ?? empty ?? DateTime.Now.Ticks);

Dashboard/Dashboard/Pages/Futures/Leads.razor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ protected override async Task OnView()
3535
await IndicatorsView.Create("Indicators");
3636
await PerformanceView.Create("Performance");
3737

38-
LeaderView.Composers.ForEach(o => o.ShowIndex = i => GetDateByIndex(o.Items, (int)i));
39-
FollowerView.Composers.ForEach(o => o.ShowIndex = i => GetDateByIndex(o.Items, (int)i));
40-
IndicatorsView.Composers.ForEach(o => o.ShowIndex = i => GetDateByIndex(o.Items, (int)i));
41-
PerformanceView.Composers.ForEach(o => o.ShowIndex = i => GetDateByIndex(o.Items, (int)i));
38+
LeaderView.Composers.ForEach(o => o.ShowIndex = i => GetDate(o.Items, (int)i));
39+
FollowerView.Composers.ForEach(o => o.ShowIndex = i => GetDate(o.Items, (int)i));
40+
IndicatorsView.Composers.ForEach(o => o.ShowIndex = i => GetDate(o.Items, (int)i));
41+
PerformanceView.Composers.ForEach(o => o.ShowIndex = i => GetDate(o.Items, (int)i));
4242
}
4343

4444
protected override Task OnTrade()

Dashboard/Dashboard/Pages/Gateways/InterBrokerDemo.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ protected override async Task OnTradeUpdate(Instrument instrument)
8080
var price = instrument.Price;
8181
var adapter = View.Adapters["Prime"];
8282
var account = adapter.Account;
83-
var orders = (await adapter.GetOrders(default)).Data;
84-
var positions = (await adapter.GetPositions(default)).Data;
83+
var orders = (await adapter.GetOrders(new() { Store = false })).Data;
84+
var positions = (await adapter.GetPositions(new() { Store = false })).Data;
8585

8686
if (orders.Count is 0 && positions.Count is 0)
8787
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@inherits BasePage
2+
3+
@page "/options/short-convex-protection"
4+
5+
<ControlsComponent @ref="View">
6+
<ChartsComponent Name="Prices" @ref="DataView" />
7+
<ChartsComponent Name="Delta" @ref="DeltaView" />
8+
<ChartsComponent Name="Variance" @ref="VarianceView" />
9+
<ChartsComponent Name="Performance" @ref="PerformanceView" />
10+
<OrdersComponent Name="Orders" @ref="OrdersView" />
11+
<PositionsComponent Name="Positions" @ref="PositionsView" />
12+
<TransactionsComponent Name="Transactions" @ref="TransactionsView" />
13+
<StatementsComponent Name="Statements" Adapters="View.Adapters" @ref="StatementsView" />
14+
</ControlsComponent>

0 commit comments

Comments
 (0)