Skip to content

Commit b783139

Browse files
committed
Update deribit client
1 parent 0d0d8fd commit b783139

37 files changed

+903
-703
lines changed

src/Prodigy.Solutions.Deribit.Client/AccountManagement/AccountSummaryResponse.cs

Lines changed: 75 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,87 @@ namespace Prodigy.Solutions.Deribit.Client.AccountManagement;
44

55
public class AccountSummaryResponse
66
{
7-
[JsonProperty("delta_total_map")]
8-
public IReadOnlyDictionary<string, decimal>? DeltaTotalMap { get; set; }
9-
[JsonProperty("margin_balance")]
10-
public decimal? MarginBalance { get; set; }
11-
[JsonProperty("futures_session_rpl")]
12-
public decimal? FuturesSessionRpl { get; set; }
13-
[JsonProperty("options_session_rpl")]
14-
public int? OptionsSessionRpl { get; set; }
7+
[JsonProperty("delta_total_map")] public IReadOnlyDictionary<string, decimal>? DeltaTotalMap { get; set; }
8+
9+
[JsonProperty("margin_balance")] public decimal? MarginBalance { get; set; }
10+
11+
[JsonProperty("futures_session_rpl")] public decimal? FuturesSessionRpl { get; set; }
12+
13+
[JsonProperty("options_session_rpl")] public int? OptionsSessionRpl { get; set; }
1514

1615
[JsonProperty("estimated_liquidation_ratio_map")]
1716
public IReadOnlyDictionary<string, decimal>? EstimatedLiquidationRatioMap { get; set; }
1817

19-
[JsonProperty("session_upl")]
20-
public decimal? SessionUpl { get; set; }
21-
[JsonProperty("email")]
22-
public string? Email { get; set; }
23-
[JsonProperty("system_name")]
24-
public string? SystemName { get; set; }
25-
[JsonProperty("username")]
26-
public string? Username { get; set; }
18+
[JsonProperty("session_upl")] public decimal? SessionUpl { get; set; }
19+
20+
[JsonProperty("email")] public string? Email { get; set; }
21+
22+
[JsonProperty("system_name")] public string? SystemName { get; set; }
23+
24+
[JsonProperty("username")] public string? Username { get; set; }
2725

2826
[JsonProperty("interuser_transfers_enabled")]
2927
public bool? InteruserTransfersEnabled { get; set; }
3028

31-
[JsonProperty("id")]
32-
public int Id { get; set; }
29+
[JsonProperty("id")] public int Id { get; set; }
3330

3431
[JsonProperty("estimated_liquidation_ratio")]
3532
public decimal? EstimatedLiquidationRatio { get; set; }
3633

37-
[JsonProperty("options_gamma_map")]
38-
public IReadOnlyDictionary<string, decimal>? OptionsGammaMap { get; set; }
39-
[JsonProperty("options_vega")]
40-
public decimal? OptionsVega { get; set; }
41-
[JsonProperty("options_value")]
42-
public decimal? OptionsValue { get; set; }
34+
[JsonProperty("options_gamma_map")] public IReadOnlyDictionary<string, decimal>? OptionsGammaMap { get; set; }
35+
36+
[JsonProperty("options_vega")] public decimal? OptionsVega { get; set; }
37+
38+
[JsonProperty("options_value")] public decimal? OptionsValue { get; set; }
4339

4440
[JsonProperty("available_withdrawal_funds")]
4541
public decimal? AvailableWithdrawalFunds { get; set; }
4642

4743
[JsonProperty("projected_delta_total")]
4844
public decimal? ProjectedDeltaTotal { get; set; }
4945

50-
[JsonProperty("maintenance_margin")]
51-
public decimal? MaintenanceMargin { get; set; }
52-
[JsonProperty("total_pl")]
53-
public decimal? TotalPl { get; set; }
54-
[JsonProperty("limits")]
55-
public LimitsInfo? Limits { get; set; }
56-
[JsonProperty("options_theta_map")]
57-
public IReadOnlyDictionary<string, decimal>? OptionsThetaMap { get; set; }
46+
[JsonProperty("maintenance_margin")] public decimal? MaintenanceMargin { get; set; }
47+
48+
[JsonProperty("total_pl")] public decimal? TotalPl { get; set; }
49+
50+
[JsonProperty("limits")] public LimitsInfo? Limits { get; set; }
51+
52+
[JsonProperty("options_theta_map")] public IReadOnlyDictionary<string, decimal>? OptionsThetaMap { get; set; }
5853

5954
[JsonProperty("projected_maintenance_margin")]
6055
public decimal? ProjectedMaintenanceMargin { get; set; }
6156

62-
[JsonProperty("available_funds")]
63-
public decimal? AvailableFunds { get; set; }
64-
[JsonProperty("login_enabled")]
65-
public bool? LoginEnabled { get; set; }
66-
[JsonProperty("options_delta")]
67-
public decimal? OptionsDelta { get; set; }
68-
[JsonProperty("balance")]
69-
public decimal? Balance { get; set; }
57+
[JsonProperty("available_funds")] public decimal? AvailableFunds { get; set; }
58+
59+
[JsonProperty("login_enabled")] public bool? LoginEnabled { get; set; }
60+
61+
[JsonProperty("options_delta")] public decimal? OptionsDelta { get; set; }
62+
63+
[JsonProperty("balance")] public decimal? Balance { get; set; }
7064

7165
[JsonProperty("security_keys_enabled")]
7266
public bool? SecurityKeysEnabled { get; set; }
7367

74-
[JsonProperty("referrer_id")]
75-
public object ReferrerId { get; set; }
76-
[JsonProperty("mmp_enabled")]
77-
public bool? MmpEnabled { get; set; }
78-
[JsonProperty("equity")]
79-
public decimal? Equity { get; set; }
80-
[JsonProperty("futures_session_upl")]
81-
public decimal? FuturesSessionUpl { get; set; }
82-
[JsonProperty("fee_balance")]
83-
public int? FeeBalance { get; set; }
84-
[JsonProperty("currency")]
85-
public string? Currency { get; set; }
86-
[JsonProperty("options_session_upl")]
87-
public decimal? OptionsSessionUpl { get; set; }
68+
[JsonProperty("referrer_id")] public object ReferrerId { get; set; }
69+
70+
[JsonProperty("mmp_enabled")] public bool? MmpEnabled { get; set; }
71+
72+
[JsonProperty("equity")] public decimal? Equity { get; set; }
73+
74+
[JsonProperty("futures_session_upl")] public decimal? FuturesSessionUpl { get; set; }
75+
76+
[JsonProperty("fee_balance")] public int? FeeBalance { get; set; }
77+
78+
[JsonProperty("currency")] public string? Currency { get; set; }
79+
80+
[JsonProperty("options_session_upl")] public decimal? OptionsSessionUpl { get; set; }
8881

8982
[JsonProperty("projected_initial_margin")]
9083
public decimal? ProjectedInitialMargin { get; set; }
9184

92-
[JsonProperty("options_theta")]
93-
public decimal? OptionsTheta { get; set; }
94-
[JsonProperty("creation_timestamp")]
95-
public long CreationTimestamp { get; set; }
85+
[JsonProperty("options_theta")] public decimal? OptionsTheta { get; set; }
86+
87+
[JsonProperty("creation_timestamp")] public long CreationTimestamp { get; set; }
9688

9789
[JsonProperty("self_trading_extended_to_subaccounts")]
9890
public bool? SelfTradingExtendedToSubaccounts { get; set; }
@@ -103,54 +95,48 @@ public class AccountSummaryResponse
10395
[JsonProperty("cross_collateral_enabled")]
10496
public bool? CrossCollateralEnabled { get; set; }
10597

106-
[JsonProperty("margin_model")]
107-
public string? MarginModel { get; set; }
98+
[JsonProperty("margin_model")] public string? MarginModel { get; set; }
10899

109100
[JsonProperty("decimal?> options_vega_map")]
110101
public IReadOnlyDictionary<string, decimal>? OptionsVegaMap { get; set; }
111102

112-
[JsonProperty("futures_pl")]
113-
public decimal? FuturesPl { get; set; }
114-
[JsonProperty("options_pl")]
115-
public decimal? OptionsPl { get; set; }
116-
[JsonProperty("type")]
117-
public string? Type { get; set; }
103+
[JsonProperty("futures_pl")] public decimal? FuturesPl { get; set; }
104+
105+
[JsonProperty("options_pl")] public decimal? OptionsPl { get; set; }
106+
107+
[JsonProperty("type")] public string? Type { get; set; }
118108

119109
[JsonProperty("self_trading_reject_mode")]
120110
public string? SelfTradingRejectMode { get; set; }
121111

122-
[JsonProperty("initial_margin")]
123-
public decimal? InitialMargin { get; set; }
124-
[JsonProperty("spot_reserve")]
125-
public int? SpotReserve { get; set; }
126-
[JsonProperty("delta_total")]
127-
public decimal? DeltaTotal { get; set; }
128-
[JsonProperty("options_gamma")]
129-
public decimal? OptionsGamma { get; set; }
130-
[JsonProperty("session_rpl")]
131-
public decimal? SessionRpl { get; set; }
112+
[JsonProperty("initial_margin")] public decimal? InitialMargin { get; set; }
113+
114+
[JsonProperty("spot_reserve")] public int? SpotReserve { get; set; }
115+
116+
[JsonProperty("delta_total")] public decimal? DeltaTotal { get; set; }
117+
118+
[JsonProperty("options_gamma")] public decimal? OptionsGamma { get; set; }
119+
120+
[JsonProperty("session_rpl")] public decimal? SessionRpl { get; set; }
132121

133122
public class LimitsInfo
134123
{
135-
[JsonProperty("non_matching_engine")]
136-
public NonMatchingEngine? NonMatchingEngine { get; set; }
137-
[JsonProperty("matching_engine")]
138-
public MatchingEngine? MatchingEngine { get; set; }
124+
[JsonProperty("non_matching_engine")] public NonMatchingEngine? NonMatchingEngine { get; set; }
125+
126+
[JsonProperty("matching_engine")] public MatchingEngine? MatchingEngine { get; set; }
139127
}
140128

141129
public class NonMatchingEngine
142130
{
143-
[JsonProperty("rate")]
144-
public int? Rate { get; set; }
145-
[JsonProperty("burst")]
146-
public int? Burst { get; set; }
131+
[JsonProperty("rate")] public int? Rate { get; set; }
132+
133+
[JsonProperty("burst")] public int? Burst { get; set; }
147134
}
148135

149136
public class MatchingEngine
150137
{
151-
[JsonProperty("rate")]
152-
public int? Rate { get; set; }
153-
[JsonProperty("burst")]
154-
public int? Burst { get; set; }
138+
[JsonProperty("rate")] public int? Rate { get; set; }
139+
140+
[JsonProperty("burst")] public int? Burst { get; set; }
155141
}
156-
}
142+
}
Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Prodigy.Solutions.Deribit.Client.Authentication;
1+
using System.Dynamic;
2+
using Prodigy.Solutions.Deribit.Client.Authentication;
23
using Prodigy.Solutions.Deribit.Client.MarketData;
34

