C# Class NPlot.TradingDateTimeAxis

Provides a DateTime axis that removes non-trading days.
Inheritance: DateTimeAxis
Afficher le fichier Open project: mono/nplot-gtk Class Usage Examples

Méthodes publiques

Méthode Description
Clone ( ) : object

Deep copy of DateTimeAxis.

OnTradingDays ( double coord ) : bool

Check whether the given coordinate falls on trading days.

PhysicalToWorld ( PointF p, PointF physicalMin, PointF physicalMax, bool clip ) : double

Transforms a physical coordinate to an axis world coordinate given the physical extremites of the axis.

SparseWorldAdd ( double coord, double delta ) : double

Adds a delta amount to the given world coordinate in such a way that all "sparse gaps" are skipped. In other words, the returned value is in delta distance from the given in the "virtual" world.

TradingDateTimeAxis ( ) : System

Constructor

TradingDateTimeAxis ( Axis a ) : System

Copy Constructor

WithinTradingHours ( double coord ) : bool

Check whether the given coordinate falls within defined trading hours.

WorldToPhysical ( double coord, PointF physicalMin, PointF physicalMax, bool clip ) : PointF

World to physical coordinate transform.

Not sure how much time is spent in this often called function. If it's lots, then worth optimizing (there is scope to do so).

Méthodes protégées

Méthode Description
DoClone ( TradingDateTimeAxis b, TradingDateTimeAxis a ) : void

Helper method for Clone.

LargeTickLabel ( System.DateTime tickDate ) : string

Get an appropriate label name, given the DateTime of a label

ReverseSparseWorldRemap ( double coord ) : double

Remaps a "virtual" world coordinates back to true world coordinates.

SparseWorldRemap ( double coord ) : double

Remap a world coordinate into a "virtual" world, where non-trading dates and times are collapsed.

This code works under asumption that there are exactly 24*60*60 seconds in a day This is strictly speaking not correct but apparently .NET 2.0 does not count leap seconds. Luckilly, Ticks == 0 =~= 0001-01-01T00:00 =~= Monday First tried a version fully on floating point arithmetic, but failed hopelessly due to rounding errors.

Private Methods

Méthode Description
Init ( ) : void

Helper function for constructors.

WorldTickPositions_FirstPass ( Point physicalMin, Point physicalMax, ArrayList &largeTickPositions, ArrayList &smallTickPositions ) : void

Determines the positions of all Large and Small ticks.

The method WorldTickPositions_FirstPass() from the base works just fine, except that it does not account for non-trading gaps in time, therefore, when less than two days are visible an own algorithm is used (to show intraday time). Otherwise the base class implementation is used but the output is corrected to remove ticks on non-trading days (Sat, Sun).

Method Details

Clone() public méthode

Deep copy of DateTimeAxis.
public Clone ( ) : object
Résultat object

DoClone() protected static méthode

Helper method for Clone.
protected static DoClone ( TradingDateTimeAxis b, TradingDateTimeAxis a ) : void
b TradingDateTimeAxis The cloned source object.
a TradingDateTimeAxis The cloned target object.
Résultat void

LargeTickLabel() protected méthode

Get an appropriate label name, given the DateTime of a label
protected LargeTickLabel ( System.DateTime tickDate ) : string
tickDate System.DateTime the DateTime to get the label name for
Résultat string

OnTradingDays() public méthode

Check whether the given coordinate falls on trading days.
public OnTradingDays ( double coord ) : bool
coord double world coordinate in ticks to check.
Résultat bool

PhysicalToWorld() public méthode

Transforms a physical coordinate to an axis world coordinate given the physical extremites of the axis.
public PhysicalToWorld ( PointF p, PointF physicalMin, PointF physicalMax, bool clip ) : double
p PointF the point to convert
physicalMin PointF the physical minimum extremity of the axis
physicalMax PointF the physical maximum extremity of the axis
clip bool whether or not to clip the world value to lie in the range of the axis if it is outside.
Résultat double

ReverseSparseWorldRemap() protected méthode

Remaps a "virtual" world coordinates back to true world coordinates.
protected ReverseSparseWorldRemap ( double coord ) : double
coord double virtual world coordinate to transform.
Résultat double

SparseWorldAdd() public méthode

Adds a delta amount to the given world coordinate in such a way that all "sparse gaps" are skipped. In other words, the returned value is in delta distance from the given in the "virtual" world.
public SparseWorldAdd ( double coord, double delta ) : double
coord double world coordinate to shift.
delta double shif amount in "virtual" units.
Résultat double

SparseWorldRemap() protected méthode

Remap a world coordinate into a "virtual" world, where non-trading dates and times are collapsed.
This code works under asumption that there are exactly 24*60*60 seconds in a day This is strictly speaking not correct but apparently .NET 2.0 does not count leap seconds. Luckilly, Ticks == 0 =~= 0001-01-01T00:00 =~= Monday First tried a version fully on floating point arithmetic, but failed hopelessly due to rounding errors.
protected SparseWorldRemap ( double coord ) : double
coord double world coordinate to transform.
Résultat double

TradingDateTimeAxis() public méthode

Constructor
public TradingDateTimeAxis ( ) : System
Résultat System

TradingDateTimeAxis() public méthode

Copy Constructor
public TradingDateTimeAxis ( Axis a ) : System
a Axis construct a TradingDateTimeAxis based on this provided axis.
Résultat System

WithinTradingHours() public méthode

Check whether the given coordinate falls within defined trading hours.
public WithinTradingHours ( double coord ) : bool
coord double world coordinate in ticks to check.
Résultat bool

WorldToPhysical() public méthode

World to physical coordinate transform.
Not sure how much time is spent in this often called function. If it's lots, then worth optimizing (there is scope to do so).
public WorldToPhysical ( double coord, PointF physicalMin, PointF physicalMax, bool clip ) : PointF
coord double The coordinate value to transform.
physicalMin PointF The physical position corresponding to the world minimum of the axis.
physicalMax PointF The physical position corresponding to the world maximum of the axis.
clip bool if false, then physical value may extend outside worldMin / worldMax. If true, the physical value returned will be clipped to physicalMin or physicalMax if it lies outside this range.
Résultat PointF