code: def random_ohlc_data(
      example_data: pd.DataFrame,
      *,
      frac=1.0,
      random_state: Optional[int] = None,
  ) -> pd.DataFrame:
      """
      OHLC data generator. The generated OHLC data has basic
      [descriptive statistics](https://en.wikipedia.org/wiki/Descriptive_statistics)
      similar to the provided `example_data`.
  
      `frac` is a fraction of data to sample (with replacement). Values greater
      than 1 result in oversampling.
  
      Such random data can be effectively used for stress testing trading
      strategy robustness, Monte Carlo simulations, significance testing, etc.
  
      >>> from backtesting.test import EURUSD
      >>> ohlc_generator = random_ohlc_data(EURUSD)
      >>> next(ohlc_generator)  # returns new random data
      ...
      >>> next(ohlc_generator)  # returns new random data
      ...
      """
  
      def shuffle(x):
          return x.sample(
              frac=frac, replace=frac > 1, random_state=random_state
          )
  
      if (
          len(
              example_data.columns.intersection(
                  {"Open", "High", "Low", "Close"}
              )
          )
          != 4
      ):
          raise ValueError(
              "`data` must be a pandas.DataFrame with columns "
              "'Open', 'High', 'Low', 'Close'"
          )
      while True:
          df = shuffle(example_data)
          df.index = example_data.index
          padding = df.Close - df.Open.shift(-1)
          gaps = shuffle(
              example_data.Open.shift(-1) - example_data.Close
          )
          deltas = (padding + gaps).shift(1).fillna(0).cumsum()
          for key in ("Open", "High", "Low", "Close"):
              df[key] += deltas
          yield df
  
imports: from collections import OrderedDict
  from inspect import currentframe
  from itertools import compress
  from numbers import Number
  from typing import Callable, Optional, Sequence, Union
  import numpy
  import pandas
  from ._plotting import plot_heatmaps
  from ._stats import compute_stats
  from ._util import _Array, _as_str
  from .backtesting import Strategy
label_desc: Use image node_id 8 for calling a global function with example usage: random_ohlc_data(example_data) and returns: x