45
namespace Prodigy.Solutions.Deribit.Client.AccountManagement;
@@ -14,86 +15,82 @@ public DeribitAccountManagementClient(DeribitJsonRpcClient deribitClient, Deribi
1415
_session = session;
1516
}
1617

17-
public Task<AccountSummaryResponse> GetAccountSummaryAsync(string currency, int? subAccountId = null, bool? extended = null)
18+
public Task<AccountSummaryResponse> GetAccountSummaryAsync(string currency, int? subAccountId = null,
19+
bool? extended = null)
1820
{
19-
dynamic requestObject = new System.Dynamic.ExpandoObject();
21+
dynamic requestObject = new ExpandoObject();
2022
requestObject.currency = currency;
21-
22-
if (subAccountId.HasValue)
23-
{
24-
requestObject.subaccount_id = subAccountId.Value;
25-
}
2623

27-
if (extended.HasValue)
28-
{
29-
requestObject.extended = extended.Value;
30-
}
24+
if (subAccountId.HasValue) requestObject.subaccount_id = subAccountId.Value;
25+
26+
if (extended.HasValue) requestObject.extended = extended.Value;
3127

3228
return _deribitClient.InvokeAsync<AccountSummaryResponse>("private/get_account_summary", requestObject);
3329
}
3430

