add margin
All checks were successful
Build Docker Image / build (amd64) (push) Successful in 1m47s

This commit is contained in:
thuanle
2024-10-24 10:58:32 +07:00
parent b60fcb842d
commit 94a11e8d68
10 changed files with 98 additions and 30 deletions

View File

@@ -35,19 +35,21 @@ func RenderPrice(price float64) string {
}
}
func RenderOnPriceMessage(symbol string, spotPrice float64, futurePrice float64, fundrate float64, fundtime int64) string {
func RenderOnPriceMessage(symbol string, spotPrice float64, futurePrice float64, fundrate float64, fundtime int64, marginRate float64) string {
return fmt.Sprintf(
"%s: %s\n"+
"Fund rate: %.4f%% %s in %s\n"+
"Spot: %s",
"Spot: %s\n"+
"Margin rate: %.3f%%",
RenderSymbolInfo(symbol), RenderPrice(futurePrice),
fundrate*100, IconOfFundingFeeDirection(fundrate), timex.CdMinuteStringTime(time.UnixMilli(fundtime)),
RenderPrice(spotPrice),
marginRate*365,
)
}
func RenderOnGetTopPricesMessage(symbols []string, price []float64, fundRate []float64) string {
t := helper.NewNoBorderTableWriter("", "Price", "Rate")
t := helper.NewNoBorderTableWriter("", "Price", "Fund")
mFmt := message.NewPrinter(language.AmericanEnglish)
for i, symbol := range symbols {
t.AppendRow(table.Row{

View File

@@ -7,5 +7,5 @@ import (
func RenderSymbolInfo(sym string) string {
token := binancex.Symbol2Token(sym)
return fmt.Sprintf("<a href=\"https://www.binance.com/futures/%s\">%s</a>", sym, token)
return fmt.Sprintf("#%s", token)
}