Overall Statistics
Total Orders
91
Average Win
3.03%
Average Loss
-1.52%
Compounding Annual Return
-69.408%
Drawdown
38.800%
Expectancy
-0.321
Start Equity
100000.0
End Equity
67353.16
Net Profit
-32.647%
Sharpe Ratio
-1.137
Sortino Ratio
-1.593
Probabilistic Sharpe Ratio
6.199%
Loss Rate
77%
Win Rate
23%
Profit-Loss Ratio
2.00
Alpha
-0.577
Beta
0.1
Annual Standard Deviation
0.475
Annual Variance
0.226
Information Ratio
-1.883
Tracking Error
0.484
Treynor Ratio
-5.417
Total Fees
$0.00
Estimated Strategy Capacity
$140000.00
Lowest Capacity Asset
BTCUSD 2XR
Portfolio Turnover
116.56%
from AlgorithmImports import *

class CoinGeckoAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)   # Set Start Date
        self.set_end_date(2019, 5, 1)    # Set End Date

        self.crypto_symbol = self.add_crypto("BTCUSD").symbol
        self.custom_data_symbol = self.add_data(CoinGecko, "BTC").symbol
        self.window = RollingWindow[CoinGecko](2)

    def on_data(self, slice: Slice) -> None:
        data = slice.Get(CoinGecko)
        if data and self.custom_data_symbol in data:
            self.window.add(data[self.custom_data_symbol])
            if not self.window.is_ready:
                return

            # Buy BTCUSD if the market cap of BTC is increasing
            if self.window[0].market_cap > self.window[1].market_cap:
                self.set_holdings(self.crypto_symbol, 1)
            else:
                self.set_holdings(self.crypto_symbol, -1)

    def on_order_event(self, orderEvent: OrderEvent) -> None:
        if orderEvent.status == OrderStatus.FILLED:
            self.debug(f'Purchased Stock: {orderEvent.symbol}')