mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-18 01:44:38 +08:00
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:
35
provider/alpaca/kline_test.go
Normal file
35
provider/alpaca/kline_test.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user