0
$\begingroup$

I am currently using the FinRL library to try to automate Trading using Reinforcement Learning. However, I wanted to understand how FinRL simulates the stock market using historical data. I read here that they "simulate live stock markets with real market data according to the principle of time-driven simulation", but I could not figure out what is meant by time-driven simulation.

Unrelated to FinRL I read here that you could do it with geometric Brownian motion like this: Assume you have historical stock data $S_0, \dots, S_N$. Then we can calculate the log returns $$ ⁡r_1 = \log\left(\frac{S_1}{S_0}\right), \dots, \log\left(\frac{S_N}{S_{N-1}}\right) $$ Then we can estimate the empirical mean and standard deviation of the log returns $\hat \mu$ and $\hat \sigma$ and simulate a brownian motion $W_t$ and then simulate the stock market using $$ S_t = S_0 e^{(\hat \mu - \frac{\hat\sigma^2}{2})t + \hat \sigma W_t} $$ Does anyone know if FinRL actually simulates the stock market like this? If not, what are some other (common) ways to realistically simulate the stock market using historical data? Maybe use a time series model with estimated parameters from the given historical data (maybe some references?)?

$\endgroup$
2
  • 4
    $\begingroup$ Stock market simulations use one of two methods AFAIK: from a known distribution (for example the Geometric Brownian Motion you mention) or from Monte Carlo resampling of actual past market returns (for example the stationary bootstrap method of Politis and Romano). These are mutually exclusive. (A resampling method spits out daily stock market returns that have occurred on past days, but not in the same order s they occurred). $\endgroup$
    – nbbo2
    May 9 at 22:19
  • $\begingroup$ From their documentations, looks like FinRL 'employs a “training-testing-trading" pipeline to reduce the simulation-to-reality gap. We use historical data (time series) for the “training-testing" part, which is the same as conventional machine learning tasks, and this testing period is for backtesting purpose'. In order words, looks like they are basically using historical data (not resampled) and and pumping it through a machine learning algorithm to come up with some optimization. $\endgroup$ May 10 at 18:14

1 Answer 1

0
$\begingroup$

You can generate an arbitrary amount of data with various hurst values using the hurst package in python. There are examples in the documentation but for a Geo Brownian Motion a hurst of 0.5 suffices.

An approach you might want to take is to compute the $n$ period hurst of a market, take the quantiles of said rolling hursts and interleave data computed with each hurst.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.