from enum import Enum

YEARLY = 'yearly'
QUARTERLY = 'quarterly'


USER_AGENT_HEADERS = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 '
                  '(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
}


class TimePeriods(Enum):
    Day = '1d'
    Week = '5d'
    Month = '1mo'
    Quarter = '3mo'
    HalfYear = '6mo'
    Year = '1y'
    TwoYears = '2y'
    FiveYears = '5y'
    TenYears = '10y'
    YTD = 'ytd'
    Max = 'max'


class TimeIntervals(Enum):
    Minute = '1m'
    TwoMinutes = '2m'
    FiveMinutes = '5m'
    FifteenMinutes = '15m'
    HalfHour = '30m'
    Hourly = '60m'
    HourAndAHalf = '90m'
    Daily = '1d'
    FiveDays = '5d'
    Weekly = '1wk'
    Monthly = '1mo'
    Quarterly = '3mo'


class HistoryColumns:
    Date = 'Date'
    Open = 'Open'
    High = 'High'
    Low = 'Low'
    Close = 'Close'
    Volume = 'Volume'
    Dividends = 'Dividends'
    Splits = 'Stock Splits'


class BalanceSheetColumns:
    TotalLiabilities = 'Total Liab'
    OtherLiabilities = 'Other Liab'
    TotalCurrentLiabilities = 'Total Current Liabilities'
    OtherCurrentLiabilities = 'Other Current Liab'

    TotalAssets = 'Total Assets'
    OtherAssets = 'Other Assets'
    TotalCurrentAssets = 'Total Current Assets'
    OtherCurrentAssets = 'Other Current Assets'
    NetTangibleAssets = 'Net Tangible Assets'

    TotalStockholderEquity = 'Total Stockholder Equity'
    RetainedEarnings = 'Retained Earnings'
    CommonStock = 'Common Stock'
    TreasureStock = 'Treasury Stock'
    Cash = 'Cash'
    LongTermDebt = 'Long Term Debt'
    ShortLongTermDebt = 'Short Long Term Debt'
    OtherStockholderEquity = 'Other Stockholder Equity'
    PropertyPlantEquipment = 'Property Plant Equipment'
    LongTermInvestments = 'Long Term Investments'
    ShortTermInvestments = 'Short Term Investments'
    NetReceivables = 'Net Receivables'
    Inventory = 'Inventory'
    AccountsPayable = 'Accounts Payable'


class FinancialColumns:
    RnD = 'Research Development'
    EffectOfAccountingCharges = 'Effect Of Accounting Charges'
    IncomeBeforeTax = 'Income Before Tax'
    MinorityInterest = 'Minority Interest'
    NetIncome = 'Net Income'
    SellingGeneralAdministrative = 'Selling General Administrative'
    GrossProfit = 'Gross Profit'
    Ebit = 'Ebit'
    OperatingIncome = 'Operating Income'
    OtherOperatingExpenses = 'Other Operating Expenses'
    InterestExpense = 'Interest Expense'
    ExtraordinaryItems = 'Extraordinary Items'
    NonRecurring = 'Non Recurring'
    OtherItems = 'Other Items'
    IncomeTaxExpense = 'Income Tax Expense'
    TotalRevenue = 'Total Revenue'
    TotalOperatingExpenses = 'Total Operating Expenses'
    CostOfRevenue = 'Cost Of Revenue'
    TotalOtherIncomeExpenseNet = 'Total Other Income Expense Net'
    DiscontinuedOperations = 'Discontinued Operations'
    NetIncomeFromContinuingOps = 'Net Income From Continuing Ops'
    NetIncomeApplicableToCommonShares = 'Net Income Applicable To Common Shares'


class CashflowColumns:
    Investments = 'Investments'
    ChangeToLiabilities = 'Change To Liabilities'
    TotalCashflowFromInvestingActivities = 'Total Cashflows From Investing Activities'
    NetBorrowings = 'Net Borrowings'
    TotalCashFromFinancingActivities = 'Total Cash From Financing Activities'
    ChangeToOperatingActivities = 'Change To Operating Activities'
    IssuanceOfStock = 'Issuance Of Stock'
    NetIncome = 'Net Income'
    ChangeInCash = 'Change In Cash'
    RepurchaseOfStock = 'Repurchase Of Stock'
    TotalCashFromOperatingActivities = 'Total Cash From Operating Activities'
    Depreciation = 'Depreciation'
    DividendsPaid = 'Dividends Paid'
    ChangeToInventory = 'Change To Inventory'
    ChangeToAccountReceivables = 'Change To Account Receivables'
    OtherCashflowFromFinancingActivities = 'Other Cashflows From Financing Activities'
    ChangeToNetIncome = 'Change To Netincome'
    CapitalExpenditures = 'Capital Expenditures'


