Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calculation
#11
Are you talking about like simple interest or something?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#12
okay i got it,
i had a friend here helping me with the math..

so here's the final code:

end = float(input('please enter end price: '))
start = float(input('please enter start price: '))
years = float(input('please enter number of years: '))

avg_year = (end/start)**(1/years)

print(avg_year)

yea pyzyx3qwerty i meant the interest, in any case - we got it solved
Reply
#13
(May-12-2020, 07:22 AM)astral_travel Wrote: i trade stocks for a living, i've been trading for the last 19 years, since age 17,
you kidding me, right? No offense, but you don't know how to calculate annual return over multi-year holding period, yet you trade for a living? I don't know how you make basic investment decisions or how you assess the decisions already made... :-) Or what if the holding period is less than a year...

You are not there yet... you need to subtract 1.
with your example, your code will produce
Output:
please enter end price: 21.97 please enter start price: 10 please enter number of years: 3 1.3
how do you think, what exactly is 1.3? Hint: your annual return is 30%.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#14
well it doesn't matter much (1.3, 0.3 or 30%), as long as i understand what it means.

in anyway - i trade stocks, i don't invest (i hold positions for 2 days upto 2 weeks) so these kind of calculations aren't relevant to me so much (practically wise) - but it's interesting to see what kinda return different stocks made over the years, to see where i would land in relation to the investors...

trading isn't much about mathematics (as long as you are a discretionary trader) - of course that if you wanna write code to automate the process - then yes - there would be much math involved.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020