2022-07-14 09:36:16 +00:00
|
|
|
package exchange
|
|
|
|
|
2024-03-04 12:52:01 +00:00
|
|
|
import (
|
|
|
|
"github.com/c9s/bbgo/pkg/exchange/max"
|
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
|
|
)
|
2022-07-14 09:36:16 +00:00
|
|
|
|
|
|
|
func GetSessionAttributes(exchange types.Exchange) (isMargin, isFutures, isIsolated bool, isolatedSymbol string) {
|
|
|
|
if marginExchange, ok := exchange.(types.MarginExchange); ok {
|
|
|
|
marginSettings := marginExchange.GetMarginSettings()
|
|
|
|
isMargin = marginSettings.IsMargin
|
|
|
|
if isMargin {
|
|
|
|
isIsolated = marginSettings.IsIsolatedMargin
|
|
|
|
if marginSettings.IsIsolatedMargin {
|
|
|
|
isolatedSymbol = marginSettings.IsolatedMarginSymbol
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if futuresExchange, ok := exchange.(types.FuturesExchange); ok {
|
|
|
|
futuresSettings := futuresExchange.GetFuturesSettings()
|
|
|
|
isFutures = futuresSettings.IsFutures
|
|
|
|
if isFutures {
|
|
|
|
isIsolated = futuresSettings.IsIsolatedFutures
|
|
|
|
if futuresSettings.IsIsolatedFutures {
|
|
|
|
isolatedSymbol = futuresSettings.IsolatedFuturesSymbol
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return isMargin, isFutures, isIsolated, isolatedSymbol
|
|
|
|
}
|
2024-03-04 12:52:01 +00:00
|
|
|
|
|
|
|
func IsMaxExchange(exchange interface{}) bool {
|
|
|
|
_, res := exchange.(*max.Exchange)
|
|
|
|
return res
|
|
|
|
}
|