cb123 said:
Holy sheet buhlz.. I have no idea what I was smoking earlier (hurrying to finish typing and get on with a meeting maybe??)-- Kinda funny though.. So, assuming you didn't fully understand my casually insane post from earlier....
LOL actually, i got most of it... just wanted to give you a hard time
cb123 said:
No worries, everything is working. It's just another opportunity that I see to tighten up this code to produce even better results (mathematically and computationally) No need to over explain, we just get better results.
I came to this after admiring your new working code for a while and asking myself, "How could this be better?" as I do with every project I work on (you can imagine the hell I put my co-workers through, and how much the CEO likes my work

).
So, I figured out a simple way to reduce computational load, while improving the nature of the average calculation that is being done, basically there's just an overall better way to do this, while there is nothing wrong with the current setup. I just know from experience it's best to tighten up a project as much as possible before moving away from it.. Or something like that anyway.
well, load isnt much of an issue, as the contents of the fugly script are only meant to be ran once... at that point it will write the GPT to the database, and future updates will occur at the point of sale, not much overhead at all there.
cb123 said:
So, the optimized code looks like this (we've added the variable
count, it might not be needed because you might be able to easily tell the thing how many transaction pairs exist without counting like this):
codesnippet said:
gpt=0
count=0
startloop::
gpt = gpt ((totalvalue - cashinvested) / cashinvested)
count= count 1
endloop:
gpt=(gpt * 100)/count
The first part of this code resets variables (you might not need to do this)
The second part is the optimized loop (one calculation, no need for logic, and fewer calculations)
The third part is a conversion to get an average out of the variable gpt ...
------
yep, if we were doing it all every time, that would be cleaner...
now would be a good time to mention that this number will never be 100% accurate if we divide by two...
that assumes that you only bought once... however, the math looks at the average price per share over all purchases (ie: more shares became available, so i bought em)
we can bend the math in fugly and divide by that number if that makes sense (total buy transactions +1) ?
same for the first sale? it should be divided by something right?
cb123 said:
Easy enough right? And it will make your servers happy (and keep any real mathematicians that might stumble on this at least somewhat pleased that we arrived at a reasonably clean and nice final result, no worries though, I'm sure they will have laughed at us until they've cried long before this point in our conversation..

)
we are damn close... just need to hammer out the little details