Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Start Equity
100000
End Equity
100000
Net Profit
0%
Sharpe Ratio
0
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
Drawdown Recovery
0
#region imports
    using System;
    using QuantConnect;
    using QuantConnect.Brokerages;
    using QuantConnect.Algorithm;
    using QuantConnect.Data;
    using QuantConnect.Orders;
#endregion

public class dYdXBrokerageExampleAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    
    public override void Initialize()
    {
        SetStartDate(2024, 9, 1);
        SetCash(100000);
        
        SetBrokerageModel(BrokerageName.dYdX, AccountType.Margin);
        
        _symbol = AddCryptoFuture("BTCUSD", Resolution.Minute).Symbol;
        
        // Set default order properties
        DefaultOrderProperties = new dYdXOrderProperties
        {
            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 dYdXOrderProperties { 
            TimeInForce = TimeInForce.GoodTilCanceled,
            PostOnly = true, 
            ReduceOnly = true
        };
        var ticket = LimitOrder(_symbol, -0.5m, Math.Round(data[_symbol].Price + 5000, 2), orderProperties: orderProperties);
    }
}