mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-16 12:03:51 +00:00
118 lines
3.5 KiB
Go
118 lines
3.5 KiB
Go
// Code generated by "enumer -type=BacktestFeeMode -transform=snake -trimprefix BacktestFeeMode -yaml -json"; DO NOT EDIT.
|
|
|
|
package bbgo
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const _BacktestFeeModeName = "quotenativetoken"
|
|
|
|
var _BacktestFeeModeIndex = [...]uint8{0, 5, 11, 16}
|
|
|
|
const _BacktestFeeModeLowerName = "quotenativetoken"
|
|
|
|
func (i BacktestFeeMode) String() string {
|
|
if i < 0 || i >= BacktestFeeMode(len(_BacktestFeeModeIndex)-1) {
|
|
return fmt.Sprintf("BacktestFeeMode(%d)", i)
|
|
}
|
|
return _BacktestFeeModeName[_BacktestFeeModeIndex[i]:_BacktestFeeModeIndex[i+1]]
|
|
}
|
|
|
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
// Re-run the stringer command to generate them again.
|
|
func _BacktestFeeModeNoOp() {
|
|
var x [1]struct{}
|
|
_ = x[BacktestFeeModeQuote-(0)]
|
|
_ = x[BacktestFeeModeNative-(1)]
|
|
_ = x[BacktestFeeModeToken-(2)]
|
|
}
|
|
|
|
var _BacktestFeeModeValues = []BacktestFeeMode{BacktestFeeModeQuote, BacktestFeeModeNative, BacktestFeeModeToken}
|
|
|
|
var _BacktestFeeModeNameToValueMap = map[string]BacktestFeeMode{
|
|
_BacktestFeeModeName[0:5]: BacktestFeeModeQuote,
|
|
_BacktestFeeModeLowerName[0:5]: BacktestFeeModeQuote,
|
|
_BacktestFeeModeName[5:11]: BacktestFeeModeNative,
|
|
_BacktestFeeModeLowerName[5:11]: BacktestFeeModeNative,
|
|
_BacktestFeeModeName[11:16]: BacktestFeeModeToken,
|
|
_BacktestFeeModeLowerName[11:16]: BacktestFeeModeToken,
|
|
}
|
|
|
|
var _BacktestFeeModeNames = []string{
|
|
_BacktestFeeModeName[0:5],
|
|
_BacktestFeeModeName[5:11],
|
|
_BacktestFeeModeName[11:16],
|
|
}
|
|
|
|
// BacktestFeeModeString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func BacktestFeeModeString(s string) (BacktestFeeMode, error) {
|
|
if val, ok := _BacktestFeeModeNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
|
|
if val, ok := _BacktestFeeModeNameToValueMap[strings.ToLower(s)]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to BacktestFeeMode values", s)
|
|
}
|
|
|
|
// BacktestFeeModeValues returns all values of the enum
|
|
func BacktestFeeModeValues() []BacktestFeeMode {
|
|
return _BacktestFeeModeValues
|
|
}
|
|
|
|
// BacktestFeeModeStrings returns a slice of all String values of the enum
|
|
func BacktestFeeModeStrings() []string {
|
|
strs := make([]string, len(_BacktestFeeModeNames))
|
|
copy(strs, _BacktestFeeModeNames)
|
|
return strs
|
|
}
|
|
|
|
// IsABacktestFeeMode returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i BacktestFeeMode) IsABacktestFeeMode() bool {
|
|
for _, v := range _BacktestFeeModeValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalJSON implements the json.Marshaler interface for BacktestFeeMode
|
|
func (i BacktestFeeMode) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(i.String())
|
|
}
|
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface for BacktestFeeMode
|
|
func (i *BacktestFeeMode) UnmarshalJSON(data []byte) error {
|
|
var s string
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
return fmt.Errorf("BacktestFeeMode should be a string, got %s", data)
|
|
}
|
|
|
|
var err error
|
|
*i, err = BacktestFeeModeString(s)
|
|
return err
|
|
}
|
|
|
|
// MarshalYAML implements a YAML Marshaler for BacktestFeeMode
|
|
func (i BacktestFeeMode) MarshalYAML() (interface{}, error) {
|
|
return i.String(), nil
|
|
}
|
|
|
|
// UnmarshalYAML implements a YAML Unmarshaler for BacktestFeeMode
|
|
func (i *BacktestFeeMode) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
var s string
|
|
if err := unmarshal(&s); err != nil {
|
|
return err
|
|
}
|
|
|
|
var err error
|
|
*i, err = BacktestFeeModeString(s)
|
|
return err
|
|
}
|