Merge branch 'main' into chore/remove-eth-special-case
This commit is contained in:
@@ -13,15 +13,19 @@ func GetTopPrices() ([]string, []float64, []float64) {
|
||||
topPrice := make([]float64, n)
|
||||
topRate := make([]float64, n)
|
||||
|
||||
all, err := data.Market.GetAllPremiumIndex()
|
||||
if err != nil {
|
||||
return topSym, topPrice, topRate
|
||||
}
|
||||
|
||||
for i, sym := range strategy.TopPriceSymbols {
|
||||
price, rate, _, ok := data.Market.GetFuturePrice(sym)
|
||||
p, ok := all[sym]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
topSym[i] = sym
|
||||
topPrice[i] = price
|
||||
topRate[i] = rate
|
||||
|
||||
topPrice[i] = p.MarkPrice
|
||||
topRate[i] = p.FundingRate
|
||||
}
|
||||
return topSym, topPrice, topRate
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ var commandList = []telebot.Command{
|
||||
Text: "fee",
|
||||
Description: "(f) - show top funding fee",
|
||||
},
|
||||
{
|
||||
Text: "refresh",
|
||||
Description: "Refresh trading pair cache",
|
||||
},
|
||||
}
|
||||
|
||||
func setupCommands(b *telebot.Bot) error {
|
||||
@@ -36,6 +40,7 @@ func setupCommands(b *telebot.Bot) error {
|
||||
//info
|
||||
b.Handle("/p", commands.OnGetTopPrices)
|
||||
b.Handle("/fee", commands.OnGetTopFundingFee)
|
||||
b.Handle("/refresh", commands.OnRefreshPairCache)
|
||||
|
||||
//any text
|
||||
b.Handle(telebot.OnText, commands.OnChatHandler)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"gopkg.in/telebot.v3"
|
||||
"me.thuanle/bbot/internal/configs/key"
|
||||
"me.thuanle/bbot/internal/data"
|
||||
"me.thuanle/bbot/internal/services/controllers"
|
||||
"me.thuanle/bbot/internal/services/tele/chat"
|
||||
"me.thuanle/bbot/internal/services/tele/view"
|
||||
@@ -16,3 +21,14 @@ func OnGetTopFundingFee(context telebot.Context) error {
|
||||
fee, float64s, cds := controllers.GetTopFundingFee()
|
||||
return chat.ReplyMessagePre(context, view.RenderOnGetTopFundingFeeMessage(fee, float64s, cds))
|
||||
}
|
||||
|
||||
func OnRefreshPairCache(context telebot.Context) error {
|
||||
adminID, err := strconv.ParseInt(os.Getenv(key.AdminChatID), 10, 64)
|
||||
if err != nil || adminID == 0 || context.Sender().ID != adminID {
|
||||
return nil
|
||||
}
|
||||
if err := data.Market.RefreshTradingPairCache(); err != nil {
|
||||
return chat.ReplyMessage(context, "Failed to refresh trading pair cache")
|
||||
}
|
||||
return chat.ReplyMessage(context, "Trading pair cache refreshed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user