0

This python 2 code generates random time series data with a certain noise:

from common import arbitrary_timeseries
from commonrandom import  generate_trendy_price
from matplotlib.pyplot import show

ans=arbitrary_timeseries(generate_trendy_price(Nlength=180, Tlength=30, Xamplitude=10.0, Volscale=0.1))
ans.plot()
show()

Output:
enter image description here

Does someone know how I can generate this data in python 3?

9
  • What happened when you tried to use the same code in Python 3? Commented Jun 14, 2021 at 21:09
  • Does this answer your question? Generate random timeseries data with dates Commented Jun 14, 2021 at 21:24
  • @mkrieger1 That the common and commonrandom modules aren't supported in Python 3. Commented Jun 14, 2021 at 21:24
  • What are they, anyway? Commented Jun 14, 2021 at 21:25
  • @crissal Not really I can't generate noise using that method. But maybe I can add noise later hmmm. Commented Jun 14, 2021 at 21:27

1 Answer 1

1

You can use simple Markov process like this one:

import random

def random_timeseries(initial_value: float, volatility: float, count: int) -> list:
    time_series = [initial_value, ]
    for _ in range(count):
        time_series.append(time_series[-1] + initial_value * random.gauss(0, 1) * volatility)
    return time_series

ts = random_timeseries(1.2, 0.15, 100)

Now you have list with random values which can be zipped with any timestamps. enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.