Back to Community
Debt to Total Assets with FactSet Data - Template Fundamental Algo

Many of our funded authors have relied upon price driven strategies. As we continue to evaluate and add algorithms to our portfolio, we will be especially interested in new strategies that take advantage of a broader range of fundamental factors.

Debt to Total Assets

The ratio of a company’s debt to its total assets is a measure of the amount of leverage taken on by a company. Higher values (above 1) indicate that a company has more liabilities than assets (aka you owe more than you own), while lower values (below 1) indicate that a company has more equity than debt. In this template, we’ve taken advantage of this measure to test the idea that companies with relatively lower levels of Debt to Total Assets are likely to outperform companies with relatively higher levels of Debt to Total Assets. Read more here.

As we look to expand the set of algorithms receiving allocations over the next few months we expect to give preference to new ideas that take advantage of a broader range of fundamental factors.

To get started, clone this algorithm, improve it with your own ideas, and submit it to the Quantopian Daily Contest.

N.B. As implemented here, this algo doesn't fully meet all of the criteria for entry in the daily contest so we're leaving that as an "exercise for the reader".

Fundamental Sample Strategies Library

To see all of our fundamental sample strategies, please visit our new library post. We will be adding more templates in the future, so keep an eye on the "Algo Template" tag in the Quantopian forums:

Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
import numpy as np
import quantopian.algorithm as algo
import quantopian.optimize as opt
from quantopian.pipeline import Pipeline
from quantopian.pipeline.filters import QTradableStocksUS
from import factset

ZSCORE_FILTER = 3 # Maximum number of standard deviations to include before counting as outliers
ZERO_FILTER = 0.001 # Minimum weight we allow before dropping security

def initialize(context):
    algo.attach_pipeline(make_pipeline(), 'alpha_factor_template')

    # Schedule our rebalance function

    # Record our portfolio variables at the end of day

def make_pipeline():
    # Setting up the variables
    alpha_factor = -factset.Fundamentals.debt.latest / \
    # Standardized logic for each input factor after this point
    alpha_w = alpha_factor.winsorize(min_percentile=0.02,
                                     mask=QTradableStocksUS() & alpha_factor.isfinite())
    alpha_z = alpha_w.zscore()
    alpha_weight = alpha_z / 100.0
    outlier_filter = alpha_z.abs() < ZSCORE_FILTER
    zero_filter = alpha_weight.abs() > ZERO_FILTER

    universe = QTradableStocksUS() & \
               outlier_filter & \

    pipe = Pipeline(
            'alpha_weight': alpha_weight
    return pipe

def before_trading_start(context, data):
    context.pipeline_data = algo.pipeline_output('alpha_factor_template')

def record_vars(context, data):
    # Plot the number of positions over time.

def rebalance(context, data):
    # Retrieve pipeline output
    pipeline_data = context.pipeline_data
    alpha_weight = pipeline_data['alpha_weight']
    alpha_weight_norm = alpha_weight / alpha_weight.abs().sum()

    objective = opt.TargetWeights(alpha_weight_norm)

    # No constraints, want all assets allocated to
    constraints = []
There was a runtime error.

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

4 responses

Hmmm, running this factor through Thomas' NB doesn't make it look too good in either the training set or the testing set. Have I made a mistake somewhere?

Loading notebook preview...

Hi Joakim, I also did not find predictive power using this factor alone.

And yet common sense would appear to dictate that in the very long run companies which keep their balance sheets under control should survive and prosper while the wastrels blow up. It needs to be coupled to asset growth I would imagine. And earnings growth.

short-term credit cycles timescales are typically around 6-8 years. credit is more of an investment factor rather than a trading factor, i think. also, the current credit cycle has lasted well beyond typical; hence, many hedge funds and big money managers are nervous.