nofx icon indicating copy to clipboard operation
nofx copied to clipboard

[BUG] 初始金额如果不填写币安余额,会引发统计错误

Open huangyongde opened this issue 1 year ago • 2 comments

当前初始金额如果不填写币安真实余额会引起统计错误,这样无法满足前期调试prompt,只愿意使用币安一部分金额的场景

Image

Image

huangyongde avatar Nov 06 '25 13:11 huangyongde

Product Decision Questions

This issue requires product design clarification. Current system assumes initial_balance = actual Binance account balance, which conflicts with the use case of "only allocating part of my funds to NoFx".

Current Behavior

  • initial_balance: User must input their EXACT Binance balance
  • P&L Calculation: (current_equity - initial_balance) / initial_balance * 100%
  • Problem: If user inputs 1000 USDT but actually has 10000 USDT in Binance, stats are wrong

Use Case Requirements

User wants to:

  • Have 10,000 USDT in Binance account
  • Only allocate 1,000 USDT for NoFx testing
  • See accurate P&L for the 1,000 USDT allocation

Solution Options

Option 1: Two-Balance System (Recommended)

Add new field: allocated_capital (separate from Binance total balance)

initial_balance: 10000,      // Actual Binance balance (for API validation)
allocated_capital: 1000,     // User's allocation to NoFx

P&L Formula: (current_equity - allocated_capital) / allocated_capital * 100%

Pros:

  • ✅ Accurate P&L for allocated capital
  • ✅ System knows real Binance balance (can show warnings if approaching limit)
  • ✅ Supports partial allocation use case

Cons:

  • Requires backend schema change
  • More complex UX

Option 2: Trade-Based P&L (No Initial Balance Required)

Remove initial_balance dependency, calculate P&L from trades only:

P&L = Σ(all closed position profits) + Σ(open position unrealized P&L)
ROI% = P&L / (total capital used in trades) * 100%

Pros:

  • ✅ Simple - no balance input needed
  • ✅ Works regardless of Binance account balance
  • ✅ Accurate for actual trading performance

Cons:

  • Cannot show "account equity curve" accurately
  • Requires tracking all historical trades

Option 3: Better UX Only (Keep Current Logic)

Keep current system, but improve UI/UX:

  • Add clear warning: "⚠️ Must match your actual Binance balance for accurate stats"
  • Show "Test Mode" checkbox that disables P&L tracking
  • Display disclaimer when initial_balance seems mismatched

Pros:

  • ✅ No backend changes
  • ✅ Quick to implement

Cons:

  • ❌ Doesn't solve the partial allocation use case

Option 4: Percentage-Based Allocation

User inputs:

  • binance_balance: 10000
  • allocation_percentage: 10%

System calculates: allocated = 10000 * 10% = 1000

Pros:

  • ✅ Clear mental model
  • ✅ Easy to adjust allocation

Cons:

  • What if user manually adds/removes funds from Binance?

Questions for Product Owner

  1. What is the priority use case?

    • [ ] Professional trading with full capital allocation
    • [ ] Testing/debugging prompts with partial allocation
    • [ ] Both equally important
  2. Should we track Binance account balance separately from NoFx allocation?

    • [ ] Yes (Option 1 - two-balance system)
    • [ ] No (Option 2 - trade-based P&L)
  3. Is it acceptable to require schema migration for this fix?

    • [ ] Yes, we can add new fields
    • [ ] No, prefer UI-only changes (Option 3)
  4. How should the system behave when user manually adds funds to Binance?

    • [ ] Auto-detect and ask user to update
    • [ ] User must manually update initial_balance
    • [ ] Ignore it, only track trades
  5. Timeline priority?

    • [ ] P0 - Blocking users from testing
    • [ ] P1 - Important but workaround exists (use exact balance)
    • [ ] P2 - Nice to have

Please clarify these questions so I can propose the appropriate technical solution.

the-dev-z avatar Nov 07 '25 01:11 the-dev-z

最新的测试环境中仍然未解决

huangyongde avatar Nov 13 '25 09:11 huangyongde