2023-08-09 07:20:33 +00:00
|
|
|
package bitget
|
|
|
|
|
2023-08-09 07:30:28 +00:00
|
|
|
import (
|
2023-10-31 03:56:15 +00:00
|
|
|
"math"
|
2023-08-09 07:30:28 +00:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/c9s/bbgo/pkg/exchange/bitget/bitgetapi"
|
|
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
|
|
)
|
2023-08-09 07:20:33 +00:00
|
|
|
|
|
|
|
func toGlobalSymbol(s string) string {
|
|
|
|
return strings.ToUpper(s)
|
|
|
|
}
|
2023-08-09 07:30:28 +00:00
|
|
|
|
|
|
|
func toGlobalBalance(asset bitgetapi.AccountAsset) types.Balance {
|
|
|
|
return types.Balance{
|
|
|
|
Currency: asset.CoinName,
|
|
|
|
Available: asset.Available,
|
|
|
|
Locked: asset.Lock.Add(asset.Frozen),
|
|
|
|
Borrowed: fixedpoint.Zero,
|
|
|
|
Interest: fixedpoint.Zero,
|
|
|
|
NetAsset: fixedpoint.Zero,
|
|
|
|
MaxWithdrawAmount: fixedpoint.Zero,
|
|
|
|
}
|
|
|
|
}
|
2023-10-31 03:56:15 +00:00
|
|
|
|
|
|
|
func toGlobalMarket(s bitgetapi.Symbol) types.Market {
|
|
|
|
if s.Status != bitgetapi.SymbolOnline {
|
|
|
|
log.Warnf("The symbol %s is not online", s.Symbol)
|
|
|
|
}
|
|
|
|
return types.Market{
|
|
|
|
Symbol: s.SymbolName,
|
|
|
|
LocalSymbol: s.Symbol,
|
|
|
|
PricePrecision: s.PriceScale.Int(),
|
|
|
|
VolumePrecision: s.QuantityScale.Int(),
|
|
|
|
QuoteCurrency: s.QuoteCoin,
|
|
|
|
BaseCurrency: s.BaseCoin,
|
|
|
|
MinNotional: s.MinTradeUSDT,
|
|
|
|
MinAmount: s.MinTradeUSDT,
|
|
|
|
MinQuantity: s.MinTradeAmount,
|
|
|
|
MaxQuantity: s.MaxTradeAmount,
|
|
|
|
StepSize: fixedpoint.NewFromFloat(1.0 / math.Pow10(s.QuantityScale.Int())),
|
|
|
|
TickSize: fixedpoint.NewFromFloat(1.0 / math.Pow10(s.PriceScale.Int())),
|
|
|
|
MinPrice: fixedpoint.Zero,
|
|
|
|
MaxPrice: fixedpoint.Zero,
|
|
|
|
}
|
|
|
|
}
|
2023-11-01 08:14:21 +00:00
|
|
|
|
|
|
|
func toGlobalTicker(ticker bitgetapi.Ticker) types.Ticker {
|
|
|
|
return types.Ticker{
|
|
|
|
Time: ticker.Ts.Time(),
|
|
|
|
Volume: ticker.BaseVol,
|
|
|
|
Last: ticker.Close,
|
|
|
|
Open: ticker.OpenUtc0,
|
|
|
|
High: ticker.High24H,
|
|
|
|
Low: ticker.Low24H,
|
|
|
|
Buy: ticker.BuyOne,
|
|
|
|
Sell: ticker.SellOne,
|
|
|
|
}
|
|
|
|
}
|