Skip to content

Commit

Permalink
Add TradeCount (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssnyder-intrinio authored Nov 25, 2024
1 parent ff3bbb0 commit dacd4c9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
28 changes: 17 additions & 11 deletions Intrinio.Realtime/CandleStick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public abstract class CandleStick
private readonly double _closeTimestamp;
private readonly IntervalType _interval;

public UInt32 Volume { get; set; }
public double High { get; set; }
public double Low { get; set; }
public double Close { get; set; }
public double Open { get; set; }
public UInt32 Volume { get; private set; }
public double High { get; private set; }
public double Low { get; private set; }
public double Close { get; private set; }
public double Open { get; private set; }
public double OpenTimestamp
{
get { return _openTimestamp; }
Expand All @@ -23,11 +23,13 @@ public double CloseTimestamp
{
get { return _closeTimestamp; }
}
public double FirstTimestamp { get; set; }
public double LastTimestamp { get; set; }
public bool Complete { get; set; }
public double Average { get; set; }
public double Change { get; set; }
public double FirstTimestamp { get; private set; }
public double LastTimestamp { get; private set; }
public bool Complete { get; private set; }
public double Average { get; private set; }
public double Change { get; private set; }

public UInt32 TradeCount { get; private set; }
public IntervalType Interval
{
get { return _interval; }
Expand All @@ -48,9 +50,10 @@ public CandleStick(UInt32 volume, double price, double openTimestamp, double clo
Average = price;
Change = 0.0;
_interval = interval;
TradeCount = 1U;
}

public CandleStick(UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval)
public CandleStick(UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval, UInt32 tradeCount)
{
Volume = volume;
High = high;
Expand All @@ -65,6 +68,7 @@ public CandleStick(UInt32 volume, double high, double low, double closePrice, do
Average = average;
Change = change;
_interval = interval;
TradeCount = tradeCount;
}

public void Merge(CandleStick candle)
Expand All @@ -78,6 +82,7 @@ public void Merge(CandleStick candle)
FirstTimestamp = candle.FirstTimestamp < FirstTimestamp ? candle.FirstTimestamp : FirstTimestamp;
LastTimestamp = candle.LastTimestamp > LastTimestamp ? candle.LastTimestamp : LastTimestamp;
Change = (Close - Open) / Open;
TradeCount += candle.TradeCount;
}

public void Update(UInt32 volume, double price, double time)
Expand All @@ -91,6 +96,7 @@ public void Update(UInt32 volume, double price, double time)
FirstTimestamp = time < FirstTimestamp ? time : FirstTimestamp;
LastTimestamp = time > LastTimestamp ? time : LastTimestamp;
Change = (Close - Open) / Open;
++TradeCount;
}

public void MarkComplete()
Expand Down
4 changes: 2 additions & 2 deletions Intrinio.Realtime/Equities/QuoteCandleStick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public QuoteCandleStick(string symbol, UInt32 volume, double price, QuoteType qu
_quoteType = quoteType;
}

public QuoteCandleStick(string symbol, UInt32 volume, double high, double low, double closePrice, double openPrice, QuoteType quoteType, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval)
public QuoteCandleStick(string symbol, UInt32 volume, double high, double low, double closePrice, double openPrice, QuoteType quoteType, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval, UInt32 tradeCount)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval, tradeCount)
{
_symbol = symbol;
_quoteType = quoteType;
Expand Down
4 changes: 2 additions & 2 deletions Intrinio.Realtime/Equities/TradeCandleStick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public TradeCandleStick(string symbol, UInt32 volume, double price, double openT
_symbol = symbol;
}

public TradeCandleStick(string symbol, UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval)
public TradeCandleStick(string symbol, UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval, UInt32 tradeCount)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval, tradeCount)
{
_symbol = symbol;
}
Expand Down
4 changes: 2 additions & 2 deletions Intrinio.Realtime/Options/QuoteCandleStick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public QuoteCandleStick(string contract, UInt32 volume, double price, QuoteType
_quoteType = quoteType;
}

public QuoteCandleStick(string contract, UInt32 volume, double high, double low, double closePrice, double openPrice, QuoteType quoteType, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval)
public QuoteCandleStick(string contract, UInt32 volume, double high, double low, double closePrice, double openPrice, QuoteType quoteType, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval, UInt32 tradeCount)
: base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval, tradeCount)
{
_contract = contract;
_quoteType = quoteType;
Expand Down
4 changes: 2 additions & 2 deletions Intrinio.Realtime/Options/TradeCandleStick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public TradeCandleStick(string contract, UInt32 volume, double price, double ope
_contract = contract;
}

public TradeCandleStick(string contract, UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval)
:base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval)
public TradeCandleStick(string contract, UInt32 volume, double high, double low, double closePrice, double openPrice, double openTimestamp, double closeTimestamp, double firstTimestamp, double lastTimestamp, bool complete, double average, double change, IntervalType interval, UInt32 tradeCount)
:base(volume, high, low, closePrice, openPrice, openTimestamp, closeTimestamp, firstTimestamp, lastTimestamp, complete, average, change, interval, tradeCount)
{
_contract = contract;
}
Expand Down
4 changes: 1 addition & 3 deletions Intrinio.Realtime/WebSocketClient.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Linq;
using System.Net;
using System.Net.WebSockets;
using Intrinio.Realtime.Composite;

namespace Intrinio.Realtime;

Expand Down Expand Up @@ -38,7 +36,7 @@ public abstract class WebSocketClient
private readonly Func<Task> _tryReconnect;
private readonly HttpClient _httpClient = new ();
private const string ClientInfoHeaderKey = "Client-Information";
private const string ClientInfoHeaderValue = "IntrinioDotNetSDKv12.2";
private const string ClientInfoHeaderValue = "IntrinioDotNetSDKv12.3";
private readonly ThreadPriority _mainThreadPriority;
private readonly Thread[] _threads;
private Thread? _receiveThread;
Expand Down
4 changes: 2 additions & 2 deletions IntrinioRealTimeClient.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package>
<metadata>
<id>IntrinioRealTimeClient</id>
<version>12.2.0</version>
<version>12.3.0</version>
<title>Intrinio SDK for Real-Time Stock and Option Prices</title>
<authors>Intrinio</authors>
<owners>Intrinio</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<projectUrl>https://github.com/intrinio/intrinio-realtime-csharp-sdk</projectUrl>
<description>Intrinio provides real-time stock and option prices via a two-way WebSocket connection.</description>
<releaseNotes>Version 12.2.0 release.</releaseNotes>
<releaseNotes>Version 12.3.0 release.</releaseNotes>
<copyright>Copyright 2024 Intrinio</copyright>
<tags>fintech stocks options prices websocket real-time market finance</tags>
<dependencies>
Expand Down

0 comments on commit dacd4c9

Please sign in to comment.