Class MarketProfile
- Namespace
- Balsam
- Assembly
- Balsam.Backtester.dll
A class used to build a market profile.
public class MarketProfile : IEnumerable<TPO>, IEnumerable, ICloneable
- Inheritance
-
MarketProfile
- Implements
- Inherited Members
- Extension Methods
Constructors
MarketProfile(BarSeries)
Creates a new market profile using the specified BarSeries, where each tick between the high and low counts once.
public MarketProfile(BarSeries series)
Parameters
series
BarSeries
MarketProfile(BarSeries, bool)
Creates a new market profile using the specified BarSeries and optionally tallies volume by price level rather than just having each price level count once.
public MarketProfile(BarSeries series, bool useVolume)
Parameters
MarketProfile(Instrument)
Creates an empty market profile using the specified instrument.
public MarketProfile(Instrument instrument)
Parameters
instrument
Instrument
MarketProfile(TimeSeries, Instrument)
Creates a new market profile using the specified TimeSeries.
public MarketProfile(TimeSeries series, Instrument instrument)
Parameters
series
TimeSeriesinstrument
Instrument
Properties
AvgCount
Gets the average number of TPO prints per price level.
public double AvgCount { get; }
Property Value
AvgPrice
Gets the average price of the distribution (not to be confused with the most frequent price or fair value.)
public double AvgPrice { get; }
Property Value
Bars
Gets the number of bars that were added to the profile.
public int Bars { get; }
Property Value
BuyImbalance
Gets the number of TPOs greater than fair value.
public double BuyImbalance { get; }
Property Value
Close
Gets the closing price of the distribution.
public double Close { get; }
Property Value
FairValue
Gets fair value or the most frequently traded price. In the event of a tie, the price level closest to the midpoint of the range is returned.
public double FairValue { get; }
Property Value
FirstDate
Gets/sets the first date used in the profile.
public DateTime FirstDate { get; set; }
Property Value
High
Gets the maximum price of the distribution.
public double High { get; }
Property Value
HighVolumePrice
Gets the price at which the most volume traded.
public double HighVolumePrice { get; }
Property Value
InitialBalance
Gets the range of the initial bar used to build the profile.
public Range InitialBalance { get; }
Property Value
Instrument
Gets the instrument on which the market profile is based. The Instrument's DecimalsToDisplay property is used to control rounding.
public Instrument Instrument { get; }
Property Value
LastDate
Gets/sets the last date used in the profile.
public DateTime LastDate { get; set; }
Property Value
Low
Gets the minimum price of the distribution.
public double Low { get; }
Property Value
MaxDensity
Gets the number of TPO prints that comprise the fair value price.
public int MaxDensity { get; }
Property Value
Midpoint
Gets the midpoint of the total range, rounded to the nearest tick. In the event of a tie, the value closest to fair value is returned.
public double Midpoint { get; }
Property Value
NetImbalance
Gets net buy/sell imbalance. Postive number indicates long-term buying pressure.
public double NetImbalance { get; }
Property Value
Open
Gets the opening price of the distribution.
public double Open { get; }
Property Value
PriceLevels
Gets the number of distinct price levels in the distribution.
public int PriceLevels { get; }
Property Value
Range
Gets the range or height of the total profile in points (High - Low).
public double Range { get; }
Property Value
RequiresVolume
Returns true when an Add method must be called with volume.
public bool RequiresVolume { get; }
Property Value
SellImbalance
Gets the number of TPOs below fair value.
public double SellImbalance { get; }
Property Value
Symbol
Gets/sets the symbol.
public string Symbol { get; set; }
Property Value
TPOProfile
Gets the internal dictionary containing TPO counts with the price level as key.
protected SortedDictionary<double, double> TPOProfile { get; }
Property Value
TotalDensity
Gets the number of TPOs comprising the profile.
public int TotalDensity { get; }
Property Value
TotalVolume
Gets the total volume of all points that comprise the profile. If volume was not used, this will match TotalDensity.
public double TotalVolume { get; }
Property Value
VWAP
Gets the volume weighted average price (calculated using the midpoint of a bar multiplied by that bar's volume).
public double VWAP { get; }
Property Value
VolumeProfile
Gets the internal dictionary containing volume with the price level as key.
protected SortedDictionary<double, double> VolumeProfile { get; }
Property Value
Methods
Add(Bar)
Adds the specified bar using all price levels equally, ignoring volume.
public void Add(Bar bar)
Parameters
bar
Bar
Add(Bar, bool)
Adds the specified bar allocating volume equally across all price levels.
public void Add(Bar bar, bool useVolume)
Parameters
Add(TPO)
Adds the specified TPO to the profile.
public void Add(TPO tpo)
Parameters
tpo
TPO
Add(double)
Adds the specified price level to the profile.
public void Add(double price)
Parameters
price
double
Add(double, double)
Adds the specified price and associated volume to the profile.
public void Add(double price, double volume)
Parameters
Bin(MarketProfile, int)
Returns a new market profile combining multiple price levels into one.
public static MarketProfile Bin(MarketProfile profile, int binSize)
Parameters
profile
MarketProfilebinSize
intThe number of price levels per bin.
Returns
Clone()
Returns a clone of this market profile.
public MarketProfile Clone()
Returns
FillGaps()
Fills in any gaps in the market profile with a zero frequency and returns the number of price levels inserted.
public int FillGaps()
Returns
GetCorrelationToNormal()
Returns the correlation of the first differences in the empirical and normal cdfs.
public double GetCorrelationToNormal()
Returns
GetCorrelationToUniform()
Returns the correlation of the first differences in the empirical and uniform cdfs.
public double GetCorrelationToUniform()
Returns
GetDensityAtPrice(double)
Returns the density value (number of TPO prints) at the specified price level.
public double GetDensityAtPrice(double price)
Parameters
price
double
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TPO> GetEnumerator()
Returns
GetMaximumDensity()
Returns the price with the maximum density within the value area.
public double GetMaximumDensity()
Returns
GetMaximumDensity(Range, double)
Returns the price with the maximum density within the specified range. Ties are broken by the distance to the tiebreaker level.
public double GetMaximumDensity(Range range, double tieBreaker)
Parameters
Returns
GetMinimumDensity(Range, double)
Returns the price with the minimum density within the specified range. Ties are broken by the distance to the tiebreaker level.
public double GetMinimumDensity(Range range, double tieBreaker)
Parameters
Returns
GetStandardDeviation()
Returns the standard deviation of TPO prices.
public double GetStandardDeviation()
Returns
GetTPOPivot(Range, double)
Returns the deepest pivot within the specified range subject to a minimum depth ratio. Returns NaN if none found.
public double GetTPOPivot(Range range, double depthRatio = 1)
Parameters
Returns
GetTPOValueArea()
Returns a range that encompasses 70% of the TPO prints centered around fair value.
public Range GetTPOValueArea()
Returns
GetTPOValueArea(double, int, double)
Returns a range that encompasses the specified percentage of the distribution centered around fair value.
public Range GetTPOValueArea(double percentage, int levels, double center)
Parameters
Returns
GetTPOValueAreaPivot(double)
Returns the deepest pivot within the TPO value area surrounded by higher values or NaN if one doesn't exist.
public double GetTPOValueAreaPivot(double depthRatio = 1)
Parameters
depthRatio
double
Returns
GetValueArea()
Returns the range exclusive of single TPO prints.
public Range GetValueArea()
Returns
GetVolumeAtPrice(double)
Returns the volume at the specified price if the profile was built using volume.
public double GetVolumeAtPrice(double price)
Parameters
price
double
Returns
GetVolumeProfile()
Returns an enumerable of TPOs representing the volume profile.
public IEnumerable<TPO> GetVolumeProfile()
Returns
GetVolumeValueArea()
Returns a range that encompasses 70% of the volume centered around the high volume price.
public Range GetVolumeValueArea()
Returns
GetVolumeValueArea(double, int)
Returns a range that encompasses the specified percentage of total volume centered around the high volume price.
public Range GetVolumeValueArea(double percentage, int levels)
Parameters
Returns
Merge(MarketProfile)
Merges the specified profile into this one, returning a new combined profile.
public MarketProfile Merge(MarketProfile profile)
Parameters
profile
MarketProfile
Returns
Merge(params MarketProfile[])
Merges one or more market profiles into a new profile.
public static MarketProfile Merge(params MarketProfile[] profiles)
Parameters
profiles
MarketProfile[]