Overall Statistics
Total Trades
2
Average Win
0.49%
Average Loss
0%
Compounding Annual Return
11.394%
Drawdown
15.100%
Expectancy
0
Net Profit
10.564%
Sharpe Ratio
0.612
Probabilistic Sharpe Ratio
31.660%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.088
Beta
0.203
Annual Standard Deviation
0.143
Annual Variance
0.02
Information Ratio
-1.406
Tracking Error
0.554
Treynor Ratio
0.432
Total Fees
$23.53
Estimated Strategy Capacity
$2200000.00
Lowest Capacity Asset
BTCUSD 2MN
namespace QuantConnect.Algorithm.CSharp
{
    public class FTXBrokerageExampleAlgorithm : QCAlgorithm
    {
        private Symbol _symbol;
        
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetCash(100000);
            
            SetBrokerageModel(BrokerageName.FTX, AccountType.Margin);
            
            _symbol = AddCrypto("BTCUSD", Resolution.Minute).Symbol;

            // Set default order properties
            DefaultOrderProperties = new FTXOrderProperties
            {
                TimeInForce = TimeInForce.Day,
                ReduceOnly = false,
                PostOnly = false
            };
        }
        
        public override void OnData(Slice data)
        {
            if (Portfolio.Invested)
            {
                return;
            }
            
            // Place an order with the default order properties
            MarketOrder(_symbol, 1);
            
            // Place an order with new order properties
            var orderProperties = new FTXOrderProperties { 
                TimeInForce = TimeInForce.GoodTilCanceled,
                ReduceOnly = true,
                PostOnly = true 
            };
            var ticket = LimitOrder(_symbol, -0.5, Math.Round(data[_symbol].Price + 5000, 0), orderProperties: orderProperties);
            
            // If we try to call `Update`, an exception is raised
            // ticket.Update(...)
            
            // Update the order
            ticket.Cancel();
            LimitOrder(_symbol, -0.5, Math.Round(data[_symbol].Price + 1000, 0), orderProperties: orderProperties);
        }

    }
}