importarcticdbasadb# This example assumes the below variables (host, bucket, access, secret) are validly setac=adb.Arctic(f"s3://{HOST}:{BUCKET}?access={ACCESS}&secret={SECRET})library="my_library"iflibrarynotinac.list_libraries():ac.create_library(library)library=ac[library]# Assumes there are CSV files containing pricing data and factor data. Each time we've written ALL new factor files# to their symbol, we'll take a snapshot across all symbols.fori,finenumerate(sorted(glob.glob('*.csv'),key=lambdaf:f.split('_')[1].split('.')[0])):df=pd.read_csv(f)if'FACTORS'inf:library.write(f,df)# SNAP_{i} will forever point to all symbols that exist at this time at their current latest versionlibrary.snapshot(f"SNAP_{i}")else:df=df.set_index(df.columns[0])df.index=df.index.to_datetime()library.append(pricing_symbol,df,write_if_missing=True)snapshots=library.list_snapshots()symbols=library.list_symbols(snapshot_name=list(snapshots.keys())[0])
To generate this data, the following code can be used: