Terminal: buy-average price per coin in Poinbase and Web3; drop the price line on the Poinbase card
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9441d4d1bd
commit
a2dc1dd2f6
5 files changed
+48
-3
No files matched your search
@@ -248,6 +248,20 @@ internal static class Program
|
||||
Check(hi.Price <= 300 + 1e-9, $"上限 3 倍:{hi.Price:0.0}");
|
||||
});
|
||||
|
||||
Test("钱包:买入均价按买入记录算,卖出和转出按比例减少,挖出的币不计入", () =>
|
||||
{
|
||||
var w = new Wallet { Address = "x" };
|
||||
w.Add("PSC", 10); // 挖出的 10 个,无买入记录
|
||||
Check(w.AvgBuy("PSC") == null, "没有买入记录时没有均价");
|
||||
w.Add("PSC", 5); w.RecordBuy("PSC", 5, 400);
|
||||
w.Add("PSC", 5); w.RecordBuy("PSC", 5, 600);
|
||||
Check(Near(w.AvgBuy("PSC").Value, 100, 1e-9), "买 5 个花 400 + 买 5 个花 600:均价 100");
|
||||
w.Add("PSC", -10); // 卖掉一半(20 个里的 10 个)
|
||||
Check(Near(w.AvgBuy("PSC").Value, 100, 1e-9) && Near(w.BuyQty["PSC"], 5, 1e-9), "卖出后均价不变,买入记录按比例减少");
|
||||
w.Add("PSC", -10);
|
||||
Check(w.AvgBuy("PSC") == null, "清仓后记录清除");
|
||||
});
|
||||
|
||||
Test("市场:减半抬高价格锚(逐日靠拢),减半前一周有预期行情", () =>
|
||||
{
|
||||
Check(Near(Market.SupplyTarget(10, Tuning.BlockReward), 1.0, 1e-9), "减半前很远:目标因子 1");
|
||||
|
||||
Reference in new issue
Block a user