MikaLendingBot
MikaLendingBot copied to clipboard
No partial coinconfigs allowed?
I wanted to just prevent a single coin from being lent so I added to the config the following:
[BTC]
maxactiveamount = 0
Instead of it just no longer loaning out BTC it gave me the error:
Coinconfig for BTC parsed incorrectly, please refer to the documentation. Error: No option 'mindailyrate' in section: 'BTC'
Traceback (most recent call last):
File "lendingbot.py", line 47, in <module>
MaxToLend.init(Config, log)
File "/sites/poloniexlendingbot/modules/MaxToLend.py", line 14, in init
coin_cfg = coin_cfg = config.get_coin_cfg()
File "/sites/poloniexlendingbot/modules/Configuration.py", line 82, in get_coin_cfg
coin_cfg[cur]['minrate'] = (Decimal(config.get(cur, 'mindailyrate'))) / 100
File "/usr/lib/python2.7/ConfigParser.py", line 618, in get
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'mindailyrate' in section: 'BTC'
I don't think the mindailyrate
is necessary if that coin is set to not be lent.
Okay, it seems like there's an expectation that every element is expected to be there. I think it should use the default value if the value is absent.
I thought of about that when doing it, but then I thought what if you do it by accident and have something in there you don't want, which could be much worse.
I think the current behaviour is how it should be.
Letting users only configure the per-coin settings they want to override and leaving the rest at default would probably be desireable (and apparently expected) behavior.
I disagree @Evanito , just for example if you make a typo in the per-coin settings, you will not know that if it defaults. However, I agree that disabling a coin should be possible without specifying all other params.
@rnevet , I haven't looked at the config code, but is it possible to throw an error if there's a configuration setting that's unrecognized to avoid the issue with a mistyped setting?
Incidentally, it seems all the settings are required except minloansize
. I'm assuming that one uses the default if it's not specified.
IMO it's better to require the user to enter all params so he's absolutely aware of the config he chose for the coin and not use fallbacks - the typo was just one more example. I don't think we should add extra code looking for config typos as it will be one more thing to maintain and the complexity of the config is already an annoyance when introducing new features.
minloansize has a more complex logic because different coins have different values enforced from Poloniex side, so it could be that it is provided if it isn't specified in config, I didn't look at that part of the code in a while. As this wasn't a subject before, this behavior wasn't really observed.
I thin I will look into it, seems pretty simple :)
something like this?
then I could exclude the currency and ignore the other fields, so they don't have to be commented out
I can make a PR tomorrow
@rnevet
I disagree @Evanito , just for example if you make a typo in the per-coin settings, you will not know that if it defaults.
you could just throw a WARN as in #429 #430 and then go to default?