Overall Statistics |
Total Trades 72 Average Win 13.32% Average Loss -10.21% Compounding Annual Return 45.006% Drawdown 66.300% Expectancy 0.229 Net Profit 69.440% Sharpe Ratio 1.298 Probabilistic Sharpe Ratio 33.880% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 1.30 Alpha 1.566 Beta 1.198 Annual Standard Deviation 1.376 Annual Variance 1.894 Information Ratio 1.19 Tracking Error 1.346 Treynor Ratio 1.491 Total Fees $20721.71 Estimated Strategy Capacity $23000.00 Lowest Capacity Asset ABP RXBFGHC4AV6T |
from AlgorithmImports import * class USEnergyDataAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2021, 6, 1) self.SetCash(100000) # Requesting data self.symbol = self.AddEquity("AXAS", Resolution.Daily).Symbol us_energy_symbol = self.AddData(USEnergy, USEnergy.Petroleum.UnitedStates.WeeklyNetImportsOfTotalPetroleumProducts).Symbol # Historical data history = self.History(USEnergy, us_energy_symbol, 60, Resolution.Daily) self.Log(f"We got {len(history)} items from our history request") # Get latest value for net imports of petroleum products self.previous_value = history.loc[us_energy_symbol].values[-1, -1] def OnData(self, data): # Gather the current net imports of petroleum products points = data.Get(USEnergy) current_value = None for point in points.Values: current_value = point.Value if current_value is None: return # Buy when net imports of petroleum products are increasing self.Debug(f"{current_value} :: {self.previous_value}" ) if current_value > self.previous_value: self.SetHoldings(self.symbol, 1) # Short sell when net imports of petroleum products are decreasing elif current_value < self.previous_value: self.SetHoldings(self.symbol, -1) self.previous_value = current_value