# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda env:py37]
#     language: python
#     name: conda-env-py37-py
# ---

# # spectre Benchmarks

# +
import pandas as pd
print(pd.__version__)
start, end = pd.Timestamp('2013-01-02', tz='UTC'), pd.Timestamp('2018-01-02', tz='UTC')

import sys
sys.path.append('..\\..\\spectre')

from spectre import factors, parallel, data
import pandas as pd
loader = data.ArrowLoader('../../historical_data/us/prices/quandl/wiki_prices.feather')
# -

engine = factors.FactorEngine(loader)
engine.to_cuda()

engine.remove_all_factors()
engine.add(factors.MA(100), 'ma')
# %time dfsp=engine.run(start, end)
dfsp.head(5).append(dfsp.tail(5))

# %timeit engine.run(start, end)
# %timeit -n 3 -r 10 engine.run(start, end)

engine.remove_all_factors()
engine.add(factors.EMA(50, adjust=True), 'ema50')
# %time dfsp=engine.run(start, end)
dfsp.head(5).append(dfsp.tail(5))

# %timeit engine.run(start, end)
# %timeit -n 3 -r 10 engine.run(start, end)

engine.remove_all_factors()
engine.add(factors.MACD(), 'MACD')
# %time dfsp=engine.run(start, end)
dfsp.head(5).append(dfsp.tail(5))

# %timeit engine.run(start, end)
# %timeit -n 3 -r 10 engine.run(start, end)

engine.remove_all_factors()
f = factors.MACD()+factors.RSI()+factors.STOCHF()
engine.add(f.rank().zscore(), 'f')
# %time dfsp=engine.run(start, end)
dfsp.head(5).append(dfsp.tail(5))

# %timeit engine.run(start, end)
# %timeit -n 3 -r 10 engine.run(start, end)







 

import torch
torch.cuda.max_memory_allocated()/1024**3, 'GB'





StarcoderdataJupyterScriptsDedupFiltered