New timeseries.tools is out! See what's new# Instant Tearsheet & Performance Analysis

Drop any CSV, XLSX, or JSON file and start analyzing

- Backtests
- Portfolios
- Stocks

If Volatility, VaR, Sharpe, Calmar or Sortino ratio, we have it.

Provide a benchmark to compare your time series against.

Transform your time series data into actionable insights with our powerful tool.

Open Example AnalysisAre you tired of manually analyzing your time series data? Our Python SDK makes it easy and fast to uncover insights and trends in your data.

Getting StartedExplore the whole collection of open-source web components and elements built with the utility classes from Tailwind

ArticleSimple moving average (MA) cross-over strategy using the python backtesting libraryIn this post, we will explore a simple moving average (SMA) cross-over strategy for trading financial assets. The strategy is implemented using the backtesting library, which allows us to test our strategy on historical data and evaluate its performance. This is the code. We will go through it step by step. The SMA cross-over strategy is based on the idea that when a short-term SMA crosses above a long-term SMA, it is a signal to buy the asset, and when the short-term SMA crosses below the long-term SMA, it is a signal to sell the asset. This strategy can be implemented in a few lines of code using the backtesting library. First, we import the Backtest and Strategy classes from the backtesting library, as well as the crossover function, which we will use to check for SMA cross-overs: Next, we define a SMA function that calculates the simple moving average of a given series of values. This function takes two arguments: values, which is a list or array of values, and n, which is the number of previous values to take into account when calculating the SMA: Now, we can define our SmaCross strategy class, which subclasses the Strategy class from the backtesting library. The class defines two class variables, n1 and n2, which represent the two moving average lags that are used in the strategy. The init method of the class precomputes the two SMAs using the SMA function, which we defined earlier: The next method of the class is called at each step of the backtesting process and implements the logic of the strategy. If the first SMA crosses above the second SMA, any existing short trades are closed and the asset is bought; if the second SMA crosses above the first SMA, any existing long trades are closed and the asset is sold: Now that we have implemented our SmaCross strategy class, we can use it to test our strategy on some historical data. We will use the Backtest class from the backtesting library to run the backtesting process. First, we need to import the historical data that we will use for the backtesting. In this example, we will use the GOOG data, which is included in the backtesting library and represents the daily closing prices of Google's stock. Next, we create an instance of the Backtest class, passing it the GOOG data, the SmaCross strategy class that we defined earlier, and some additional parameters such as the initial cash balance and the commission rate: Finally, we call the run method on the Backtest instance to run the backtesting process and store the resulting stats in a stats variable: Now that we have run the backtesting process, we can use the stats variable to evaluate the performance of our strategy. The stats variable is a dictionary that contains a variety of metrics and plots that can help us understand how the strategy performed. We can extract the equity curve from it and store it in a equity variable. We can then use the create_tearsheet method of the TimeseriesTools class to create a tearsheet, which is a plot that displays the equity curve and some additional metrics such as the Sharpe ratio and the maximum drawdown. This plot can help us visualize the performance of the strategy and understand how it evolved over time. Our tearsheet will create these graphs! Also check out some other posts!

Tim David Brachwitz

2022-11-30

6 min readArticleThe Variation of a functionIf you want to know the fundamentals of stochastic calculus, you need to know what the variation of a function is. In mathematics, the variation of a function measures how much the output of the function changes as its input changes. This concept is often used in calculus to study the behavior of functions and their derivatives. In simple terms, a function's variation is a measure of how much the output of the function changes as the input changes. For example, if a function always outputs the same value regardless of the input, then we say that the function has zero variation. On the other hand, if the output of a function changes significantly as the input changes, then we say that the function has a high variation. One way to measure the variation of a function is to calculate the average rate of change of the function over a given interval. This is known as the differential of the function, and it measures how much the output of the function changes on average as the input changes. A function with a large average slope has a high variation, while a function with a small average slope has a low variation. Why do we need to know about this? The functions we care about in stochastic analysis (e.g stocks) usually have a really big or infinite variation! This happens when the output of the function changes arbitrarily as the input changes, without any limiting factors. For example, consider the function ⁍ defined over the interval ⁍. This function has a finite range of ⁍, and its derivative ⁍ has a maximum value of ⁍ at ⁍ and a minimum value of ⁍ at ⁍. Therefore, the function ⁍ has a finite variation over the interval ⁍. Now consider the function ⁍. This function also has a finite range of ⁍, but its derivative ⁍ has a maximum value of ⁍ at ⁍ and a minimum value of ⁍ at ⁍. Therefore, the function ⁍ has a higher variation over the interval ⁍ than the function ⁍. However, if we extend the domain of the function ⁍ to include all real numbers, then the derivative ⁍ becomes unbounded. This means that the output of the function ⁍ can change arbitrarily as the input ⁍ changes, without any limiting factors. In this case, we say that the function ⁍ has infinite variation over the interval of all real numbers. In summary, a function can have infinite variation if its derivative is unbounded over the domain of the function. This means that the output of the function can change arbitrarily as the input changes, without any limiting factors. This is the definition of of the total variation for a differentiable function is. This is the more general definition: This means we can quantize the domain, sample some random values and add those using Riemann. Calculating the Variation of sin between ⁍ and ⁍: This code generates 1000 random samples of the function f(x) = sin(x) over the interval [0, 2π]. It then plots the samples and the function itself, and computes the total variation of the samples using the formula I provided earlier. Finally, it prints the value of the total variation.

Tim David Brachwitz

2022-11-30

6 min readArticleWhat is a Brownian Bridge?The Brownian bridge is a type of stochastic process that is related to Brownian motion. It is called a "bridge" because it is a stochastic process hat starts at one point, moves randomly according to Brownian motion, and ends at another predefined point. The Brownian bridge is used in many different fields, including finance and engineering, to model the random movement of particles or objects. This is some code that illustrates how it looks like.

Tim David Brachwitz

2022-11-30

6 min read2653

1.131.739

510+

We are focusing on financial time series analysis first but we'll eventually expand the functionality to sales, marketing and usage data.

We will add machine learning models to forecast future values and to detect anomalies.