I'm using the config crate, which is great.
One of my config sections looks like this:
[strategy]
name = "mean-reversion"
symbols = ["SPY", "AAPL"]
I'd like to be able to support n strategies - something like:
[strategy-1]
name-1 = "mean-reversion"
symbols-1 = ["SPY", "AAPL"]
[strategy-2]
name-2 = "mean-reversion"
symbols-2 = ["SPY", "AAPL"]
I don't think the crate supports importing this into a data structure directly - I'd have to write custom code. Am I correct?
I think arrays of tables are a better solution here:
[[strategy]]
name = "mean-reversion"
symbols = ["SPY", "AAPL"]
[[strategy]]
name = "angry-regression"
symbols = ["EYE", "MSFT"]
4 Likes
I'll find out if the crate supports this.
Worked like a charm!
[[strategies]]
name = "mean-reversion"
symbols = ["SPY", "AAPL"]
[[strategies]]
name = "pairs"
symbols = []
...
Config:
Ok(AppConfig { strategies: [Strategy { name: "mean-reversion", symbols: ["SPY", "AAPL"] }, Strategy { name: "pairs", symbols: [] }] })
system
Closed
6
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.