Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Start Equity
100000.00
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
1.653
Tracking Error
0.049
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
# region imports
from AlgorithmImports import *
# endregion

class VirtualBlackParrot(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2024, 6, 1)
        self.set_cash(100000)
        self.set_brokerage_model(BrokerageName.OANDA_BROKERAGE, AccountType.MARGIN)

        self.forex_tickers = ["EURUSD"]
        self.init = {}
        
        for ticker in self.forex_tickers:
            self.add_forex(ticker, Resolution.MINUTE, market=Market.OANDA)

            h4_consolidator = QuoteBarConsolidator(self._custom_forex_h4)
            h4_consolidator.data_consolidated += self.four_hour_consolidated
            self.subscription_manager.add_consolidator(ticker, h4_consolidator)

            self.init[ticker] = False

        self.set_warmup(timedelta(hours=120))

    def _custom_forex_h4(self, dt):
        if all([value for value in self.init.values()]):
            # after the first bar, consolidate every 4 hours
            return CalendarInfo(dt, timedelta(hours=4))
        else:
            # first bar will consolidate at current day 17:00
            return CalendarInfo(dt, dt.replace(hour=17, minute=0, second=0) - dt)

    def four_hour_consolidated(self, sender, bar):
        ticker = bar.symbol.value
        self.init[ticker] = True
        if self.is_warming_up:
            return
        self.debug(f"{self.time} - {ticker} H4 Consolidated. EndTime: {bar.EndTime}")

    def on_data(self, data: Slice):
        if self.is_warming_up:
            return
        return