Table of Contents

Class Instrument

Namespace
Balsam
Assembly
Balsam.Backtester.dll

Encapsulates relevant information about a particular trading vehicle.

public class Instrument : IInstrument, ICloneable
Inheritance
Instrument
Implements
Inherited Members
Extension Methods

Constructors

Instrument()

Initializes a new empty instrument.

public Instrument()

Instrument(string, InstrumentType, double, double)

Initializes a new instrument using the specified values.

public Instrument(string symbol, InstrumentType instrumentType, double pointValue, double tickSize)

Parameters

symbol string
instrumentType InstrumentType
pointValue double
tickSize double

Properties

AltIdentifier

Gets/sets an alternate identifer (CUSIP, Sedol, etc.).

public string AltIdentifier { get; set; }

Property Value

string

Commission

Gets/sets the default commission per contract/share for this instrument.

public double Commission { get; set; }

Property Value

double

ConversionFactor

Gets/sets a coefficient that can be used to adjust prices to the instrument's proper quoting convention. This is a convenience property only that could be used by a bar server. It is not used or saved by the backtesting engine.

public double ConversionFactor { get; set; }

Property Value

double

Currency

Gets/sets the local currency of the instrument.

public string Currency { get; set; }

Property Value

string

DecimalsToDisplay

Gets/sets the number of decimals to display.

public int DecimalsToDisplay { get; set; }

Property Value

int

Default

Gets a generic equity instrument with point value of 1.

public static Instrument Default { get; }

Property Value

Instrument

Exchange

Gets/sets the exchange on which the instrument is traded.

public string Exchange { get; set; }

Property Value

string

Group

Gets/sets the instrument's industry group.

public string Group { get; set; }

Property Value

string

InitialMargin

Gets/sets the initial margin requirement in local currency.

public double InitialMargin { get; set; }

Property Value

double

InstrumentType

Gets/sets the type of instrument (equity, future, etc.).

public InstrumentType InstrumentType { get; set; }

Property Value

InstrumentType

LimitMove

Gets/sets the distance in points for a limit move.

public double LimitMove { get; set; }

Property Value

double

MaintenanceMargin

Gets/sets the maintenance margin requirement in local currency.

public double MaintenanceMargin { get; set; }

Property Value

double

Months

Gets/sets valid contract months.

public string Months { get; set; }

Property Value

string

Name

Gets/sets the instrument name or description.

public string Name { get; set; }

Property Value

string

PointValue

Gets/sets the value of a 1.0 move in local currency.

public double PointValue { get; set; }

Property Value

double

Sector

Gets/sets the instrument's sector.

public string Sector { get; set; }

Property Value

string

Slippage

Gets/sets the default slippage in points (decimal form) for this instrument.

public double Slippage { get; set; }

Property Value

double

Symbol

Gets/sets the ticker symbol. This will typically act as the key when an instrument is added to a dictionary.

public string Symbol { get; set; }

Property Value

string

Tag

Gets/sets a convenience property for the user to store any arbitrary object.

public object Tag { get; set; }

Property Value

object

TickSize

Gets/sets the decimal equivalent of one tick.

public double TickSize { get; set; }

Property Value

double

TickValue

Gets the value of a one tick move in local currency.

public double TickValue { get; }

Property Value

double

Methods

Clone()

Create a clone of this instrument.

public Instrument Clone()

Returns

Instrument

Equals(Instrument)

Returns true if the specified instrument is identical to the current one.

public bool Equals(Instrument instrument)

Parameters

instrument Instrument

Returns

bool

Equals(object)

Returns true if the specified object is identical to the current instrument.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

Returns a hash code for this instrument.

public override int GetHashCode()

Returns

int

IsTick(double, double)

Returns true if the specified price is an even tick within the specified tolerance.

public bool IsTick(double price, double tolerance = 1E-10)

Parameters

price double
tolerance double

Returns

bool

RoundTickDown(double, double)

Rounds down to the nearest tick if the price is outside the specified tolerance.

public double RoundTickDown(double price, double tolerance = 1E-10)

Parameters

price double
tolerance double

A decimal value which determines the equivalence threshold.

Returns

double

RoundTickNearest(double)

Rounds the specified price to the nearest tick.

public double RoundTickNearest(double price)

Parameters

price double

Returns

double

RoundTickUp(double, double)

Rounds up to the nearest tick if the price is outside the specified tolerance.

public double RoundTickUp(double price, double tolerance = 1E-10)

Parameters

price double
tolerance double

A decimal value which determines the equivalence threshold.

Returns

double

ToString()

Returns a string representation of this instrument.

public override string ToString()

Returns

string

Operators

operator ==(Instrument, Instrument)

Returns true if the specified instruments are equal (either reference equality or all properties are the same).

public static bool operator ==(Instrument left, Instrument right)

Parameters

left Instrument
right Instrument

Returns

bool

operator !=(Instrument, Instrument)

Returns true if the specified instruments are not equal.

public static bool operator !=(Instrument left, Instrument right)

Parameters

left Instrument
right Instrument

Returns

bool