MCPcopy Create free account
hub / github.com/Open-Quant/openquant / make_dataset

Function make_dataset

python/benchmarks/benchmark_data_processing.py:147–169  ·  view source on GitHub ↗
(rows_per_symbol: int, symbols: list[str])

Source from the content-addressed store, hash-verified

145def make_dataset(rows_per_symbol: int, symbols: list[str]) -> pl.DataFrame:
146 frames: list[pl.DataFrame] = []
147 ts_base = pl.datetime_range(
148 start=pl.datetime(2020, 1, 1),
149 end=pl.datetime(2020, 1, 1) + pl.duration(minutes=rows_per_symbol - 1),
150 interval="1m",
151 eager=True,
152 )
153 for symbol in symbols:
154 frames.append(
155 pl.DataFrame(
156 {
157 "ts": ts_base,
158 "symbol": [symbol] * rows_per_symbol,
159 "open": pl.arange(0, rows_per_symbol, eager=True).cast(pl.Float64) + 100.0,
160 "high": pl.arange(0, rows_per_symbol, eager=True).cast(pl.Float64) + 100.5,
161 "low": pl.arange(0, rows_per_symbol, eager=True).cast(pl.Float64) + 99.5,
162 "close": pl.arange(0, rows_per_symbol, eager=True).cast(pl.Float64) + 100.2,
163 "volume": pl.repeat(1000.0, rows_per_symbol, eager=True),
164 }
165 )
166 )
167 return pl.concat(frames, rechunk=True)
168
169
170def run_benchmarks(rows_per_symbol: int, symbols: int, iterations: int) -> dict[str, Any]:
171 symbol_names = [f"SYM{i}" for i in range(symbols)]
172 base = make_dataset(rows_per_symbol, symbol_names)

Callers 1

run_benchmarksFunction · 0.70

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected