Overall Statistics |
Total Orders 1 Average Win 0% Average Loss 0% Compounding Annual Return 6.626% Drawdown 0.800% Expectancy 0 Start Equity 100000 End Equity 100193.54 Net Profit 0.194% Sharpe Ratio 0.021 Sortino Ratio 0.029 Probabilistic Sharpe Ratio 50.504% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.031 Beta 1.058 Annual Standard Deviation 0.047 Annual Variance 0.002 Information Ratio 5.264 Tracking Error 0.006 Treynor Ratio 0.001 Total Fees $1.24 Estimated Strategy Capacity $980000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 9.01% |
from AlgorithmImports import * from Newtonsoft.Json import JsonConvert from System.Collections.Generic import List class ObjectStoreInsightsAlgorithm(QCAlgorithm): def initialize(self): self.universe_settings.resolution = Resolution.DAILY self.set_start_date(2023,4,1) self.set_end_date(2023,4,11) self.set_cash(100000) self.insights_key = f"{self.project_id}/insights" # Read the file with the insights if self.object_store.contains_key(self.insights_key): insights = self.object_store.read_json[List[Insight]](self.insights_key) self.log(f"Read {len(insights)} insight(s) from the Object Store") self.insights.add_range(insights) # Delete the key to reuse it self.object_store.delete(self.insights_key) self.set_universe_selection(ManualUniverseSelectionModel([ Symbol.create("SPY", SecurityType.EQUITY, Market.USA) ])) self.set_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(5), 0.025, None)) self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(Resolution.DAILY)) def on_end_of_algorithm(self): # Get all active insights insights = self.insights.get_insights(lambda x: x.is_active(self.utc_time)) # If we want to save all insights (expired and active), we can use # insights = self.insights.get_insights(lambda x: True) self.log(f"Save {len(insights)} insight(s) to the Object Store.") content = ','.join([JsonConvert.SerializeObject(x) for x in insights]) self.object_store.save(self.insights_key, f'[{content}]')