Comments (5)
I'm planning to work on this; can you clarify how the double-quoted formatting ties into the case change?
from kelp.
@Reidmcc thanks for taking this on.
You would need to use the toml
tag with the ALL_CAPS version of the field name, like so:
tradingSecretSeed string `toml:"TRADING_SECRET_SEED"`
(see the examples section of the BurntSushi/toml parser)
You can keep the existing valid
tag for now and add the second toml
tag using a space to separate them. Here's an example
from kelp.
This doesn't seem to work; the executable builds but throws a Unknown fields error when attempting to parse the strategy config. If you leave one of the fields as ALL_CAPS that fields parses but the changed fields do not. For example, if the struct is:
type balancedConfig struct {
PRICE_TOLERANCE float64 `valid:"-" toml:"PRICE_TOLERANCE"`
amountTolerance float64 `valid:"-" toml:"AMOUNT_TOLERANCE"`
spread float64 `valid:"-" toml:"SPREAD"`
minAmountSpread float64 `valid:"-" toml:"MIN_AMOUNT_SPREAD"`
maxAmountSpread float64 `valid:"-" toml:"MAX_AMOUNT_SPREAD"`
maxLevels int16 `valid:"-" toml:"MAX_LEVELS"`
levelDensity float64 `valid:"-" toml:"LEVEL_DENSITY"`
ensureFirstNLevels int16 `valid:"-" toml:"ENSURE_FIRST_N_LEVELS"`
minAmountCarryoverSpread float64 `valid:"-" toml:"MIN_AMOUNT_CARRYOVER_SPREAD"`
maxAmountCarryoverSpread float64 `valid:"-" toml:"MAX_AMOUNT_CARRYOVER_SPREAD"`
carryoverInclusionProbability float64 `valid:"-" toml:"CARRYOVER_INCLUSION_PROBABILITY"`
virtualBalanceBase float64 `valid:"-" toml:"VIRTUAL_BALANCE_BASE"`
virtualBalanceQuote float64 `valid:"-" toml:"VIRTUAL_BALANCE_QUOTE"`
}
The error comes back with everything except PRICE_TOLERANCE as unknown:
Am I missing something?
from kelp.
@Reidmcc the field name inside the struct needs to be exported. i.e. TradingSecretSeed
instead of tradingSecretSeed
. My bad on the above example that used a unexported struct variable.
You'll need to fix the StructString()
function in support/utils/configs.go
to use the correct display name for the config so they are displayed with the ALL_CAPS version of the toml string.
Additionally, we should keep the transformations intact. Currently the transforms
map takes in values based on the field name. This is used to convert secret keys to public keys for display. We need to update the StructString()
method to map this based on the config ALL_CAPS name.
To sum up these changes we should introduce a new variable fieldDisplayName
in StructString()
, line 29-48 in support/utils/configs.go
should be something like this:
for i := 0; i < numFields; i++ {
field := reflect.TypeOf(s).Field(i)
fieldName := field.Name
fieldDisplayName := field.Tag.Get("toml")
if fieldDisplayName == "" {
fieldDisplayName = fieldName
}
// set the transformation function
transformFn := passthrough
if fn, ok := transforms[fieldDisplayName]; ok {
transformFn = fn
}
if reflect.ValueOf(s).Field(i).CanInterface() {
value := reflect.ValueOf(s).Field(i).Interface()
transformedValue := transformFn(value)
buf.WriteString(fmt.Sprintf("%s: %+v\n", fieldDisplayName, transformedValue))
}
}
from kelp.
I didn't see the full text of this message separately from the PR message. I'll finish the rest of this soon.
from kelp.
Related Issues (20)
- Fill Tracker cannot unmarshal string into Go struct field Price._embedded.records.price.n of type int32 HOT 16
- newest GUI only support one tradetype "buysell"? how to convert to others tradetype?
- command-line run sample_pendulum.cfg prompt error
- GUI problem with checked the "Fill Tracter" on,the bot can not be start
- KELP is crashing after network upgrade HOT 1
- Critical BUG ⚠️ HOT 2
- kelp crashes after protocol update 18 HOT 2
- Not working after the P18 upgrade?
- Provide option to not build the GUI HOT 2
- no such file or directory libsodium.so.23
- linux-ia32-83_binding.node HTTP error 404 Not Found
- Private Stellar Network
- Add arm64 architecture to darwin platform
- Is there a guide on how to start the program? A video would be ideal!
- Coinmarketcap isn't working anymore for Kelp HOT 1
- OKX (OkeX): Integrate via API, Commissions up tp 60%?
- adjusting order size
- Infinite loop when encounters a trade that is different from base/quote asset HOT 5
- Add a bias to the weighting of buysell orders
- How to run on iPad⁉️
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kelp.