-
Notifications
You must be signed in to change notification settings - Fork 0
/
HistoricalPrice.cs
53 lines (39 loc) · 1.76 KB
/
HistoricalPrice.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using CoinStory.Models.Enumerations;
using CoinStory.Models.Interfaces;
using System.ComponentModel.DataAnnotations.Schema;
namespace CoinStory.Models
{
/// <summary>
/// Contains all historical USD pricing information for a single UTC day and its source
/// </summary>
public class HistoricalPrice : IHistoricalPrice
{
public DateTime Date { get; set; }
public Currency Currency { get; set; }
public HistoricalDataSource Source { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal Open { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal High { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal Low { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal Close { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal Volume { get; set; }
[Column(TypeName = "decimal(38,10)")]
public decimal MarketCap { get; set; }
public override bool Equals(object? obj)
{
if (obj is HistoricalPrice t)
if (Date.Year == t.Date.Year && Date.Month == t.Date.Month && Date.Day == t.Date.Day && Currency == t.Currency)
return true;
else
return false;
return base.Equals(obj);
}
public override int GetHashCode() => HashCode.Combine(Date, Currency);
public static bool operator ==(HistoricalPrice price1, HistoricalPrice price2) => price1 is null ? price2 is null : Equals(price1, price2);
public static bool operator !=(HistoricalPrice price1, HistoricalPrice price2) => !(price1 == price2);
}
}