pycryptobot icon indicating copy to clipboard operation
pycryptobot copied to clipboard

UnboundLocalError("local variable 'margin_text' referenced before assignment")

Open MadScrewdriver opened this issue 4 years ago • 2 comments

Screenshot from 2021-10-19 20-09-39 Varaible margin_text is not assigned but it is used sometimes.

Probably here: https://github.com/whittlem/pycryptobot/blob/main/pycryptobot.py#L1092 python goes in to elif before margin_text is assigned (before state.last_action == "BUY") throwing exception.

MadScrewdriver avatar Oct 19 '21 18:10 MadScrewdriver

Simply declaring default function-level variable margin_text will get rid of the issue.

MadScrewdriver avatar Oct 20 '21 06:10 MadScrewdriver

i have defined like this to solve this issue.

####Added Margin_text 1116 if state.last_buy_size > 0: 1117 margin_text = truncate(margin) + "%" 1118 else: 1119 margin_text = "0%"

esaravanakumar89 avatar Nov 20 '21 16:11 esaravanakumar89