Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by Zero #1

Closed
demon-ru opened this issue May 5, 2021 · 5 comments
Closed

Division by Zero #1

demon-ru opened this issue May 5, 2021 · 5 comments

Comments

@demon-ru
Copy link

demon-ru commented May 5, 2021

File "./main.py", line 245, in
my_positions = creating_positions_objects()
File "./main.py", line 73, in creating_positions_objects
percent_change = ((market_price / this_pos.average_position_price.value) * 100) - 100
decimal.InvalidOperation: [<class 'decimal.DivisionUndefined'>]

Похоже что пытается поделить на ноль. У меня есть акции VTRS, которые достались мне выделением от PFE по нулевой цене :)

@demon-ru
Copy link
Author

demon-ru commented May 5, 2021

Пока добавил проверку на 0 и... не придумал какой процент в этом случае ставить :)
Поставил 0%

@demon-ru
Copy link
Author

demon-ru commented May 5, 2021

И далее... вероятно, по этой же причине (по акции нет ни одной строки истории. Мне её "выделили", но я не покупал, не продавал).

Traceback (most recent call last):
File "./main.py", line 248, in
my_positions = creating_positions_objects()
File "./main.py", line 137, in creating_positions_objects
ave_buy_price_rub = calculate_ave_buy_price_rub()
File "./main.py", line 133, in calculate_ave_buy_price_rub
ave_buy_price_rub = sum(item_list) / len(item_list)
ZeroDivisionError: division by zero

@EgoPingvina
Copy link

EgoPingvina commented May 5, 2021

У меня тоже возник ZeroDivisionError: division by zero и экселька не появилась. Только не понимаю почему, упало на фонде FXIT по которому не может нулей нигде быть.

@Lowton
Copy link

Lowton commented May 6, 2021

К тому же в 130 строке main.py. Добавил бы проверку на 0.
ave_buy_price_rub = 0 if len(item_list) == 0 else sum(item_list) / len(item_list)

@samizdam
Copy link

samizdam commented May 6, 2021

К тому же в 130 строке main.py. Добавил бы проверку на 0.
ave_buy_price_rub = 0 if len(item_list) == 0 else sum(item_list) / len(item_list)

934e84a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants