Skip to content

Commit

Permalink
Gateway stream
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiusgreat committed Oct 28, 2024
1 parent def2c86 commit 11f56f8
Show file tree
Hide file tree
Showing 26 changed files with 1,418 additions and 1,155 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Custom
appsettings.Production.json
Samples/
Releases/

# User-specific files
*.suo
Expand Down
2 changes: 1 addition & 1 deletion Derivative/Pages/Profile.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected double GetEstimate(double price, OptionInputModel inputModel)
{
var direction = inputModel.Position is OrderSideEnum.Buy ? 1.0 : -1.0;

if (inputModel.Side is Terminal.Core.Enums.OptionSideEnum.Share)
if (inputModel.Side is OptionSideEnum.Share)
{
return (price - inputModel.Price) * inputModel.Amount * direction;
}
Expand Down
10 changes: 5 additions & 5 deletions Gateway/Alpaca/Libs/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,16 @@ protected virtual async Task<ClientWebSocket> GetConnection(ClientWebSocket ws,
await ws.ReceiveAsync(data, cancellation.Token).ContinueWith(async o =>
{
var response = await o;
var content = $"[{Encoding.ASCII.GetString(data).Trim(new[] { '\0', '[', ']' })}]";
var content = $"[{Encoding.ASCII.GetString(data).Trim(['\0', '[', ']'])}]";
var message = JsonNode
.Parse(content)
?.AsArray()
?.FirstOrDefault();

switch ($"{message?["T"]}".ToUpper())
{
case "Q": ProcessPoint(content); break;
case "T": ProcessTrade(content); break;
case "Q": OnPoint(content); break;
case "T": OnTrade(content); break;
}
});
}
Expand All @@ -494,7 +494,7 @@ await ws.ReceiveAsync(data, cancellation.Token).ContinueWith(async o =>
/// Process quote from the stream
/// </summary>
/// <param name="content"></param>
protected virtual void ProcessPoint(string content)
protected virtual void OnPoint(string content)
{
var streamPoint = JsonSerializer
.Deserialize<QuoteMessage[]>(content, _sender.Options)
Expand Down Expand Up @@ -522,7 +522,7 @@ protected virtual void ProcessPoint(string content)
/// Process quote from the stream
/// </summary>
/// <param name="content"></param>
protected virtual void ProcessTrade(string content)
protected virtual void OnTrade(string content)
{
var orderMessage = JsonSerializer
.Deserialize<TradeMessage[]>(content, _sender.Options)
Expand Down
Loading

0 comments on commit 11f56f8

Please sign in to comment.