class TickerInfoKeys:
    zip = 'zip'
    sector = 'sector'
    fullTimeEmployees = 'fullTimeEmployees'
    longBusinessSummary = 'longBusinessSummary'
    city = 'city'
    phone = 'phone'
    state = 'state'
    country = 'country'
    companyOfficers = 'companyOfficers'
    website = 'website'
    maxAge = 'maxAge'
    address1 = 'address1'
    industry = 'industry'
    previousClose = 'previousClose'
    regularMarketOpen = 'regularMarketOpen'
    twoHundredDayAverage = 'twoHundredDayAverage'
    trailingAnnualDividendYield = 'trailingAnnualDividendYield'
    payoutRatio = 'payoutRatio'
    volume24Hr = 'volume24Hr'
    regularMarketDayHigh = 'regularMarketDayHigh'
    navPrice = 'navPrice'
    averageDailyVolume10Day = 'averageDailyVolume10Day'
    totalAssets = 'totalAssets'
    regularMarketPreviousClose = 'regularMarketPreviousClose'
    fiftyDayAverage = 'fiftyDayAverage'
    trailingAnnualDividendRate = 'trailingAnnualDividendRate'
    open = 'open'
    toCurrency = 'toCurrency'
    averageVolume10days = 'averageVolume10days'
    expireDate = 'expireDate'
    algorithm = 'algorithm'
    dividendRate = 'dividendRate'
    exDividendDate = 'exDividendDate'
    beta = 'beta'
    circulatingSupply = 'circulatingSupply'
    startDate = 'startDate'
    regularMarketDayLow = 'regularMarketDayLow'
    priceHint = 'priceHint'
    currency = 'currency'
    trailingPE = 'trailingPE'
    regularMarketVolume = 'regularMarketVolume'
    lastMarket = 'lastMarket'
    maxSupply = 'maxSupply'
    openInterest = 'openInterest'
    marketCap = 'marketCap'
    volumeAllCurrencies = 'volumeAllCurrencies'
    strikePrice = 'strikePrice'
    averageVolume = 'averageVolume'
    priceToSalesTrailing12Months = 'priceToSalesTrailing12Months'
    dayLow = 'dayLow'
    ask = 'ask'
    ytdReturn = 'ytdReturn'
    askSize = 'askSize'
    volume = 'volume'
    fiftyTwoWeekHigh = 'fiftyTwoWeekHigh'
    forwardPE = 'forwardPE'
    fromCurrency = 'fromCurrency'
    fiveYearAvgDividendYield = 'fiveYearAvgDividendYield'
    fiftyTwoWeekLow = 'fiftyTwoWeekLow'
    bid = 'bid'
    tradeable = 'tradeable'
    dividendYield = 'dividendYield'
    bidSize = 'bidSize'
    dayHigh = 'dayHigh'
    exchange = 'exchange'
    shortName = 'shortName'
    longName = 'longName'
    exchangeTimezoneName = 'exchangeTimezoneName'
    exchangeTimezoneShortName = 'exchangeTimezoneShortName'
    isEsgPopulated = 'isEsgPopulated'
    gmtOffSetMilliseconds = 'gmtOffSetMilliseconds'
    quoteType = 'quoteType'
    symbol = 'symbol'
    messageBoardId = 'messageBoardId'
    market = 'market'
    annualHoldingsTurnover = 'annualHoldingsTurnover'
    enterpriseToRevenue = 'enterpriseToRevenue'
    beta3Year = 'beta3Year'
    enterpriseToEbitda = 'enterpriseToEbitda'
    OneYearChange = '52WeekChange'
    morningStarRiskRating = 'morningStarRiskRating'
    forwardEps = 'forwardEps'
    revenueQuarterlyGrowth = 'revenueQuarterlyGrowth'
    sharesOutstanding = 'sharesOutstanding'
    fundInceptionDate = 'fundInceptionDate'
    annualReportExpenseRatio = 'annualReportExpenseRatio'
    bookValue = 'bookValue'
    sharesShort = 'sharesShort'
    sharesPercentSharesOut = 'sharesPercentSharesOut'
    fundFamily = 'fundFamily'
    lastFiscalYearEnd = 'lastFiscalYearEnd'
    heldPercentInstitutions = 'heldPercentInstitutions'
    netIncomeToCommon = 'netIncomeToCommon'
    trailingEps = 'trailingEps'
    lastDividendValue = 'lastDividendValue'
    SandP52WeekChange = 'SandP52WeekChange'
    priceToBook = 'priceToBook'
    heldPercentInsiders = 'heldPercentInsiders'
    nextFiscalYearEnd = 'nextFiscalYearEnd'
    mostRecentQuarter = 'mostRecentQuarter'
    shortRatio = 'shortRatio'
    sharesShortPreviousMonthDate = 'sharesShortPreviousMonthDate'
    floatShares = 'floatShares'
    enterpriseValue = 'enterpriseValue'
    threeYearAverageReturn = 'threeYearAverageReturn'
    lastSplitDate = 'lastSplitDate'
    lastSplitFactor = 'lastSplitFactor'
    legalType = 'legalType'
    morningStarOverallRating = 'morningStarOverallRating'
    earningsQuarterlyGrowth = 'earningsQuarterlyGrowth'
    dateShortInterest = 'dateShortInterest'
    pegRatio = 'pegRatio'
    lastCapGain = 'lastCapGain'
    shortPercentOfFloat = 'shortPercentOfFloat'
    sharesShortPriorMonth = 'sharesShortPriorMonth'
    category = 'category'
    fiveYearAverageReturn = 'fiveYearAverageReturn'
    regularMarketPrice = 'regularMarketPrice'
    logo_url = 'logo_url'
    ebitdaMargins = 'ebitdaMargins'
    profitMargins = 'profitMargins'
    grossMargins = 'grossMargins'
    operatingCashflow ='operatingCashflow'
    revenueGrowth = 'revenueGrowth'
    operatingMargins = 'operatingMargins'
    ebitda = 'ebitda'
    targetLowPrice = 'targetLowPrice'
    recommendationKey = 'recommendationKey'
    grossProfits = 'grossProfits'
    freeCashflow = 'freeCashflow'
    targetMedianPrice = 'targetMedianPrice'
    currentPrice = 'currentPrice'
    earningsGrowth = 'earningsGrowth'
    currentRatio = 'currentRatio'
    returnOnAssets = 'returnOnAssets'
    numberOfAnalystOpinions = 'numberOfAnalystOpinions'
    targetMeanPrice = 'targetMeanPrice'
    debtToEquity = 'debtToEquity'
    returnOnEquity = 'returnOnEquity'
    targetHighPrice = 'targetHighPrice'
    totalCash = 'totalCash'
    totalDebt = 'totalDebt'
    totalRevenue = 'totalRevenue'
    totalCashPerShare = 'totalCashPerShare'
    financialCurrency = 'financialCurrency'
    revenuePerShare = 'revenuePerShare'
    quickRatio = 'quickRatio'
    recommendationMean = 'recommendationMean'


