Norman's Note 諾曼筆記

Norman's Note 諾曼筆記

Go lang learning

func Sprintf

msg := fmt.Sprintf("not profitable: %s \n stop reason: %s\n", future.name, stopReason)
util.Info(fra.tag, msg)

func Repeat

  btxmPerp := "BTMX-PERP"

  getFundingRateOffset := int64(-1)
  perpOrderbook := fra.ftx.GetOrderbook(btxmPerp, 1)
  hedgeOrderbook := fra.ftx.GetOrderbook("BTMX/USD", 1)
  var perpPrice, hedgePrice float64
  perpPrice, _ = perpOrderbook.GetMarketBuyPrice()
  hedgePrice, _ = hedgeOrderbook.GetMarketSellPrice()
  fmt.Println(perpPrice, hedgePrice)

  spread := (perpPrice - hedgePrice) / hedgePrice * 100

  fmt.Printf("%.2f%%\n", spread)
  t := int(spread * 100)

  str := "+"
  if t < 0 {
    t = -t
    str = "-"
  }

  resp := fra.ftx.GetFutureStats(btxmPerp)
  nextFundingRate := resp.NextFundingRate

  fmt.Printf("%.2f%%\n", nextFundingRate*24*365*100)
  fmt.Println(strings.Repeat(str, t))

  if now%(60*60) == getFundingRateOffset && isTestEnv && false {

fmt.Printf

  • print format 的意思
  • % 功能和 regular expression 的 \ 類似

air

  • 像是 Node.js 的 nodemon 可以偵測改 code 自動重開 server