# This script updates all of the morning values import shelve import cell # Create a list of values to update. vals = ['total_val','equity_val','fixed_val','cash_val','wfa_val','acorns_val','robinhood_val','LGMAX_val','LGRRX_val', 'VOO_val','VB_val','VWO_val','VNQ_val','IRDM_val','MSTX_val','SHY_val','LQD_val','DDF_val','LGMAX_shares','LGRRX_shares', 'VOO_shares','VB_shares','VWO_shares','VNQ_shares','IRDM_shares','MSTX_shares','SHY_shares','LQD_shares','DDF_shares', 'CHKR_val','CHKR_shares','equity_percent','fixed_percent','cash_percent','SO_val','SO_shares'] # Open the shelf cells = shelve.open('cell_store') # go value-by-value and update the morning value. for item in vals: mItem = 'morning_' + item cell.setVal('Other', cells[mItem]['worksheet'], cells[mItem]['cell'], cell.getVal('Other', cells[item]['worksheet'],cells[item]['cell']))
val.remove(',') # Join string val = ''.join(val) # convert to float val = float(val) return val ## Get the evening total values, as well as equity, ## fixed income, and cash values and percentages. gSheet = "Other" cells = shelve.open('cell_store') # Total morning_val_s = cell.getVal(gSheet, cells['morning_total_val']['worksheet'], cells['morning_total_val']['cell']) evening_val_s = cell.getVal(gSheet, cells['total_val']['worksheet'], cells['total_val']['cell']) # Category values & percents equity_val_s = cell.getVal(gSheet, cells['equity_val']['worksheet'], cells['equity_val']['cell']) equity_pct_s = cell.getVal(gSheet, cells['equity_percent']['worksheet'], cells['equity_percent']['cell']) fixed_val_s = cell.getVal(gSheet, cells['fixed_val']['worksheet'], cells['fixed_val']['cell']) fixed_pct_s = cell.getVal(gSheet, cells['fixed_percent']['worksheet'], cells['fixed_percent']['cell']) cash_val_s = cell.getVal(gSheet, cells['cash_val']['worksheet'],
#!/usr/bin/python3 # This script gets the total value of a portfolio as of 4am and stores it in the appropriate cell in the google sheet import cell gSheet = "Other" all_sheet = 'All' total_val_cell = 'D2' # Get the current value total_val = cell.getVal(gSheet, all_sheet, total_val_cell) store_sheet = 'storage-morning' morning_total_cell = 'B2' # Set the morning value cell.setVal(gSheet, store_sheet, morning_total_cell, total_val)
# Join string val = ''.join(val) # convert to float val = float(val) return val ## Get the evening and morning total values gSheet = "Other" all_sheet = "All" store_sheet = "storage-morning" total_val_cell = "D2" morning_total_cell = "B2" morning_val_s = cell.getVal(gSheet, store_sheet, morning_total_cell) evening_val_s = cell.getVal(gSheet, all_sheet, total_val_cell) # Convert to number morning_val = clean(morning_val_s) evening_val = clean(evening_val_s) ## Calculate change in value # Dollar change dollar_change = evening_val - morning_val # Percentage change percent_change = 100 * (evening_val - morning_val) / morning_val ## Create email now = datetime.datetime.now() to = '*****@*****.**'