1、暂存
This commit is contained in:
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
DbModels "go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/const/rediskey"
|
||||
"go-admin/common/global"
|
||||
"go-admin/common/helper"
|
||||
"go-admin/models"
|
||||
@ -13,6 +12,7 @@ import (
|
||||
"go-admin/models/futuresdto"
|
||||
"go-admin/pkg/httputils"
|
||||
"go-admin/pkg/utility"
|
||||
"go-admin/services/cacheservice"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -261,18 +261,18 @@ func GetAndReloadSymbols(data *map[string]models.TradeSet) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e FutRestApi) Ticker() {
|
||||
url := fmt.Sprintf("%s%s", futureApi, "/fapi/v1/ticker/price")
|
||||
mapData, err := httputils.NewHttpRequestWithFasthttp("GET", url, "", map[string]string{})
|
||||
if err != nil {
|
||||
log.Error("获取合约交易对行情失败:err:", err)
|
||||
}
|
||||
// func (e FutRestApi) Ticker() {
|
||||
// url := fmt.Sprintf("%s%s", futureApi, "/fapi/v1/ticker/price")
|
||||
// mapData, err := httputils.NewHttpRequestWithFasthttp("GET", url, "", map[string]string{})
|
||||
// if err != nil {
|
||||
// log.Error("获取合约交易对行情失败:err:", err)
|
||||
// }
|
||||
|
||||
if len(mapData) == 0 {
|
||||
log.Error("获取合约交易对行情失败,或数量为空")
|
||||
}
|
||||
helper.DefaultRedis.SetString(rediskey.FutSymbolTicker, string(mapData))
|
||||
}
|
||||
// if len(mapData) == 0 {
|
||||
// log.Error("获取合约交易对行情失败,或数量为空")
|
||||
// }
|
||||
// helper.DefaultRedis.SetString(rediskey.FutSymbolTicker, string(mapData))
|
||||
// }
|
||||
|
||||
// 获取合约行情
|
||||
func GetTicker24h() ([]futuresdto.FutureTicker24h, error) {
|
||||
@ -862,9 +862,10 @@ func (e FutRestApi) CancelBatchFutOrder(apiUserInfo DbModels.LineApiUser, symbol
|
||||
// quoteSymbol 计价货币 ETHBTC -> 计价货币就是BTC
|
||||
// totalMoney 兑换的总金额
|
||||
func (e FutRestApi) CalcSymbolExchangeAmt(symbol string, quoteSymbol string, totalMoney decimal.Decimal) decimal.Decimal {
|
||||
tickerSymbol := helper.DefaultRedis.Get(rediskey.FutSymbolTicker).Val()
|
||||
tickerSymbolMaps := make([]dto.Ticker, 0)
|
||||
sonic.Unmarshal([]byte(tickerSymbol), &tickerSymbolMaps)
|
||||
// tickerSymbol := helper.DefaultRedis.Get(rediskey.FutSymbolTicker).Val()
|
||||
// tickerSymbolMaps := make([]dto.Ticker, 0)
|
||||
// sonic.Unmarshal([]byte(tickerSymbol), &tickerSymbolMaps)
|
||||
tickerSymbolMaps, _ := cacheservice.GetExchangeTradeSets(global.EXCHANGE_BINANCE, 1)
|
||||
|
||||
targetSymbol := strings.Replace(symbol, quoteSymbol, "USDT", 1) //ETHBTC -》 ETHUSDT
|
||||
key := fmt.Sprintf("%s:%s", global.TICKER_FUTURES, targetSymbol)
|
||||
@ -873,7 +874,7 @@ func (e FutRestApi) CalcSymbolExchangeAmt(symbol string, quoteSymbol string, tot
|
||||
quantity := decimal.Zero
|
||||
for _, symbolMap := range tickerSymbolMaps {
|
||||
if symbolMap.Symbol == strings.ToUpper(targetSymbol) {
|
||||
targetPrice, _ = decimal.NewFromString(symbolMap.Price)
|
||||
targetPrice, _ = decimal.NewFromString(symbolMap.LastPrice)
|
||||
quantity = totalMoney.Div(targetPrice).Truncate(int32(tradeSet.AmountDigit))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user