def call_property(self, other_args: List[str]): """Process property command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="property", description= "Returns a portfolio that is weighted based on selected property.", ) parser.add_argument( "-p", "--property", required=bool("-h" not in other_args), type=optimizer_helper.check_valid_property_type, dest="property", choices=self.yf_info_choices, help= """Property info to weigh. Use one of yfinance info options.""", ) parser.add_argument( "-v", "--value", default=1, type=float, dest="value", help="Amount to allocate to portfolio", ) parser.add_argument( "--pie", action="store_true", dest="pie", default=False, help="Display a pie chart for weights", ) ns_parser = parse_known_args_and_warn(parser, other_args) if ns_parser: if len(self.tickers) < 2: console.print( "Please have at least 2 stocks selected to perform calculations." ) return optimizer_view.display_property_weighting( self.tickers, s_property=ns_parser.property, value=ns_parser.value, pie=ns_parser.pie, )
def call_dividend(self, other_args: List[str]): """Process dividend command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="dividend", description="Returns a portfolio that is weighted based dividend yield.", ) parser.add_argument( "-v", "--value", default=1, type=float, dest="value", help="Amount to allocate to portfolio", ) parser.add_argument( "--pie", action="store_true", dest="pie", default=False, help="Display a pie chart for weights", ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return if len(self.tickers) < 2: print("Please have at least 2 stocks selected to perform calculations.") return optimizer_view.display_property_weighting( self.tickers, s_property="dividendYield", value=ns_parser.value, pie=ns_parser.pie, ) except Exception as e: print(e, "\n")
def call_mktcap(self, other_args: List[str]): """Process mktcap command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="mktcap", description= "Returns a portfolio that is weighted based on Market Cap.", ) parser.add_argument( "-v", "--value", default=1, type=float, dest="value", help="Amount to allocate to portfolio", ) parser.add_argument( "--pie", action="store_true", dest="pie", default=False, help="Display a pie chart for weights", ) ns_parser = parse_known_args_and_warn(parser, other_args) if ns_parser: if len(self.tickers) < 2: console.print( "Please have at least 2 stocks selected to perform calculations." ) return optimizer_view.display_property_weighting( self.tickers, s_property="marketCap", value=ns_parser.value, pie=ns_parser.pie, )
def call_property(self, other_args: List[str]): """Process property command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="property", description="Returns a portfolio that is weighted based on selected property.", ) parser.add_argument( "-p", "--property", required=bool("-h" not in other_args), type=optimizer_helper.check_valid_property_type, dest="property", help="""Property info to weigh. Use one of: previousClose, regularMarketOpen, twoHundredDayAverage, trailingAnnualDividendYield, payoutRatio, volume24Hr, regularMarketDayHigh, navPrice, averageDailyVolume10Day, totalAssets, regularMarketPreviousClose, fiftyDayAverage, trailingAnnualDividendRate, open, toCurrency, averageVolume10days,expireDate, yield, algorithm, dividendRate, exDividendDate, beta, circulatingSupply, regularMarketDayLow, priceHint, currency, trailingPE, regularMarketVolume, lastMarket, maxSupply, openInterest,marketCap, volumeAllCurrencies, strikePrice, averageVolume, priceToSalesTrailing12Months, dayLow, ask, ytdReturn,askSize,volume, fiftyTwoWeekHigh, forwardPE, fromCurrency, fiveYearAvgDividendYield, fiftyTwoWeekLow, bid,dividendYield,bidSize, dayHigh, annualHoldingsTurnover, enterpriseToRevenue, beta3Year, profitMargins, enterpriseToEbitda, 52WeekChange, morningStarRiskRating, forwardEps, revenueQuarterlyGrowth, sharesOutstanding, fundInceptionDate, annualReportExpenseRatio, bookValue, sharesShort, sharesPercentSharesOut heldPercentInstitutions, netIncomeToCommon, trailingEps, lastDividendValue, SandP52WeekChange, priceToBook, heldPercentInsiders, shortRatio, sharesShortPreviousMonthDate, floatShares, enterpriseValue,fundFamily, threeYearAverageReturn, lastSplitFactor, legalType, lastDividendDate, morningStarOverallRating, earningsQuarterlyGrowth, pegRatio, lastCapGain, shortPercentOfFloat, sharesShortPriorMonth, impliedSharesOutstanding, fiveYearAverageReturn, and regularMarketPrice.""", ) parser.add_argument( "-v", "--value", default=1, type=float, dest="value", help="Amount to allocate to portfolio", ) parser.add_argument( "--pie", action="store_true", dest="pie", default=False, help="Display a pie chart for weights", ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return if len(self.tickers) < 2: print("Please have at least 2 stocks selected to perform calculations.") return optimizer_view.display_property_weighting( self.tickers, s_property=ns_parser.property, value=ns_parser.value, pie=ns_parser.pie, ) except Exception as e: print(e, "\n")