Scripting Framework
Our scripting framework is heavily inspired by PineScript from TradingView for its ease of use and accessibility, and thus our framework will parallel many parts of PineScript
Tickers
The Ticker class is the essential class for retrieving stock data.
Example:
# Create a ticker object for daily Apple stock data
apple_ticker = Ticker(
ticker='AAPL',
timespan='day',
periods=10
)We can then call value() on the ticker:
value = await apple_ticker.value()
print(value[0]) # Print the current value of the stock at this particular time intervalvalue() returns a RedstoneSeries object. Learn more about it here.
Note: value needs to be awaited since we are fetching stock data on runtime.
Ticker() also has these other following functions:
emarsisma
Checkout the guide for more details.
RedstoneSeries
A RedstoneSeries is almost identical to a pandas.Series but with a few key ideas. In fact, under the hood, we represent a RedstoneSeries as a :py:class’pandas.Series’ with its indices being the dates from user’s start to end dates.
Backtesting and Indexing
Here value() returns a RedstoneSeries object.
value = await apple_ticker.value()
print(value[0]) # Print the current value of the stock at this particular time intervalIn the context of a backtest and live execution, a RedstoneSeries’s index has its [0] index refers to the current time point’s value, [1] index refers to the previous time point’s value [2] index refer to the value 2 time points before.
Here is an example: Assume these following prices:

If we backtest the following code with the same configuration as this illustration in Backtesting.

Then, it will follow that the value()[0] at each time point will look like the following:

Working with another pandas.Series
When performing operations on another pandas.Series such as addition, subtraction, multiplication, the operations are done element-wise as long as they have the same length.
Working with another RedstoneSeries
When performing operations on another RedstoneSeries such as addition, subtraction, multiplication, the operations are done element-wise as long as they have the same length. However, things get more complicated for different time ranges. If two RedstoneSeries are of different timespans (one of month and one of year) and we add them, we first find the intersecting indices of the two :py:class’RedstoneSeries’ and then add them element-wise.