feat: add xyz dex balance calculation, market data providers, and UI improvements

- Fix xyz dex balance calculation (use marginSummary for isolated margin)
- Add Alpaca provider for US stocks market data
- Add TwelveData provider for forex & metals market data
- Add Hyperliquid kline provider
- Centralize API keys in config system
- Add builder fee for order routing
- Improve chart UI with compact design
- Fix position history fee display precision
- Add comprehensive balance calculation tests
This commit is contained in:
tinkle-community
2025-12-29 22:16:48 +08:00
parent 4776fc37ce
commit 47bff87966
21 changed files with 3863 additions and 393 deletions

View File

@@ -0,0 +1,35 @@
package alpaca
import (
"context"
"fmt"
"testing"
)
func TestGetBars(t *testing.T) {
client := NewClient()
resp, err := client.GetBars(context.TODO(), "AAPL", "1Day", 5)
if err != nil {
t.Fatal(err)
}
t.Log("=== AAPL 日线数据 (Alpaca IEX feed) ===")
for i, bar := range resp {
t.Logf("\n[%d] 时间: %s", i, bar.Timestamp.Format("2006-01-02 15:04:05"))
t.Logf(" Open: %.2f", bar.Open)
t.Logf(" High: %.2f", bar.High)
t.Logf(" Low: %.2f", bar.Low)
t.Logf(" Close: %.2f", bar.Close)
t.Logf(" Volume: %d (股数)", bar.Volume)
t.Logf(" TradeCount: %d (成交笔数)", bar.TradeCount)
t.Logf(" VWAP: %.2f (成交量加权平均价)", bar.VWAP)
// 计算成交额
quoteVolume := float64(bar.Volume) * bar.Close
t.Logf(" 成交额: %.2f USD (Volume × Close)", quoteVolume)
}
fmt.Printf("\n⚠ 注意IEX feed 只包含 IEX 交易所的数据,不是完整市场数据\n")
fmt.Printf("完整市场数据需要使用 SIP feed付费\n")
}