| Overall Statistics |
|
Total Orders 77 Average Win 2.04% Average Loss -0.98% Compounding Annual Return 13.411% Drawdown 5.800% Expectancy 1.355 Start Equity 1000000.00 End Equity 1606433.50 Net Profit 60.643% Sharpe Ratio 1.032 Sortino Ratio 1.443 Probabilistic Sharpe Ratio 84.065% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 2.09 Alpha 0.059 Beta 0.065 Annual Standard Deviation 0.063 Annual Variance 0.004 Information Ratio -0.116 Tracking Error 0.144 Treynor Ratio 0.989 Total Fees $0.00 Estimated Strategy Capacity $630000.00 Lowest Capacity Asset USDJPY 8G Portfolio Turnover 5.56% |
# region imports
from AlgorithmImports import *
# endregion
class Ichimokueurusdjpy(QCAlgorithm):
def initialize(self):
# Locally Lean installs free sample data, to download more data please visit https://www.quantconnect.com/docs/v2/lean-cli/datasets/downloading-data
self.set_start_date(2020, 11, 1) # Set Start Date
self.set_end_date(2024, 11, 1) # Set End Date
self._cash = 1000000
self.set_cash(self._cash) # Set Strategy Cash
self.spy = self.add_equity("SPY", Resolution.DAILY)
self.set_benchmark("SPY")
self.usdjpy = self.add_forex("USDJPY", Resolution.DAILY)
self.add_forex("EURUSD", Resolution.DAILY)
self._symbol = self.usdjpy.symbol
self._ichimoku = self.ichimoku(self._symbol, 9, 26, 17, 52, 26, 26)
self.register_indicator(self._symbol,self._ichimoku, Resolution.DAILY)
self.warm_up_indicator(self._symbol, self._ichimoku)
parameter = InitialMarginParameters(self.usdjpy, self._cash)
self.initial_margin = self.usdjpy.buying_power_model.get_initial_margin_requirement(parameter)
self.flag = 'jpy' #variable that tells us if a protfolio contains USDJPY or EURUSD
def on_data(self, data: Slice):
"""on_data event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
"""
if not self.portfolio.invested and self.IsWarmingUp == False and self.portfolio.margin_remaining >= self.initial_margin.value and self._ichimoku.tenkan.current.value > self._ichimoku.kijun.current.value:
self.flag = 'jpy'
#self.set_holdings('SPY', 1)
self.set_holdings("USDJPY", 1)
if self.portfolio.invested and self.IsWarmingUp == False and self.portfolio.margin_remaining >= self.initial_margin.value and self._ichimoku.tenkan.current.value < self._ichimoku.kijun.current.value and self.flag == 'jpy':
self.liquidate()
if not self.portfolio.invested and self.IsWarmingUp == False and self.portfolio.margin_remaining >= self.initial_margin.value and self._ichimoku.tenkan.current.value < self._ichimoku.kijun.current.value:
#self.set_holdings('SPY', 1)
self.set_holdings("EURUSD", 1)
self.flag = 'eur'
if self.portfolio.invested and self.IsWarmingUp == False and self.portfolio.margin_remaining >= self.initial_margin.value and self._ichimoku.tenkan.current.value > self._ichimoku.kijun.current.value and self.flag == 'eur':
self.flag = 'jpy'
self.liquidate()