Overall Statistics
Total Trades
2
Average Win
0.35%
Average Loss
0%
Compounding Annual Return
10.689%
Drawdown
17.200%
Expectancy
0
Net Profit
10.653%
Sharpe Ratio
0.528
Probabilistic Sharpe Ratio
27.765%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.086
Beta
0.238
Annual Standard Deviation
0.164
Annual Variance
0.027
Information Ratio
-1.235
Tracking Error
0.517
Treynor Ratio
0.364
Total Fees
$82.67
Estimated Strategy Capacity
$4500000.00
Lowest Capacity Asset
BTCUSD E3
namespace QuantConnect.Algorithm.CSharp
{
    public class BitfinexBrokerageExampleAlgorithm : QCAlgorithm
    {
        private Symbol _symbol;
        
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetCash(100000);
            
            SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Margin);
            
            _symbol = AddCrypto("BTCUSD", Resolution.Minute).Symbol;
            
            // Set default order properties
            DefaultOrderProperties = new BitfinexOrderProperties
            {
                TimeInForce = TimeInForce.Day,
                Hidden = 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 BitfinexOrderProperties { 
			    TimeInForce = TimeInForce.GoodTilCanceled,
			    PostOnly = true, 
			    Hidden = true
			};
            var ticket = LimitOrder(_symbol, -0.5m, Math.Round(data[_symbol].Price + 5000, 2), orderProperties: orderProperties);
            
            // Update the order
			var response = ticket.Update(new UpdateOrderFields() { 
			    Quantity = -0.4m,
			    LimitPrice = Math.Round(data[_symbol].Price + 1000, 2),
			    Tag = "Informative order tag"
			});
            if (!LiveMode && response.IsSuccess)
            {
                 Debug("Order updated successfully");
            }
        }
    }
}