35 lines
815 B
C#
35 lines
815 B
C#
using System;
|
|
namespace sharp.trading.cache
|
|
{
|
|
public class WeightedAverage
|
|
{
|
|
public string marketSymbol { get; private set; }
|
|
public string baseSymbol { get; private set; }
|
|
|
|
public double Volume { get; set; }
|
|
public double TotalPrice { get; set; }
|
|
public double AveragePrice { get { return TotalPrice / Volume; } }
|
|
|
|
public WeightedAverage(string msym,string bsym,double vol,double total)
|
|
{
|
|
marketSymbol = msym;
|
|
baseSymbol = bsym;
|
|
Volume = vol;
|
|
TotalPrice = total;
|
|
}
|
|
public WeightedAverage(string msym, string bsym)
|
|
{
|
|
marketSymbol = msym;
|
|
baseSymbol = bsym;
|
|
Volume = 0;
|
|
TotalPrice = 0;
|
|
}
|
|
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("[WeightedAverage: Volume={0}, TotalPrice={1}, AveragePrice={2}]", Volume, TotalPrice, AveragePrice);
|
|
}
|
|
}
|
|
}
|