-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCryptoBalanceCalculator.cs
More file actions
234 lines (207 loc) · 5.41 KB
/
CryptoBalanceCalculator.cs
File metadata and controls
234 lines (207 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
using _003CPrivateImplementationDetails_003E_007B32439FAB_002DE055_002D4B6F_002D932A_002DAD6005671EA2_007D;
namespace TradingPlatform.BusinessLayer;
public abstract class CryptoBalanceCalculator : BasicBalanceCalculator
{
private SettingItemDoubleWithLink 놰뇇;
private SettingItemSlider 놰놛;
protected override void PopulateAction(SettingItem[] orderSettings, OrderRequestParameters requestParameters)
{
RequestParameters = requestParameters;
if (놰뇇 != null)
{
놰뇇.LinkAction = null;
}
놰뇇 = orderSettings?.GetItemByName(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놜()) as SettingItemDoubleWithLink;
놰놛 = orderSettings?.GetItemByName(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놨()) as SettingItemSlider;
if (놰뇇 != null)
{
놰뇇.LinkAction = OnLinkAction;
PopulateTotal();
}
base.PopulateAction(orderSettings, requestParameters);
}
protected override void OnOrderSettingChanged(string settingName)
{
if (!(settingName == _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.뇋뇊()))
{
if (!(settingName == _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놜()))
{
if (settingName == _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놨())
{
base.QuantityDefiningSettingName = settingName;
OnPercentChanged();
}
}
else
{
base.QuantityDefiningSettingName = settingName;
OnTotalChanged();
}
}
else
{
OnSideChanged();
}
base.OnOrderSettingChanged(settingName);
}
protected override void RecalculateAction(string processingSettingName)
{
if (!(processingSettingName == _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놜()))
{
if (processingSettingName == _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놨())
{
OnPercentChanged();
}
else
{
base.RecalculateAction(processingSettingName);
}
}
else
{
OnTotalChanged();
}
}
protected override void DisposeAction()
{
놰뇇 = null;
놰놛 = null;
base.DisposeAction();
}
protected virtual double CalculateQuantity(double total, double fillPrice)
{
return (double)((decimal)total / (decimal)fillPrice);
}
protected virtual double CalculateTotal(double quantity, double fillPrice)
{
return (double)((decimal)fillPrice * (decimal)quantity);
}
protected virtual string GetTotalLinkText()
{
return _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.뇅();
}
protected virtual ulong CalculateSliderStep()
{
return 0uL;
}
protected override void OnQuantityChanged()
{
base.OnQuantityChanged();
if (QuantityItem != null)
{
UpdateTotal(GetQuantity());
UpdateSlider();
}
}
protected override void OnRiskChanged()
{
base.OnRiskChanged();
if (QuantityItem != null)
{
UpdateTotal(GetQuantity());
UpdateSlider();
}
}
protected override void OnRiskPercentChanged()
{
base.OnRiskPercentChanged();
if (QuantityItem != null)
{
UpdateTotal(GetQuantity());
UpdateSlider();
}
}
protected virtual void OnSideChanged()
{
}
protected virtual void OnTotalChanged()
{
if (놰뇇 != null)
{
UpdateQuantity(GetTotal());
UpdateSlider();
UpdateRisk(GetQuantity());
UpdateRiskPercent(GetRisk());
}
}
protected abstract void OnLinkAction(object obj);
protected abstract void OnPercentChanged();
protected void UpdateQuantity(double? total)
{
if (total.HasValue && QuantityItem != null && base.CurrentFillPrice.HasValue)
{
double value = base.CurrentFillPrice.Value;
if (!value.IsNanOrDefault())
{
double value2 = CalculateQuantity(total.Value, value);
UpdateQuantity(value2, SettingItemValueChangingReason.Programmatically);
}
}
}
protected void UpdateTotal(double? quantity)
{
if (quantity.HasValue && 놰뇇 != null && base.CurrentFillPrice.HasValue)
{
double value = base.CurrentFillPrice.Value;
if (!double.IsNaN(value))
{
UpdateTotal(CalculateTotal(quantity.Value, value), SettingItemValueChangingReason.Programmatically);
}
}
}
protected void UpdateTotal(double? total, SettingItemValueChangingReason reason)
{
if (total.HasValue)
{
놰뇇.SetValueWithReason(total, reason);
}
}
protected void UpdateTotalLink()
{
if (놰뇇 != null)
{
놰뇇.LinkText = GetTotalLinkText();
}
}
protected void UpdateSlider()
{
if (놰놛 != null)
{
ulong num = CalculateSliderStep();
놰놛.SetValueWithReason(num, SettingItemValueChangingReason.Programmatically);
}
}
protected void PopulateTotal()
{
if (놰뇇 != null)
{
double num = 1.0;
int decimalPlaces = 0;
string dimension = string.Empty;
Asset totalAsset = GetTotalAsset();
if (totalAsset != null)
{
num = totalAsset.MinimumChange;
decimalPlaces = totalAsset.Precision;
dimension = totalAsset.Name;
}
놰뇇.Minimum = num;
놰뇇.Maximum = double.MaxValue;
놰뇇.Increment = num;
놰뇇.DecimalPlaces = decimalPlaces;
놰뇇.Dimension = dimension;
}
}
protected double? GetTotal()
{
return 놰뇇?.GetValue<double>();
}
protected double? GetSliderPercent()
{
return (double?)놰놛?.GetValue<ulong>() / 100.0;
}
protected virtual Asset GetTotalAsset()
{
return RequestParameters?.Symbol?.QuotingCurrency;
}
}