OHLC should implement IComparable
See original GitHub issueHello,
Im just saving your OHLC to Entity framework with Sqllight Core and when im trying to make queries using linkq i got this :
Property ‘HistoricRates.OhlcItem’ cannot be used as a key because it has type ‘OHLC’ which does not implement ‘IComparable<T>’, ‘IComparable’ or ‘IStructuralComparable’. Use ‘HasConversion’ in ‘OnModelCreating’ to wrap ‘OHLC’ with a type that can be compared.’
public static List<OHLC> GetOhlcList(string cryptoCoinName, Granularity granularity)
{
using (SqliteDbContext dbContext = new SqliteDbContext())
{
var c = dbContext.HistoricRates.Where(s => s.MarketItemName == MarketItemName ) // Multiple market products
.Where(s => s.GranularityItem == granularity) // Multiple timeSpan 5 min 1 hour etc
.Select(s => new
{
s = s.OhlcItem
}).ToList();
}
}
public class HistoricRates
{
public string MarketItemName { get; set; }
public Granularity GranularityItem { get; set; }
public OHLC OhlcItem { get; set; }
}
Would be cool if OHLC had IComparable<T> interface !
If you have better idea on how to implement that im open to new ideas ! 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
At least one object must implement IComparable
At least one object must implement IComparable. " when trying to add a second player, the first one works, but the second one...
Read more >IComparable Interface (System)
Defines a generalized type-specific comparison method that a value type or class implements to order or sort its instances.
Read more >RolloverModifier OHLC Problem | WPF Chart Forums
Hi there, Please,take a look at our SciChart Trader example. Notice, how labels data is bound to RolloverModifier.RolloverData.SeriesInfo object; to create ...
Read more >At least one object must implement icomparable. LINQ C# - ...
You need to implement IComparable interface, to provide compare versus another instance. In the case of your code problem, will occurs at ...
Read more >Time series manipulation in C#
There are no restriction on the types of keys and values, but some operations are only available for keys that can be ordered...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After thinking about it some more, I feel the same way. To me it doesn’t make intuitive sense to sort or compare candles anyway! Adding extra code just to support an external frameworks is probably not a pattern we want to get into the habit of adopting 😅
I agree
DateTime
may make more sense as the field to compare, but unfortunately I think that just makes it more ambiguous what the comparison does. I now am unsure that this feature is a good choice. If we stored individual points of a scatterplot as aPoint
struct it would be the same issue, in certain contexts it makes more sense to compare on the x or y value but in general it just adds more confusion.I’m of the opinion that a feature shouldn’t be added if its behaviour (as interpreted by the user, not the compiler or runtime) is ambiguous. Especially when a wrapper class with behaviour of the user’s choosing is trivially implemented.