User Tools

Site Tools


the_tsl_interpreter

The TSL Interpreter

Why Use the Interpreter

The TSL Interpreter is an advanced feature: it is not be needed for most uses of SystemTrader. However, it provides the ability to create and execute small Python and TSL scripts.

Open the Interpreter

In the sidebar, under UTILITIES, click TSL Interpreter.

Try the Interpreter

Here is a small example of things you can do with the interpreter:

>>> Var = 4
>>> Var + Var
8
>>> Var * 5
20

Access Ticker Data

Here is how to display the last high, close and volume values from the AAPL ticker in the “Yahoo! Finance - Stocks (US)” data-source:

>>> yahoo_us.US.AAPL.Close[0]
346.75
>>> yahoo_us.US.AAPL.High[0]
350.95
>>> yahoo_us.US.AAPL.Volume[0]
11998900.0

Or alternatively:

>>> yahoo_us.US.AAPL.set()
>>> Close[0]
346.75
>>> High[0]
350.95
>>> Volume[0]
11998900.0

Access Indicator Data

Standard moving average (SMA) for the AAPL ticker in the “Yahoo! Finance - Stocks (US)” data-source:

>>> yahoo_us.US.AAPL.SMA(14)[0]
345.10999285714286

Or alternatively:

>>> yahoo_us.US.AAPL.set()
>>> SMA(14)[0]
345.10999285714286

This could be useful, for example, to write some indicator data to a file:

>>> yahoo_us.US.AAPL.set()
>>> Values = [SMA(14)[i] for i in range(100, -1, -1)]
>>> Data = "\n".join(str(v) for v in Values)
>>> File = open("sma.txt", 'w')
>>> File.write(Data)
the_tsl_interpreter.txt · Last modified: 2014/08/02 06:29 (external edit)