def run_analysis(self): self._read_my_holdings() mail_string = "" ; for row in self.smaArray: symbol = row[0] symbolData = symbol_analysis(symbol,self) retString = symbolData._analyze() if symbol in self.holdings: mail_string += '**' mail_string += retString mail_string += '\n' else: if (symbolData._reverseTrend | symbolData._crossing): mail_string += retString mail_string += '\n' #print retString print_colors.my_print (retString,'BOLD') if (self.mailit): mail_intf._send_my_mail(mail_string); return 0
def run_analysis(self): self._read_my_holdings() self.mail_string = "" ; numSyms = len(self.smaArray) #for row in self.smaArray: for index in range(0,numSyms): symbol = self.smaArray[index][0] symbolData = symbol_analysis(symbol,self) retString = symbolData._analyze() if symbol in self.holdings: self.mail_string += '**' self.mail_string += retString self.mail_string += '\n' else: if (symbolData._reverseTrend | symbolData._crossing): self.mail_string += retString self.mail_string += '\n' #print retString print_colors.my_print (retString,'BOLD') if (self.mailit): mail_intf._send_my_mail(self.mail_string); return 0
def run_analysis(self): self._read_my_holdings() self.mail_string = "" numSyms = len(self.smaArray) #for row in self.smaArray: for index in range(0, numSyms): symbol = self.smaArray[index][0] symbolData = symbol_analysis(symbol, self) retString = symbolData._analyze() if symbol in self.holdings: self.mail_string += '**' self.mail_string += retString self.mail_string += '\n' else: if (symbolData._reverseTrend | symbolData._crossing): self.mail_string += retString self.mail_string += '\n' #print retString print_colors.my_print(retString, 'BOLD') if (self.mailit): mail_intf._send_my_mail(self.mail_string) return 0
def _rebalance(self): # Rebalance Formula is # set all falling trend to 5% # For rising trend symbols, # First set all to equal # For reversal += 2 # For accelerating += 2 # For sharp += 2 # Now calculate Total and reduce all by same amount as # necessary to get the required total # # Currently user defined weights are not implemented. # Else, first apply user defined weights to get the starting # values and then apply above algorithm # print "Run portfolio rebalance %s" % (self._filename) myPortfolio = read_portfolio_xml.read_portfolio(self._filename) myhash = {} pctg = {} for ix1 in myPortfolio: symbol = ix1['symbol'] symbolData = symbol_analysis(symbol, self._sma_ptr) myhash[symbol] = symbolData totalNum = len(myPortfolio) totalNumRem = totalNum totalPctSoFar = 0 for symbol in myhash: print symbol symbolData = myhash[symbol] retString = symbolData._analyze() curPct = 0 if (symbolData._newTrend and symbolData._reverseTrend): curPct += 2 if (symbolData._newTrend and symbolData._trendSpeed): curPct += 2 if (symbolData._newTrend and symbolData._trendSlope): curPct += 2 pctg[symbol] = curPct totalPctSoFar += curPct if (not symbolData._newTrend): pctg[symbol] = 5 totalPctSoFar += 5 totalNumRem -= 1 DivideEq = int((100 - totalPctSoFar) / totalNumRem) for symbol in myhash: if (pctg[symbol] != 5): pctg[symbol] += DivideEq for ix1 in myPortfolio: symbol = ix1['symbol'] symbolData = myhash[symbol] print_colors.my_print( "%2s %2s %s" % (ix1['pctg'], pctg[symbol], symbolData._analyze()), 'RED')
def _rebalance(self): # Rebalance Formula is # set all falling trend to 5% # For rising trend symbols, # First set all to equal # For reversal += 2 # For accelerating += 2 # For sharp += 2 # Now calculate Total and reduce all by same amount as # necessary to get the required total # # Currently user defined weights are not implemented. # Else, first apply user defined weights to get the starting # values and then apply above algorithm # print "Run portfolio rebalance %s" % (self._filename) myPortfolio = read_portfolio_xml.read_portfolio(self._filename) myhash = {}; pctg = {}; for ix1 in myPortfolio: symbol = ix1['symbol']; symbolData = symbol_analysis(symbol,self._sma_ptr) myhash[symbol] = symbolData totalNum = len(myPortfolio) totalNumRem = totalNum totalPctSoFar = 0; for symbol in myhash: print symbol symbolData = myhash[symbol] retString = symbolData._analyze() curPct = 0; if (symbolData._newTrend and symbolData._reverseTrend): curPct += 2; if (symbolData._newTrend and symbolData._trendSpeed): curPct += 2; if (symbolData._newTrend and symbolData._trendSlope): curPct += 2; pctg[symbol] = curPct; totalPctSoFar += curPct if (not symbolData._newTrend): pctg[symbol] = 5 ; totalPctSoFar += 5; totalNumRem -= 1; DivideEq = int((100 - totalPctSoFar) / totalNumRem) for symbol in myhash: if (pctg[symbol] != 5): pctg[symbol] += DivideEq for ix1 in myPortfolio: symbol = ix1['symbol']; symbolData = myhash[symbol] print_colors.my_print ( "%2s %2s %s" % (ix1['pctg'],pctg[symbol], symbolData._analyze()),'RED')
def run_mt_analysis(self, numThreads): # # Initialize vars # self._read_my_holdings() self.mail_string = "" self.numCurIndex = -1 self.numRows = len(self.smaArray) threadingCls.run_threads(numThreads, self, self.analysis_called_from_thread) print "All Analysis Done" # # Collect and print Results # for index in range(0, self.numRows): symbol = self.smaArray[index][0] printColor = 'REG' if symbol in self.holdings: if self.interestingResults[symbol]: self.mail_string += '**' + self.retString[symbol] + '\n' printColor = 'BOLD' print_colors.my_print(self.retString[symbol], printColor) # # Mail results if necessary # (retVal, retArr) = self._run_triggers() if retVal: for trig1 in retArr: self.mail_string += '*TRIG*' + trig1 + '\n' if (self.mailit): mail_intf._send_my_mail(self.mail_string) return 0
def run_mt_analysis(self, numThreads): # # Initialize vars # self._read_my_holdings() self.mail_string = "" ; self.numCurIndex = -1; self.numRows = len(self.smaArray) threadingCls.run_threads(numThreads, self, self.analysis_called_from_thread); print "All Analysis Done" # # Collect and print Results # for index in range(0,self.numRows): symbol = self.smaArray[index][0] printColor = 'REG' if symbol in self.holdings: if self.interestingResults[symbol]: self.mail_string += '**' + self.retString[symbol] + '\n' printColor = 'BOLD' print_colors.my_print (self.retString[symbol],printColor) # # Mail results if necessary # (retVal,retArr) = self._run_triggers() if retVal: for trig1 in retArr: self.mail_string += '*TRIG*' + trig1 + '\n' if (self.mailit): mail_intf._send_my_mail(self.mail_string); return 0