Show / Hide Table of Contents

Class Instrument

Class representing a tradeable instrument. In essence, an instrument is a time series of bars, enriched by general information about the data source which feeds this instrument. Instruments are created automatically by the simulator engine as required, in many cases leading to instruments being added over the course of a simulation. As indicators typically run on time series of double, instruments break down the time series of bars into multiple series of doubles.

Inheritance
object
TimeSeries<Bar>
Instrument
Implements
ITimeSeries<Bar>
Inherited Members
TimeSeries<Bar>.Clear()
TimeSeries<Bar>.Value
TimeSeries<Bar>.this[int]
TimeSeries<Bar>.BarsAvailable
TimeSeries<Bar>.MaxBarsBack
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TuringTrader.Simulator
Assembly: TuringTrader.Simulator.dll
Syntax
public class Instrument : TimeSeries<Bar>, ITimeSeries<Bar>

Constructors

| Edit this page View Source

Instrument(SimulatorCore, DataSource)

Create and initialize instrument. Algorithms should not create instrument objects directly. Instead, the simulator engine will create these objects as required, and while processing bars from DataSource objects.

Declaration
public Instrument(SimulatorCore simulator, DataSource source)
Parameters
Type Name Description
SimulatorCore simulator

parent simulator object

DataSource source

associated data source

Fields

| Edit this page View Source

DataSource

Associated DataSource object.

Declaration
public readonly DataSource DataSource
Field Value
Type Description
DataSource
| Edit this page View Source

Simulator

Parent Simulator object.

Declaration
public readonly SimulatorCore Simulator
Field Value
Type Description
SimulatorCore

Properties

| Edit this page View Source

Ask

Time series of ask prices.

Declaration
public ITimeSeries<double> Ask { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

AskVolume

Time series of ask volumes.

Declaration
public ITimeSeries<long> AskVolume { get; }
Property Value
Type Description
ITimeSeries<long>
| Edit this page View Source

Bid

Time series of bid prices.

Declaration
public ITimeSeries<double> Bid { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

BidVolume

Time series of bid volumes.

Declaration
public ITimeSeries<long> BidVolume { get; }
Property Value
Type Description
ITimeSeries<long>
| Edit this page View Source

Close

Time series of closing prices.

Declaration
public ITimeSeries<double> Close { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

HasBidAsk

Flag indicating if this instrument has bid/ ask prices.

Declaration
public bool HasBidAsk { get; }
Property Value
Type Description
bool
| Edit this page View Source

HasOHLC

Flag indicating if this instrument has open/ high/ low/ close prices.

Declaration
public bool HasOHLC { get; }
Property Value
Type Description
bool
| Edit this page View Source

High

Time series of high prices.

Declaration
public ITimeSeries<double> High { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

IsOption

Flag indicating if this is an option contract.

Declaration
public bool IsOption { get; }
Property Value
Type Description
bool
| Edit this page View Source

Low

Time series of low prices.

Declaration
public ITimeSeries<double> Low { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

Name

Instrument's full name, e.g. Microsoft Corporation.

Declaration
public string Name { get; }
Property Value
Type Description
string
| Edit this page View Source

Nickname

DataSource's nickname.

Declaration
public string Nickname { get; }
Property Value
Type Description
string
| Edit this page View Source

Open

Time series of opening prices.

Declaration
public ITimeSeries<double> Open { get; }
Property Value
Type Description
ITimeSeries<double>
| Edit this page View Source

OptionExpiry

Options only: expiry date.

Declaration
public DateTime OptionExpiry { get; }
Property Value
Type Description
DateTime
| Edit this page View Source

OptionIsPut

Options only: flag indicating put (true), or call (false).

Declaration
public bool OptionIsPut { get; }
Property Value
Type Description
bool
| Edit this page View Source

OptionStrike

Options only: strike price.

Declaration
public double OptionStrike { get; }
Property Value
Type Description
double
| Edit this page View Source

OptionUnderlying

Options only: Underlying symbol.

Declaration
public string OptionUnderlying { get; }
Property Value
Type Description
string
| Edit this page View Source

Position

Return current open position size.

Declaration
public int Position { get; }
Property Value
Type Description
int
| Edit this page View Source

Symbol

Instrument's fully qualified symbol. For stocks, this is identical to the ticker. For options, this will include the expiry date, direction, and strike price.

Declaration
public string Symbol { get; }
Property Value
Type Description
string
| Edit this page View Source

Time

Time series with bar time stamps.

Declaration
public ITimeSeries<DateTime> Time { get; }
Property Value
Type Description
ITimeSeries<DateTime>
| Edit this page View Source

Volume

Time series of trading volumes.

Declaration
public ITimeSeries<long> Volume { get; }
Property Value
Type Description
ITimeSeries<long>

Methods

| Edit this page View Source

Trade(int, OrderType, double, Func<Instrument, bool>)

Submit trade for this instrument.

Declaration
public Order Trade(int quantity, OrderType tradeExecution = OrderType.openNextBar, double price = 0, Func<Instrument, bool> condition = null)
Parameters
Type Name Description
int quantity

number of contracts to trade

OrderType tradeExecution

type of trade execution

double price

optional price specifier

Func<Instrument, bool> condition

lambda, specifying exec condition

Returns
Type Description
Order

Order object

Implements

ITimeSeries<T>

Extension Methods

IndicatorsBasic.Range(Instrument, int, CacheId, string, int)
IndicatorsMarket.CAPM(Instrument, Instrument, int, CacheId, string, int)
IndicatorsMomentum.ADX(Instrument, int, CacheId, string, int)
IndicatorsMomentum.CCI(Instrument, int, CacheId, string, int)
IndicatorsMomentum.StochasticOscillator(Instrument, int, CacheId, string, int)
IndicatorsMomentum.WilliamsPercentR(Instrument, int, CacheId, string, int)
IndicatorsPrice.CLV(Instrument, CacheId, string, int)
IndicatorsPrice.TypicalPrice(Instrument, CacheId, string, int)
IndicatorsVolatility.AverageTrueRange(Instrument, int, CacheId, string, int)
IndicatorsVolatility.TrueRange(Instrument, CacheId, string, int)
IndicatorsVolume.AccumulationDistributionIndex(Instrument, CacheId, string, int)
IndicatorsVolume.ChaikinOscillator(Instrument, CacheId, string, int)
IndicatorsVolume.MoneyFlowIndex(Instrument, int, CacheId, string, int)
IndicatorsVolume.OnBalanceVolume(Instrument, CacheId, string, int)
UniverseExtension.IsConstituent(Instrument, Universe)
OptionSupport.BlackScholes(Instrument, double, double, double)
OptionSupport.BlackScholesImplied(Instrument, double, double)
  • Edit this page
  • View Source
In this article
Back to top Copyright © 2011-2023, Bertram Enterprises LLC dba TuringTrader.com