sharp-trading/VolumeRate.cs

30 lines
641 B
C#
Raw Normal View History

2017-10-26 18:52:58 +02:00
using System;
2017-11-23 13:03:36 +01:00
using sharp.json;
using sharp.json.attributes;
2017-10-26 18:52:58 +02:00
namespace sharp.trading
{
2017-11-23 13:03:36 +01:00
[JSONClassPolicy(Policy = JSONPolicy.ATTRIBUTED)]
public struct VolumeRate : IComparable
2017-10-26 18:52:58 +02:00
{
2017-11-23 13:03:36 +01:00
[JSONField(Alias = "Quantity")]
2017-10-26 18:52:58 +02:00
public Double Volume { get; set; }
2017-11-23 13:03:36 +01:00
[JSONField(Alias = "Rate")]
2017-10-26 18:52:58 +02:00
public Double Price { get; set; }
public VolumeRate(Double Volume,Double Price)
{
this.Volume = Volume;
this.Price = Price;
}
2017-11-23 13:03:36 +01:00
public int CompareTo(object obj)
{
return Price.CompareTo(((VolumeRate)obj).Price);
}
public double UnityPrice {
get { if (this.Volume != 0) { return this.Price / this.Volume; } return 0; }
}
2017-10-26 18:52:58 +02:00
}
}