class SustainabilityColumns:
    palmOil = 'palmOil'
    controversialWeapons = 'controversialWeapons'
    gambling = 'gambling'
    socialScore = 'socialScore'
    nuclear = 'nuclear'
    furLeather = 'furLeather'
    alcoholic = 'alcoholic'
    gmo = 'gmo'
    catholic = 'catholic'
    socialPercentile = 'socialPercentile'
    peerCount = 'peerCount'
    governanceScore = 'governanceScore'
    environmentPercentile = 'environmentPercentile'
    animalTesting = 'animalTesting'
    tobacco = 'tobacco'
    totalEsg = 'totalEsg'
    highestControversy = 'highestControversy'
    esgPerformance = 'esgPerformance'
    coal = 'coal'
    pesticides = 'pesticides'
    adult = 'adult'
    percentile = 'percentile'
    peerGroup = 'peerGroup'
    smallArms = 'smallArms'
    environmentScore = 'environmentScore'
    governancePercentile = 'governancePercentile'
    militaryContract = 'militaryContract'


class InstitutionalHoldersColumns:
    Holder = 'Holder'
    Shares = 'Shares'
    DateReported = 'Date Reported'
    Percentage = '% Out'
    Value = 'Value'


class MajorHoldersKeys(Enum):
    PctSharesByInsiders = 0
    PctSharesByInstitutions = 1
    PctFloatByInstitutions = 2
    NumInstitutionsHolding = 3


class RecommendationColumns:
    Date = 'Date'
    Firm = 'Firm'
    ToGrade = 'To Grade'
    FromGrade = 'From Grade'
    Action = 'Action'


class RecommendationGrades:
    # Warning: recommend checking these keys in a case insensitive manner
    Buy = 'Buy'
    Outperform = 'Outperform'
    Overweight = 'Overweight'
    SectorPerform = 'Sector Perform'
    Neutral = 'Neutral'
    SectorOutperform = 'Sector Outperform'
    Hold = 'Hold'
    MarketPerform = 'Market Perform'
    StrongBuy = 'Strong Buy'
    LongTermBuy = 'Long-term Buy'
    Sell = 'Sell'
    MarketOutperform = 'Market Outperform'
    Positive = 'Positive'
    EqualWeight = 'Equal-weight'
    Perform = 'Perform'
    Negative = 'Negative'
    SectorWeight = 'Sector Weight'
    Reduce = 'Reduce'
    Underweight = 'Underweight'


class EarningsColumns:
    Quarter = 'Quarter'
    Revenue = 'Revenue'
    Earnings = 'Earnings'
