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