35-
public Task<IReadOnlyCollection<PositionResult>?> GetPositionsAsync(CurrencyKind currency, InstrumentKind? kind = null, int? subaccountId = null)
31+
public Task<IReadOnlyCollection<PositionResult>?> GetPositionsAsync(CurrencyKind currency,
32+
InstrumentKind? kind = null, int? subaccountId = null)
3633
{
37-
dynamic requestObject = new System.Dynamic.ExpandoObject();
34+
dynamic requestObject = new ExpandoObject();
3835
requestObject.currency = currency;
39-
36+
4037
if (kind.HasValue) requestObject.kind = kind.Value;
4138
if (subaccountId.HasValue) requestObject.subaccount_id = subaccountId.Value;
42-
39+
4340
return _deribitClient.InvokeAsync<IReadOnlyCollection<PositionResult>>("private/get_positions", requestObject);
4441
}
4542
}
4643

4744
public class PositionResult
4845
{
4946
public decimal AveragePrice { get; init; }
50-
47+
5148
public decimal? AveragePriceUsd { get; init; }
52-
49+
5350
public decimal Delta { get; init; }
54-
51+
5552
public PositionDirection Direction { get; init; }
56-
53+
5754
public decimal? EstimatedLiquidationPrice { get; init; }
58-
55+
5956
public decimal FloatingProfitLoss { get; init; }
60-
57+
6158
public decimal FloatingProfitLossUsd { get; init; }
62-
59+
6360
public decimal? Gamma { get; init; }
64-
61+
6562
public decimal IndexPrice { get; init; }
66-
63+
6764
public decimal InitialMargin { get; init; }
68-
65+
6966
public required string InstrumentName { get; init; }
70-
67+
7168
public decimal? InterestValue { get; init; }
72-
69+
7370
public InstrumentKind Kind { get; init; }
74-
71+
7572
public decimal Leverage { get; init; }
76-
73+
7774
public decimal MaintenanceMargin { get; init; }
78-
75+
7976
public decimal MarkPrice { get; init; }
80-
77+
8178
public decimal OpenOrdersMargin { get; init; }
82-
79+
8380
public decimal? RealizedFunding { get; init; }
84-
81+
8582
public decimal RealizedProfitLoss { get; init; }
86-
83+
8784
public decimal? SettlementPrice { get; init; }
88-
85+
8986
public decimal Size { get; init; }
90-
87+
9188
public decimal SizeCurrency { get; init; }
92-
89+
9390
public decimal? Theta { get; init; }
94-
91+
9592
public decimal TotalProfitLoss { get; init; }
96-
93+
9794
public decimal? Vega { get; init; }
9895
}
9996

@@ -102,4 +99,4 @@ public enum PositionDirection
10299
Zero,
103100
Buy,
104101
Sell
105-
}
102+
}

src/Prodigy.Solutions.Deribit.Client/Authentication/AuthRequest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
public class AuthRequest
44
{
55
public required AuthRequestGrantType GrantType { get; init; }
6-
6+
77
public string? RefreshToken { get; init; }
8-
8+
99
public string? SignatureData { get; init; }
10-
10+
1111
public string? State { get; init; }
12-
12+
1313
public string? Scope { get; init; }
1414
}

0 commit comments

Comments
 (0)