Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
44.096%
Drawdown
41.700%
Expectancy
0
Net Profit
40.493%
Sharpe Ratio
0.923
Probabilistic Sharpe Ratio
39.440%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.145
Beta
0.661
Annual Standard Deviation
0.461
Annual Variance
0.213
Information Ratio
-1.815
Tracking Error
0.241
Treynor Ratio
0.644
Total Fees
$122.73
Estimated Strategy Capacity
$290000.00
Lowest Capacity Asset
BTCUSD 10B
namespace QuantConnect.Algorithm.CSharp
{
    public class KrakenBrokerageExampleAlgorithm : QCAlgorithm
    {
        private Symbol _symbol;
        private bool _ordered = false;
        
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetCash(100000);
            
            SetBrokerageModel(BrokerageName.Kraken, AccountType.Cash);
            
            _symbol = AddCrypto("BTCUSD", Resolution.Minute).Symbol;

            // Set default order properties
            DefaultOrderProperties = new KrakenOrderProperties
            {
                TimeInForce = TimeInForce.GoodTilCanceled,
                PostOnly = false,
                FeeInBase = false,
                FeeInQuote = true,
                NoMarketPriceProtection = true
            };
        }
        
        public override void OnData(Slice data)
        {
            if (Portfolio.Invested)
            {
                return;
            }
            
            // Place an order with the default order properties
            LimitOrder(_symbol, 1, Math.Round(data[_symbol].Price + 100, 1));
            
            // Place an order and with new order properties
            var orderProperties = new KrakenOrderProperties
            {
                PostOnly = true,
                FeeInBase = true,
                FeeInQuote = false,
                NoMarketPriceProtection = false
            };
            var ticket = LimitOrder(_symbol, 1, Math.Round(data[_symbol].Price * 0.9m, 1), orderProperties: orderProperties);
            
            // If we try to call `Update`, an exception is raised
            // ticket.Update(...)
            
            // Update the order
            ticket.Cancel();
            orderProperties.ConditionalOrder = new MarketOrder(_symbol, -1, Time);
            LimitOrder(_symbol, 1, Math.Round(data[_symbol].Price * 0.99m, 1), orderProperties: orderProperties);
        }
        
        public override void OnOrderEvent(OrderEvent orderEvent)
        {
            if (orderEvent.Status == OrderStatus.Filled)
            {
                Debug($"Order fee: {orderEvent.OrderFee}"); // The fees are paid in different currencies if we flip FeeInBase and FeeInQuote
            }
        }
    }
}