Skip to content

Tradomate Data

The TradomateData object is passed to your strategy function as the second argument. This allows you to access the selected symbol’s data from within your strategy function.

Data options

OptionTypeDescriptionValue
symbolstrSymbol of the data.The symbol selected to trade on.
intervalstrInterval of the data.The interval selected to trade on.
openpd.SeriesOpen prices of the data.Open prices of the selected symbol.
highpd.SeriesHigh prices of the data.High prices of the selected symbol.
lowpd.SeriesLow prices of the data.Low prices of the selected symbol.
closepd.SeriesClose prices of the data.Close prices of the selected symbol.
volumepd.SeriesVolume of the data.Volume of the selected symbol.
timestampspd.SeriesTimestamps of the data.Timestamps of the selected symbol.
firstpd.SeriesFirst prices of the data.First prices of the selected symbol.
lastpd.SeriesLast prices of the data.Last prices of the selected symbol.
last_timestampdatetimeLast timestamp of the data.Last timestamp of the selected symbol.
last_openfloatLast open price of the data.Last open price of the selected symbol.
last_highfloatLast high price of the data.Last high price of the selected symbol.
last_lowfloatLast low price of the data.Last low price of the selected symbol.
last_closefloatLast close price of the data.Last close price of the selected symbol.
last_volumefloatLast volume of the data.Last volume of the selected symbol.

Example usage

strategy.py
import tradomate as tm
def strategy_info(config: tm.TradomateConfig):
config.initial_capital = 1000
@tm.strategy()
def my_handler(config: tm.TradomateConfig, data: tm.TradomateData):
# Build your Trading Strategy here.
# Get the last close price
last_close = data.close.iloc[-1]
# Get the last timestamp
last_timestamp = data.timestamps.iloc[-1]
# Get the last open price
last_open = data.open.iloc[-1]
# Get the last high price
last_high = data.high.iloc[-1]
# Get the last low price
last_low = data.low.iloc[-1]
# Get the last volume
last_volume = data.volume.iloc[-1]
# Get the last first price
last_first = data.first.iloc[-1]
# Get the last last price
last_last = data.last.iloc[-1]
# Get the symbol
symbol = data.symbol
# Get the interval
interval = data.interval
# Get the last close price
last_close = data.last_close
# Get the last timestamp
last_timestamp = data.last_timestamp
# Get the last open price
last_open = data.last_open
# Get the last high price
last_high = data.last_high
# Get the last low price
last_low = data.last_low
# Get the last volume
last_volume = data.last_volume
# Get the last first price
last_first = data.last_first
# Get the last last price
last_last = data.last_last