Describe this code [code] After that, reimplement it, cleaning it up. And in particular,…
- User
Describe this code
codefrom alphalibs.pyviz import styler import streamlit as st import pandas as pd from alphalibs.ndrive import driver from alphalibs.jarvis.signal import JarvisSignal, JarvisStrategy from signal_generation.portfolios.unc.borges import Borges from signal_generation.portfolios.macro.cylon import CYLON from alphalibs.finance.phelper import * st.set_page_config(layout="wide") import argparse # Create the argument parser parser = argparse.ArgumentParser(description='Script to do something') # Add the profile argument parser.add_argument( '--profile', type=str, choices=['prod', 'staging', 'sandbox'], default='prod', help='The profile to use (prod, staging, or sandbox)') # Parse the arguments args = parser.parse_args() profile = args.profile options = { 'Borges': (Borges, 'BorgesV0'), 'Cylon': (CYLON, 'UNL'), } selected_option = st.sidebar.selectbox('Select an option', list(options)) featclass, featversion = options[selected_option] feat: JarvisStrategy = featclass(drive=profile) feat.get_hash_dir() rel_hd = feat.hash_dir[lambda x: x.STRATEGY==featversion] feat_complete = rel_hd[lambda x: x['COMPLETE']] feat_appr = rel_hd[lambda x: x['APPROVED']] feat_appr = feat_appr[~feat_appr.GNTD.duplicated(keep='last')] # Use a Streamlit form to select the dataframes with st.form('Select Dataframes'): unique_gntd_dates = ptd(feat_complete['GNTD'].unique()).sort_values(ascending=False).date gntd_selection = st.selectbox("GNTD Filter", list(unique_gntd_dates)) subfeat_complete = feat_complete[feat_complete['GNTD'].dt.date == gntd_selection] selected_df1 = st.selectbox('New Hash', list(subfeat_complete.HASH)) selected_df2_date = st.selectbox('Approved Hash', list(feat_appr.GNTD.dt.date)) selected_df2 = feat_appr[feat_appr.GNTD.dt.date==selected_df2_date]['HASH'].iloc[0] submitted = st.form_submit_button('Submit') # Display the selected dataframes side by side df1 = feat(f"{selected_df1}/{featversion}GNTDATTR") df2 = feat(f"{selected_df2}/{featversion}GNTDATTR") if 'index' in df1.columns: df1.set_index('index', inplace=True) if 'index' in df2.columns: df2.set_index('index', inplace=True) trades = sfs([df1, df2]) rgx = st.text_input("Regex Filter") st.write('## Comparison') col1, col2, col3 = st.columns(3) with col1: st.write(f'### Hash {selected_df1} (date)') st.dataframe(ilkp(df1, rgx)) with col2: st.write(f'### Notarized Date {selected_df2_date}') st.dataframe(ilkp(df2, rgx)) with col3: st.write(f'### Trades') st.dataframe(ilkp(trades, rgx)) st.write("## Aggregates") GMVs = pd.DataFrame({selected_df1: df1.abs().sum(), str(selected_df2_date): df2.abs().sum(), 'Trades':trades.abs().sum()}) NMVs = pd.DataFrame({selected_df1: df1.sum(), str(selected_df2_date): df2.sum(), 'Trades':trades.sum()}) col1, col2, col3 = st.columns(3) with col1: st.write("### GMVs") st.write(GMVs.applymap(styler.fmt_num)) with col2: st.write("### NMVs") st.write(NMVs.applymap(styler.fmt_num)) Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.