Current Ratio

(Current assets / current liabilities)

An algorithm that trades stocks with the highest current ratio values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 78.55%
Drawdown: -70.61%
Benchmark (S&P 500): 276.95%
import quantopian.algorithm as algo
from quantopian.pipeline import Pipeline
from quantopian.pipeline.filters import Q3000US
from quantopian.pipeline.data.morningstar import Fundamentals as ms
import quantopian.optimize as opt

import numpy as np
import pandas as pd


def initialize(context):
    context.FINE_FILTER = 5
    context.stock_weights = pd.Series()
    algo.attach_pipeline(make_pipeline(context), 'pipeline')

    schedule_function(
        stocks_weights,
        date_rules.week_start(),
        time_rules.market_open()
    )

    schedule_function(
        trade,
        date_rules.week_start(),
        time_rules.market_open()
    )


def make_pipeline(context):
    univ = Q3000US()
    factor = ms.current_ratio.latest.rank(mask=univ, ascending=False)
    top = factor.top(context.FINE_FILTER)
    pipe = Pipeline(
        columns={'top': top}, screen=univ)
    return pipe


def stocks_weights(context, data):
    df = algo.pipeline_output('pipeline')
    rule = 'top'
    stocks_to_hold = df.query(rule).index
    stock_weight = 1.0 / context.FINE_FILTER
    context.stocks_weights = pd.Series(index=stocks_to_hold, data=stock_weight)


def trade(context, data):
    target_weights = opt.TargetWeights(context.stocks_weights)

    constraints = []
    constraints.append(opt.MaxGrossExposure(1.0))

    order_optimal_portfolio(
        objective=target_weights,
        constraints=constraints
    )

Net Income Growth

(((Net income current - net income from previous quarter) / net income current) * 100)

An algorithm that trades stocks with the highest percentages of net income growth weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 61.41%
Drawdown: -72.47%
Benchmark (S&P 500): 276.95%
factor = ms.net_income_growth.latest.rank(mask=univ, ascending=False)

Net Margin

(Net income / revenue)

An algorithm that trades stocks with the highest net margin values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 16.2%
Drawdown: -84.68%
Benchmark (S&P 500): 276.95%
factor = ms.net_margin.latest.rank(mask=univ, ascending=False)

Operation Revenue Growth, Three Month Average

(((Operation revenue current - operation revenue from previous quarter) / operation revenue current) * 100)

An algorithm that trades stocks with the highest percentages of operation revenue growth weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 358.41%
Drawdown: -86.73%
Benchmark (S&P 500): 276.95%
factor = ms.operation_revenue_growth3_month_avg.latest.rank(mask=univ, ascending=False)

Quick Ratio

(Liquidity / liabilities)

An algorithm that trades stocks with the highest quick ratio values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 317.22%
Drawdown: -58.24%
Benchmark (S&P 500): 276.95%
factor = ms.quick_ratio.latest.rank(mask=univ, ascending=False)

Revenue Growth

(((Revenue current - revenue from previous quarter) / revenue current) * 100)

An algorithm that trades stocks with the highest percentages of revenue growth weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 211.05%
Drawdown: -87.44%
Benchmark (S&P 500): 276.95%
factor = ms.revenue_growth.latest.rank(mask=univ, ascending=False)

Return on Assets (ROA)

(Net income / total assets)

An algorithm that trades stocks with the highest return on assets (ROA) values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: -62.16%
Drawdown: -85.02%
Benchmark (S&P 500): 276.95%
factor = ms.roa.latest.rank(mask=univ, ascending=False)

Return on Equity (ROE)

(Net income / total common equity)

An algorithm that trades stocks with the highest return on equity (ROE) values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 24.3%
Drawdown: -87.77%
Benchmark (S&P 500): 276.95%
factor = ms.roe.latest.rank(mask=univ, ascending=False)

Return on Invested Capital (ROIC)

(Net income / (total equity + total debt and capital lease obligation))

An algorithm that trades stocks with the highest return on invested capital (ROIC) values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 36.25%
Drawdown: -72.09%
Benchmark (S&P 500): 276.95%
factor = ms.roic.latest.rank(mask=univ, ascending=False)

Total Debt to Equity Ratio

(Total debt / common equity)

An algorithm that trades stocks with the lowest debt to equity ratio values weekly.

Starting capital: $10,000
Max leverage: 1
Jan 2, 2006 - Sep 1, 2020

Returns: 100.86%
Drawdown: -31.12%
Benchmark (S&P 500): 276.95%
def make_pipeline(context):
    univ = Q3000US()

    debt_eq_low = ms.total_debt_equity_ratio.latest < 0.5
    #debt_eq_hi = ms.total_debt_equity_ratio.latest > 0.5

    factor = ms.total_debt_equity_ratio.latest.rank(mask=debt_eq_low, ascending=True)
    #factor = ms.total_debt_equity_ratio.latest.rank(mask=debt_eq_hi, ascending=False)
    top = factor.top(context.FINE_FILTER)
    pipe = Pipeline(
        columns={'top': top}, screen=univ)
    return pipe
Terms:
1. Current Ratio Investopedia
2. Net Income Growth Investopedia
3. Net Margin Investopedia
4. Operation Revenue Growth Investopedia
5. Quick Ratio Investopedia
6. Revenue Investopedia
7. Return on Assets (ROA) Investopedia
8. Return on Equity (ROE) Investopedia
9. Return on Invested Capital (ROIC) Investopedia
10. Debt to Equity Ratio Investopedia


Statements on this website are for informational purposes only and do not constitute a recommendation or advice by the website owner to transact any security or market instrument. All trading activity involves known and unknown risk. Historical data presented is not always indicative of future performance.

Social

X
Github

Contact

Email