第十阶段 stage 1(二):永续合约单仓位、保证金金额一行、名义价值
This commit is contained in:
1 parent
ad60b07ca9
commit
f732304f38
11 files changed
+72
-57
No files matched your search
@@ -187,9 +187,9 @@ namespace Decentralized
|
||||
b.End();
|
||||
}
|
||||
|
||||
private static void AmountRow(CustomUIBuilder b)
|
||||
private static void AmountRow(CustomUIBuilder b, bool label = true)
|
||||
{
|
||||
b.AddLabel(L.T("trade.amount"));
|
||||
if (label) b.AddLabel(L.T("trade.amount"));
|
||||
b.BeginPanel(RightW - 30f, -1f, TextAnchor.MiddleCenter, 0f, 0f);
|
||||
_clear.Add(b.Last.image);
|
||||
b.AddInput("0", _amount, s => _amount = s, "amount", s => _amount = s);
|
||||
@@ -390,29 +390,34 @@ namespace Decentralized
|
||||
CandleChart.Add(l, "perp", _perpProduct);
|
||||
}, r =>
|
||||
{
|
||||
r.AddHeader(L.T("perp.open"));
|
||||
r.BeginRow(4f);
|
||||
foreach (var p in PerpBook.Products)
|
||||
var held = bk.Positions.Count > 0 ? bk.Positions[0] : null;
|
||||
if (held != null) { _perpProduct = held.Product; _perpLong = held.Long; _perpLev = Math.Max(1, (int)Math.Round(held.Leverage)); }
|
||||
r.AddHeader(L.T(held == null ? "perp.open" : "perp.col.pos"));
|
||||
if (held == null)
|
||||
{
|
||||
var product = p;
|
||||
PledgerSkin.Pick(r, product, product == _perpProduct, () => { _perpProduct = product; Open(); }, _picked);
|
||||
r.BeginRow(4f);
|
||||
foreach (var p in PerpBook.Products)
|
||||
{
|
||||
var product = p;
|
||||
PledgerSkin.Pick(r, product, product == _perpProduct, () => { _perpProduct = product; Open(); }, _picked);
|
||||
}
|
||||
r.End();
|
||||
r.BeginRow(4f);
|
||||
PledgerSkin.Pick(r, L.T("perp.long"), _perpLong, () => { _perpLong = true; Open(); }, _picked);
|
||||
PledgerSkin.Pick(r, L.T("perp.short"), !_perpLong, () => { _perpLong = false; Open(); }, _picked);
|
||||
r.End();
|
||||
r.BeginRow(4f);
|
||||
foreach (int lev in new[] { 1, 2, 3, 5 })
|
||||
{
|
||||
if (lev > PerpBook.MaxLeverage(_perpProduct)) continue;
|
||||
int lv = lev;
|
||||
PledgerSkin.Pick(r, lv + "×", lv == _perpLev, () => { _perpLev = lv; Open(); }, _picked);
|
||||
}
|
||||
r.End();
|
||||
}
|
||||
r.End();
|
||||
r.BeginRow(4f);
|
||||
PledgerSkin.Pick(r, L.T("perp.long"), _perpLong, () => { _perpLong = true; Open(); }, _picked);
|
||||
PledgerSkin.Pick(r, L.T("perp.short"), !_perpLong, () => { _perpLong = false; Open(); }, _picked);
|
||||
r.End();
|
||||
r.BeginRow(4f);
|
||||
foreach (int lev in new[] { 1, 2, 3, 5 })
|
||||
{
|
||||
if (lev > PerpBook.MaxLeverage(_perpProduct)) continue;
|
||||
int lv = lev;
|
||||
PledgerSkin.Pick(r, lv + "×", lv == _perpLev, () => { _perpLev = lv; Open(); }, _picked);
|
||||
}
|
||||
r.End();
|
||||
r.AddLabel(L.T("perp.margin"));
|
||||
AmountRow(r);
|
||||
if (double.TryParse((_amount ?? "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out double m) && m > 0)
|
||||
AmountRow(r, false);
|
||||
if (held == null && double.TryParse((_amount ?? "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out double m) && m > 0)
|
||||
{
|
||||
double notional = m * _perpLev, spot = PerpSpot(_perpProduct), exec = bk.Exec(spot, notional, _perpLong, day);
|
||||
var ghost = new PerpPosition { Long = _perpLong, Entry = exec, Size = notional / exec, Margin = m };
|
||||
@@ -420,9 +425,9 @@ namespace Decentralized
|
||||
r.AddLabel(L.T("perp.preview2", Fmt.Num(notional * Tuning.PerpFee), Fmt.Num(ghost.LiqPrice)), "perp_preview_dim");
|
||||
}
|
||||
r.BeginRow(6f);
|
||||
r.AddButton(L.T("perp.do.open"), PerpOpen);
|
||||
r.AddButton(L.T("perp.do.add"), PerpAdd);
|
||||
r.AddButton(L.T("perp.do.close"), PerpClose);
|
||||
if (held == null) r.AddButton(L.T("perp.do.open"), PerpOpen);
|
||||
else r.AddButton(L.T("perp.do.add"), PerpAdd);
|
||||
if (held != null) r.AddButton(L.T("perp.do.close"), PerpClose);
|
||||
r.End();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user