Overall Statistics
Total Orders
3
Average Win
0.32%
Average Loss
0%
Compounding Annual Return
2.640%
Drawdown
22.100%
Expectancy
0
Start Equity
100000.00
End Equity
108138.42
Net Profit
8.138%
Sharpe Ratio
0.08
Sortino Ratio
0.106
Probabilistic Sharpe Ratio
10.747%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.06
Beta
0.173
Annual Standard Deviation
0.117
Annual Variance
0.014
Information Ratio
-0.725
Tracking Error
0.54
Treynor Ratio
0.054
Total Fees
$325.15
Estimated Strategy Capacity
$340000.00
Lowest Capacity Asset
BTCUSD 2XR
Portfolio Turnover
0.04%
# region imports
from AlgorithmImports import *
# endregion

class CoinbaseProBrokerageExampleAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2021, 1, 1)
        self.set_end_date(2024, 1, 1)
        
        self.set_cash(100000)
        
        self.set_brokerage_model(BrokerageName.GDAX, AccountType.CASH)
        
        self._symbol = self.add_crypto("BTCUSD", Resolution.MINUTE).symbol
        
        # Set default order properties
        self.default_order_properties = GDAXOrderProperties()
        self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED
        self.default_order_properties.post_only = False


    def on_data(self, data):
        if self.portfolio.invested:
            return
        
        # Place an order with the default order properties 
        self.market_order(self._symbol, 1)
        
        # Place an order with new order properties
        order_properties = GDAXOrderProperties()
        order_properties.post_only = True
        ticket = self.limit_order(self._symbol, -0.5, round(data[self._symbol].price + 5000, 2), order_properties = order_properties)
        
        # If we try to call `Update`, an exception is raised
        # ticket.update()
        
        # Update the order
        ticket.cancel()
        self.limit_order(self._symbol, -0.5, round(data[self._symbol].price + 1000, 2), order_properties = order_properties)