| Overall Statistics |
|
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -19.619 Tracking Error 0.104 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from AlgorithmImports import *
from universe import CustomUniverseSelectionModel
from datetime import timedelta
class FT1UniverseSelection(QCAlgorithm):
def initialize(self):
self.set_start_date(2020, 2, 1)
self.set_end_date(2020, 2, 10)
self.set_cash(100000)
# Set custom universe
self.universe_settings.schedule.on(self.date_rules.week_end())
self.set_universe_selection(CustomUniverseSelectionModel())
self.set_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(5)))
self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
self.set_risk_management(NullRiskManagementModel())
self.set_execution(NullExecutionModel())
from AlgorithmImports import *
import numpy as np
from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel
class CustomUniverseSelectionModel(FundamentalUniverseSelectionModel):
def __init__(self):
super().__init__()
self.number_of_symbols = 5
def select(self, algorithm: QCAlgorithm, fundamental: [Fundamental]) -> [Symbol]:
algorithm.log(f"Updating Universe on {algorithm.time}")
filtered_symbols = [
f
for f in fundamental
if f.has_fundamental_data
and f.OperationRatios.ROE.HasValue
and f.OperationRatios.ROE.Value > 0.10
]
# Sort by top in market cap, and select the top number_of_symbols
sorted_by_market_cap = sorted(
filtered_symbols,
key=lambda c: c.MarketCap,
reverse=True,
)[: self.number_of_symbols]
# Log selected symbols
algorithm.log("*" * 30)
algorithm.log("Standard Fundamental Data")
for index, f in enumerate(sorted_by_market_cap):
algorithm.log(
f"DATE: {algorithm.time} SYMBOL: {f.symbol.value}, ROE: {f.operation_ratios.roe.value} DividendPerShare: {f.earning_reports.dividend_per_share.value}"
)
return []