Skip to content

Commit

Permalink
fix: fixed funding rate listen
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZhengZhao committed Oct 15, 2024
1 parent 1ddf1fc commit f8259aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ bee pack -be GOOS=windows

### Change Log

## v0.0.19
- 修复资金费率的监控逻辑

## v0.0.18
- 首页调整
- 增加合约监听页面的 kc 通道图的查看
Expand Down
1 change: 0 additions & 1 deletion feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ func UpdateSymbolTradeInfo(symbols *models.Symbols) {
// 更新币种的资金费率信息
func UpdateSymbolsFundingRates() {
res, err := binance.GetFundingRate(binance.FundingRateParams{
StartTime: (time.Now().Unix() - 60 * 60 * 12) * 1000, // 12 个小时内的数据(正常8小时计算一次资金费率)
Limit: 1000,
})
if err == nil {
Expand Down
8 changes: 6 additions & 2 deletions feature/feature_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ func klineKcListen(coin models.ListenSymbols) {
}
}

// 监控资金费率
func ListenCoinFundingRate() {
o := orm.NewOrm()
var coins []models.SymbolFundingRates
o.QueryTable("symbol_funding_rates").OrderBy("ID").Filter("enable", 1).All(&coins) // 通知币列表
for _, coin := range coins {
if coin.Symbol != "CHZUSDT" {
continue
}
nowFundingRate, _ := strconv.ParseFloat(coin.NowFundingRate, 64)
lastNoticeFundingRate, _ := strconv.ParseFloat(coin.NowFundingRate, 64)
lastNoticeFundingRate, _ := strconv.ParseFloat(coin.LastNoticeFundingRate, 64)
diff := nowFundingRate - lastNoticeFundingRate
if (diff > 0.01 && nowFundingRate > 0.008) {
// 正资金费率,做空可以吃资金费用
Expand All @@ -165,7 +169,7 @@ func ListenCoinFundingRate() {

notify.ListenFutureCoinFundingRate(coin.Symbol, "做空吃资金费费率", nowFundingRate * 100, coin.NowPrice)
} else if (diff < -0.01 && nowFundingRate < -0.008) {
// 负资金费率,做多可以吃资金费用
// 负资金费率,小于 -1%, 做多可以吃资金费用
coin.LastNoticeFundingRate = coin.NowFundingRate
coin.LastNoticeFundingTime = coin.NowFundingTime
coin.LastNoticePrice = coin.NowPrice
Expand Down

0 comments on commit f8259aa

Please sign in to comment.