MikaLendingBot icon indicating copy to clipboard operation
MikaLendingBot copied to clipboard

No partial coinconfigs allowed?

Open tisdall opened this issue 7 years ago • 9 comments

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.

tisdall avatar May 23 '17 15:05 tisdall

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.

tisdall avatar May 23 '17 15:05 tisdall

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.

laxdog avatar May 25 '17 06:05 laxdog

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.

Evanito avatar May 30 '17 01:05 Evanito

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 avatar May 30 '17 08:05 rnevet

@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.

tisdall avatar May 30 '17 12:05 tisdall

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.

rnevet avatar May 30 '17 13:05 rnevet

I thin I will look into it, seems pretty simple :)

mchl18 avatar Jul 26 '17 02:07 mchl18

something like this? screen shot 2017-07-26 at 05 16 26 screen shot 2017-07-26 at 05 16 46 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

mchl18 avatar Jul 26 '17 03:07 mchl18

@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?

mchl18 avatar Jul 26 '17 03:07 mchl18