sheet_name='Sub_States') print(distribution_info) print("HELLO DOLLY") print(distribution_info.loc[('Elagolix Approved', 'Clean Approval')]) #distribution_df = distribution_info.reset_index().set_index('State') # Create a Scenario where the Core Probability of Success is .90. crl = distribution_info.loc['CRL'] crl_substate = crl.loc['CRL - No Hope'] crl_substate.loc['Price'] = 1000 substates = list(crl.iterrows()) print("HELLO STACEY") print(substates) for substate in substates: print(type(substate), len(substate), type(substate[0]), type(substate[1])) print("HELLO SUSAN") tprint(distribution_info.loc['CRL'].loc[substate[0], :], "\n") tprint(substate[1], "\n") distribution_info.loc['CRL'].loc[substate[0], :] = substate[1].T distribution_info.loc[('CRL', substate[0])] = substate[1] print(distribution_info) def change_core_scenario(distribution_df, new_core_scenario): print(distribution_info.loc['CRL']) #change_core_scenario(distribution_df, 'hi')
evt1.hello = 'HelloThere' evt1.name='Sup' print(Event.__dict__) print(evt1.__dict__) print(Paul.__class__, p.__class__) print(dir(Paul), "\n-------------------") print(dir(p), "\n''''''''''''''''''") print(vars(Paul) is Paul.__dict__, vars(Paul) == Paul.__dict__) print(vars(Paul)) print(p.__dict__) print(p.__doc__) print(Paul.__dict__, "\n''''''''''''''''''''") tprint(Paul.__dict__['__dict__']) print(Paul().__dict__) print(Paul, Paul()) print(paul_resources.Aaron, paul_resources.Aaron()) print(Aaron, Aaron()) print(Paul.__name__, Aaron.__name__, main_function.__name__) print("HERE:", str(p), repr(p), str(p) is repr(p), str(p) == repr(p)) print(Paul.__module__, Aaron.__module__, main_function.__module__) print(p.__module__) print(Paul.__doc__) print(paul_resources.daily_returns) print(main_function)
2: 'HV', 3: 'Alpha_Ratio', 4: 'Adj_Alpha_Ratio', 5: 'Sample_Size' }, inplace=True) alpha_df.set_index('Stock', inplace=True) return alpha_df stocks = PriceTable.columns.values.tolist() stocks = [i for i in stocks if i in {'AAPL', 'GOOG', 'FB', 'AMZN'}] prices_df = PriceTable.loc[:, stocks] alpha_df = alpha_df(prices_df, 252) tprint(stocks) print(alpha_df.sort_values('Adj_Alpha_Ratio', ascending=False)) def graph(): values = alpha_df['Adj_Alpha_Ratio'].tolist() bins = np.arange(-5.5, 6.5, 1) plt.hist(values, bins, histtype='bar', rwidth=.8) plt.xlabel('Adj_Alpha_Ratio') plt.ylabel('Frequency') plt.title('S&P 500 Alpha Distribution') plt.legend() plt.show()
index_col = [0,1], sheet_name = 'TimingMappings') TimingMappings = TimingMappings.reset_index().set_index('level_1').loc[:, ['Start', 'End']] mappings = pd.read_excel('TimingMappings.xlsx', header = [0,1], index_col = [0,1], sheet_name = 'TimingMappings') print(mappings) print(mappings.index.values) print(mappings.index.names) print(mappings.columns.values) print(mappings.columns.names) my_slice = mappings.loc[('Halves', '1H'), ('Start', 'Day')] my_slice = mappings.loc['Halves', ('Start', 'Day')] tprint(my_slice) my_slice = mappings.xs('Quarters') print(my_slice) my_slice = mappings.reset_index().set_index('level_1').loc[:, ['Start', 'End']] print(my_slice) my_slice = my_slice.loc['1H', ('Start', 'Month')] print(my_slice) years = descriptors.loc[:, 'Years'].dropna().tolist() guidance = descriptors.loc[:, 'Guidance'].dropna().tolist() halves = descriptors.loc[:, 'Halves'].dropna().tolist() months = descriptors.loc[:, 'Months'].dropna().tolist() weeks = descriptors.loc[:, 'Weeks'].dropna().tolist() def get_event_start_date_from_timing_descriptor(timing_descriptor): timing_period = timing_descriptor[0:-5]
stock2 = 'AAPL' index = 'QQQ' beta_lookback = 252 chart_lookback = beta_lookback base = 100 beta = Beta(stock, index, beta_lookback, ScrubParams(.075, .01, .8)).beta beta2 = Beta(stock2, index, beta_lookback, ScrubParams(.075, .01, .8)).beta #beta, beta2 = 0.0, 0.0 # Stock Lines to plot stock_line = StockLineSimple(stock, chart_lookback, base) index_line = StockLineSimple(index, chart_lookback, base) stock_line_adj = StockLineBetaAdjusted(stock, chart_lookback, beta, index, base) tprint(stock_line_adj.prices_df.round(2)) stock_line_adj2 = StockLineBetaAdjusted(stock2, chart_lookback, beta2, index, base) stock_lines = [ stock_line.stock_line(color='red'), index_line.stock_line(color='black'), stock_line_adj.stock_line(color='blue'), #stock_line_adj2.stock_line(color = 'c') ] StockChart(stock_lines).run() Beta(stock, index, beta_lookback, ScrubParams(.075, .01, .8)).show_scrub_trajectory()