mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
30 lines
906 B
Go
30 lines
906 B
Go
package exchange
|
|
|
|
import "github.com/c9s/bbgo/pkg/types"
|
|
|
|
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
|
|
}
|