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

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

Callers 1

run_benchmarksFunction · 0.70

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected