Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiusgreat committed Jul 13, 2024
1 parent acaac27 commit 2914bc3
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ indent_size = 2
[*.cs]
dotnet_diagnostic.CA2227.severity = none
dotnet_diagnostic.CA1305.severity = none
dotnet_diagnostic.CA1062.severity = none
dotnet_diagnostic.CA1062.severity = none
4 changes: 2 additions & 2 deletions Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Canvas.Views.Web" Version="3.1.4" />
<PackageReference Include="Canvas.Views.Web" Version="3.1.5" />
<PackageReference Include="Estimator" Version="1.0.2" />
<PackageReference Include="MudBlazor" Version="6.20.0" />
<PackageReference Include="MudBlazor" Version="7.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Client/Pages/Recorder.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/recorder"

<PageComponent @ref="View"></PageComponent>
88 changes: 88 additions & 0 deletions Client/Pages/Recorder.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Client.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration;
using Schwab;
using Schwab.Messages;
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Timers;
using Terminal.Core.Domains;
using Terminal.Core.Indicators;
using Terminal.Core.Models;

namespace Client.Pages
{
public partial class Recorder
{
[Inject] IConfiguration Configuration { get; set; }

protected virtual IAccount Account { get; set; }
protected virtual PageComponent View { get; set; }
protected virtual PerformanceIndicator Performance { get; set; }

protected override async Task OnAfterRenderAsync(bool setup)
{
if (setup)
{
View.OnPreConnect = CreateAccounts;
View.OnPostConnect = async () => await OnData();
}

await base.OnAfterRenderAsync(setup);
}

protected virtual void CreateAccounts()
{
Account = new Account
{
Descriptor = Configuration["Schwab:Account"],
Instruments = new Dictionary<string, InstrumentModel>
{
["SPY"] = new InstrumentModel { Name = "SPY" }
}
};

View.Adapter = new Adapter
{
Account = Account,
Scope = new ScopeMessage
{
AccessToken = Configuration["Schwab:AccessToken"],
RefreshToken = Configuration["Schwab:RefreshToken"],
ConsumerKey = Configuration["Schwab:ConsumerKey"],
ConsumerSecret = Configuration["Schwab:ConsumerSecret"],
}
};

var aTimer = new Timer();
aTimer.Elapsed += async (o, e) => await OnData();
aTimer.Interval = 5000;
aTimer.Enabled = true;
}

private async Task OnData()
{
var args = new OptionsArgs
{
Name = "SPY",
MinDate = DateTime.Now,
MaxDate = DateTime.Now.AddYears(1)
};

var options = await View.Adapter.GetOptions(args, []);
var content = JsonSerializer.Serialize(options);
var source = $"D:/Code/NET/Terminal/Data/SPY/{DateTime.UtcNow.Ticks}.zip";

using var archive = ZipFile.Open(source, ZipArchiveMode.Create);
using (var entry = archive.CreateEntry($"{DateTime.UtcNow.Ticks}").Open())
{
var bytes = Encoding.ASCII.GetBytes(content);
entry.Write(bytes);
}
}
}
}
91 changes: 1 addition & 90 deletions Client/Themes/DashboardTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class DashboardTheme : MudTheme
{
public DashboardTheme()
{
Palette = new PaletteDark();
LayoutProperties = new LayoutProperties()
{
DefaultBorderRadius = "5px",
Expand All @@ -16,95 +15,7 @@ public DashboardTheme()
{
Default = new Default()
{
FontFamily = new[] { "Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H1 = new H1()
{
FontFamily = new[] { "Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "5rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H2 = new H2()
{
FontFamily = new[] { "Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "3.75rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H3 = new H3()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "3rem",
FontWeight = 500,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H4 = new H4()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "2.15rem",
FontWeight = 500,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H5 = new H5()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1.5rem",
FontWeight = 500,
LineHeight = 1.5,
LetterSpacing = "normal"
},
H6 = new H6()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1.25rem",
FontWeight = 500,
LineHeight = 1.5,
LetterSpacing = "normal"
},
Button = new Button()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
Body1 = new Body1()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
Body2 = new Body2()
{
FontFamily = new[] {"Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "0.75rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
Caption = new Caption()
{
FontFamily = new[] { "Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontSize = "1rem",
FontWeight = 300,
LineHeight = 1.5,
LetterSpacing = "normal"
},
Subtitle2 = new Subtitle2()
{
FontFamily = new[] { "Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif" },
FontFamily = ["Segoe UI", "SegoeUI", "Montserrat", "Helvetica Neue", "Helvetica", "Arial", "sans-serif"],
FontSize = "1rem",
FontWeight = 300,
LineHeight = 1.5,
Expand Down
5 changes: 5 additions & 0 deletions Core/Extensions/Hashtable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public static NameValueCollection Merge(this Hashtable source, params Hashtable[
{
var response = HttpUtility.ParseQueryString(string.Empty);

foreach (DictionaryEntry o in source ?? [])
{
response[$"{o.Key}"] = $"{o.Value}";
}

foreach (Hashtable map in maps ?? [])
{
foreach (DictionaryEntry o in map ?? [])
Expand Down
2 changes: 1 addition & 1 deletion Gateways/Alpaca/Libs/Alpaca.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Distribution.Stream" Version="1.1.8" />
<PackageReference Include="Distribution.Stream" Version="1.1.9" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Gateways/Coinbase/Libs/Coinbase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Distribution.Stream" Version="1.1.8" />
<PackageReference Include="Distribution.Stream" Version="1.1.9" />
<PackageReference Include="jose-jwt" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Gateways/InteractiveBrokers/Libs/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public override Task<IList<ErrorModel>> Unsubscribe(InstrumentModel instrument)
if (_subscriptions.TryGetValue(instrument.Name, out var id))
{
_client?.ClientSocket?.cancelTickByTickData(id);

_subscriptions.Remove(instrument.Name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Gateways/InteractiveBrokers/Libs/InteractiveBrokers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Distribution.Stream" Version="1.1.8" />
<PackageReference Include="Distribution.Stream" Version="1.1.9" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Gateways/Schwab/Libs/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public override async Task<ResponseModel<IList<OptionModel>>> GetOptions(Options
var props = new Hashtable
{
["symbol"] = args.Name,
["fromDate"] = args.MinDate,
["toDate"] = args.MaxDate
["fromDate"] = $"{args.MinDate:yyyy-MM-dd}",
["toDate"] = $"{args.MaxDate:yyyy-MM-dd}"

}.Merge(criteria);

Expand Down Expand Up @@ -493,7 +493,7 @@ protected virtual async Task<ResponseModel<OrderModel>> CreateOrder(OrderModel o
if (exResponse.Message.Headers.TryGetValues("Location", out var orderData))
{
var orderItem = orderData.First();
var orderId = $"{orderItem.Substring(orderItem.LastIndexOf('/') + 1)}";
var orderId = $"{orderItem[(orderItem.LastIndexOf('/') + 1)..]}";

if (string.IsNullOrEmpty(orderId))
{
Expand Down
2 changes: 1 addition & 1 deletion Gateways/Schwab/Libs/Schwab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Distribution.Stream" Version="1.1.8" />
<PackageReference Include="Distribution.Stream" Version="1.1.9" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Gateways/Simulation/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 2914bc3

Please sign in to comment.