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.
Implements
Inherited Members
Namespace: TuringTrader.Simulator
Assembly: TuringTrader.Simulator.dll
Syntax
public class Instrument : TimeSeries<Bar>, ITimeSeries<Bar>
Constructors
| Edit this page View SourceInstrument(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 SourceDataSource
Associated DataSource object.
Declaration
public readonly DataSource DataSource
Field Value
| Type | Description |
|---|---|
| DataSource |
Simulator
Parent Simulator object.
Declaration
public readonly SimulatorCore Simulator
Field Value
| Type | Description |
|---|---|
| SimulatorCore |
Properties
| Edit this page View SourceAsk
Time series of ask prices.
Declaration
public ITimeSeries<double> Ask { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
AskVolume
Time series of ask volumes.
Declaration
public ITimeSeries<long> AskVolume { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<long> |
Bid
Time series of bid prices.
Declaration
public ITimeSeries<double> Bid { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
BidVolume
Time series of bid volumes.
Declaration
public ITimeSeries<long> BidVolume { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<long> |
Close
Time series of closing prices.
Declaration
public ITimeSeries<double> Close { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
HasBidAsk
Flag indicating if this instrument has bid/ ask prices.
Declaration
public bool HasBidAsk { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasOHLC
Flag indicating if this instrument has open/ high/ low/ close prices.
Declaration
public bool HasOHLC { get; }
Property Value
| Type | Description |
|---|---|
| bool |
High
Time series of high prices.
Declaration
public ITimeSeries<double> High { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
IsOption
Flag indicating if this is an option contract.
Declaration
public bool IsOption { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Low
Time series of low prices.
Declaration
public ITimeSeries<double> Low { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
Name
Instrument's full name, e.g. Microsoft Corporation.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Nickname
DataSource's nickname.
Declaration
public string Nickname { get; }
Property Value
| Type | Description |
|---|---|
| string |
Open
Time series of opening prices.
Declaration
public ITimeSeries<double> Open { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<double> |
OptionExpiry
Options only: expiry date.
Declaration
public DateTime OptionExpiry { get; }
Property Value
| Type | Description |
|---|---|
| DateTime |
OptionIsPut
Options only: flag indicating put (true), or call (false).
Declaration
public bool OptionIsPut { get; }
Property Value
| Type | Description |
|---|---|
| bool |
OptionStrike
Options only: strike price.
Declaration
public double OptionStrike { get; }
Property Value
| Type | Description |
|---|---|
| double |
OptionUnderlying
Options only: Underlying symbol.
Declaration
public string OptionUnderlying { get; }
Property Value
| Type | Description |
|---|---|
| string |
Position
Return current open position size.
Declaration
public int Position { get; }
Property Value
| Type | Description |
|---|---|
| int |
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 |
Time
Time series with bar time stamps.
Declaration
public ITimeSeries<DateTime> Time { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<DateTime> |
Volume
Time series of trading volumes.
Declaration
public ITimeSeries<long> Volume { get; }
Property Value
| Type | Description |
|---|---|
| ITimeSeries<long> |
Methods
| Edit this page View SourceTrade(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 |