Fixes exception in market averages
This commit is contained in:
parent
2cf5a26934
commit
ae25b58610
|
@ -16,7 +16,7 @@
|
|||
public class MarketAverage
|
||||
{
|
||||
public int NumberOfFinished { get; set; }
|
||||
public TimeSpan TimeRange { get; set; }
|
||||
public int TimeRangeSeconds { get; set; }
|
||||
public float Price { get; set; }
|
||||
public float Size { get; set; }
|
||||
public float Duration { get; set; }
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace BiblioTech.Commands
|
|||
|
||||
private string[] GetInsight(MarketAverage avg)
|
||||
{
|
||||
var headerLine = $"[Last {Time.FormatDuration(avg.TimeRange)}] ({avg.NumberOfFinished} Contracts finished)";
|
||||
var timeRange = TimeSpan.FromSeconds(avg.TimeRangeSeconds);
|
||||
var headerLine = $"[Last {Time.FormatDuration(timeRange)}] ({avg.NumberOfFinished} Contracts finished)";
|
||||
|
||||
if (avg.NumberOfFinished == 0)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace TestNetRewarder
|
|||
return new MarketAverage
|
||||
{
|
||||
NumberOfFinished = CountNumberOfFinishedRequests(states),
|
||||
TimeRange = GetTotalTimeRange(states),
|
||||
TimeRangeSeconds = GetTotalTimeRange(states),
|
||||
Price = Average(states, s => s.Request.Ask.Reward),
|
||||
Duration = Average(states, s => s.Request.Ask.Duration),
|
||||
Size = Average(states, s => GetTotalSize(s.Request.Ask)),
|
||||
|
@ -93,12 +93,13 @@ namespace TestNetRewarder
|
|||
}
|
||||
}
|
||||
|
||||
if (count < 1.0f) return 0.0f;
|
||||
return sum / count;
|
||||
}
|
||||
|
||||
private TimeSpan GetTotalTimeRange(ChainState[] states)
|
||||
private int GetTotalTimeRange(ChainState[] states)
|
||||
{
|
||||
return Program.Config.Interval * states.Length;
|
||||
return Convert.ToInt32((Program.Config.Interval * states.Length).TotalSeconds);
|
||||
}
|
||||
|
||||
private int CountNumberOfFinishedRequests(ChainState[] states)
|
||||
|
|
Loading…
Reference in New Issue