Introduction
Automation Platform
Botmain DAO
Building Trading Strategies
API References Dev Live Stream
@botmain/common / Class
abstract

InstrumentProcessorBase

This class is intended to be extended by the user in order to create an instrument-level strategy with name InstrumentProcessor.

When running your strategy, Botmain will create an instance your InstrumentProcessor for every instrument included in the run. Botmain exposes properties, methods, and events to use when building automated strategies.

Properties

NameTypeDescription
bars
IntradayBarsProvider

Provides access to intraday bars data

currentPrice
number

Current price of instrument

currentTime
Date

Current experiment time

daily
DailyBarsProvider

Provides access to daily bars data

dayClose
number

Close price of the day. If intraday or tick subscriptions exist, this property is updated automatically during the day from the last intraday bar close or from the last trade.

dayHigh
number

Highest price of the day. If intraday or tick subscriptions exist, this property is updated automatically during the day from the intraday bar highs or from trades.

dayLow
number

Lowest price of the day. If intraday or tick subscriptions exist, this property is updated automatically during the day from the intraday bar lows or from trades.

dayOpen
number

Today’s open price. If a daily subscription exists, this property is taken from today daily open price. If no daily subscription exists, this property is taken from the first intraday bar open or from the first trade.

exchange
Exchange

The instrument exchange

fundamentals
FundamentalsProvider

Provides access to fundamental data

isActive
boolean

Active state for the instrument. Used to determine whether an instrument is currently trading on its exchange

market
Market

The instrument market

portfolioProcessor
PortfolioProcessorBase

Reference to your custom PortfolioProcessorBase instance. If you need access to your customer PortfolioProcessor you can re-define (override) this property in your InstrumentProcessor to use your custom type.

priceChangeOpen
number

The difference between the current price and today’s open price. priceChangeOpen = currentPrice - dayOpen

priceChangeOpenPct
number

The percentage ratio between the daily price change compared to the today's open price. priceChangeOpenPct = 100 * priceChangeOpen / dayOpen

priceChangeYClose
number

The difference between the current price and yesterday’s close price. priceChangeYClose = currentPrice - yClose

priceChangeYClosePct
number

The percentage ratio between the daily price change compared to yesterday’s close. priceChangeYClosePct = 100 * priceChangeYClose / yClose

quotes
TicksProvider

Provides access to tick data

simulationMode
SimulationMode

The order execution simulation mode

volume
number

Current trading volume of the instrument. If an intraday or tick subscriptions exist, this property is updated automatically during the day from intraday bar volumes or from trade sizes.

yClose
number

Yesterday's close price. If a daily subscription exists, this property is taken from the previous day close. If no daily subscription exists, this property is taken from the last intraday bar close or from the last trade.

Methods

getBarsHistory()

Get historical data from the strategy stack.

Presentation
getBarsHistory(priceType: PriceType, count: number): number[];
Parameters
NameTypeDescription
priceType
PriceType

The type of prices to return. Possible values: "open", "high", "low", or "close"

count
number

The number of prices to return (starting from the most recent one). Must be less than or equal to the stack size

Returns

number[]

getDailyHistory()

Get historical end-of-day data from the strategy stack.

Presentation
getDailyHistory(priceType: PriceType, count: number): number[];
Parameters
NameTypeDescription
priceType
PriceType

The type of prices to return. Possible values: "open", "high", "low", or "close"

count
number

The number of prices to return (starting from the most recent one). Must be less than or equal to the stack size

Returns

number[]

log()

Print information to the integrated strategy log in the Botmain GUI

Presentation
log(text: string): void;
Parameters
NameTypeDescription
text
string
Returns

void

stop()

Stops strategy execution. OnExit() events on instrumental and portfolio levels are called anyway.

Presentation
stop(): void;
Returns

void