Skip to content

Commit 4148acd

Browse files
Override GetBuyingPowerModel to support USDC collaterla in dYdX brokerage
1 parent 7735917 commit 4148acd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Common/Brokerages/dYdXBrokerageModel.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ public dYdXBrokerageModel(AccountType accountType = AccountType.Margin) : base(a
4343
}
4444
}
4545

46+
/// <summary>
47+
/// Gets a new buying power model for the security, returning the default model with the security's configured leverage.
48+
/// For cash accounts, leverage = 1 is used.
49+
/// </summary>
50+
/// <param name="security">The security to get a buying power model for</param>
51+
/// <returns>The buying power model for this brokerage/security</returns>
52+
public override IBuyingPowerModel GetBuyingPowerModel(Security security)
53+
{
54+
return security?.Type switch
55+
{
56+
SecurityType.CryptoFuture => new SecurityMarginModel(GetLeverage(security)),
57+
_ => base.GetBuyingPowerModel(security)
58+
};
59+
}
60+
4661
/// <summary>
4762
/// Provides dYdX fee model
4863
/// </summary>
@@ -145,4 +160,4 @@ private static IReadOnlyDictionary<SecurityType, string> GetDefaultMarkets(strin
145160
map[SecurityType.CryptoFuture] = marketName;
146161
return map.ToReadOnlyDictionary();
147162
}
148-
}
163+
}

0 commit comments

Comments
 (0)