UmbralRaptor changed the topic of #kspacademia to: https://gist.github.com/pdn4kd/164b9b85435d87afbec0c3a7e69d3e6d | Dogs are cats. Spiders are cat interferometers. | Космизм сегодня! | Document well, for tomorrow you may get mauled by a ネコバス. | <UmbralRaptor> egg|nomz|egg: generally if your eyes are dewing over, that's not the weather. | <ferram4> I shall beat my problems to death with an engineer. | We can haz pdf
<SnoopJeDi>
idk why but ゴールキーパー is a funny gairaigo to me
<SilverFox>
so my bot does stock stuff and Im looking at adding in the average effective price for a set stock figure, so if you buy 1 of a stock, its average is whatever that is, and then you can add to it as you go, how would I set the algorithm for that? Can you even algorithm that, and how would you do that if you sell a stock, thus removing one of the numbers, without having to keep a list of every single stock bought?
<SnoopJeDi>
SilverFox, that sounds like a moving average
<SilverFox>
moving average, thank you
<SilverFox>
the variables I have are: number of stocks owned, number to buy, current average, and price to buy at, is this enough for it?
<SilverFox>
im not the strongest at math yet so it's difficult for me to interpret some things
<SnoopJeDi>
the average after N data points: avgN = (p1 + p2 + ... + pN) / N; the average after N+1 data points, where the new price is P: avgP = (p1 + p2 + ... + pN + P) / (N+1) = (p1 + p2 + ... + pN) / (N+1) + P/(N+1) = avgN * N/(N+1) + P/(N+1)
<SnoopJeDi>
i.e. you grab the old terms and write them in terms of the average you already know, then add in the new info
<SilverFox>
thanks, hold up while I try to write this out so I actually understand its process
<SnoopJeDi>
I say it sounds like a moving average because that ^ calculation is for the all-time average, but you probably don't care about all of time, just some window into the past
<SilverFox>
I want all the numbers to be factored in
<SnoopJeDi>
oh okay
<SilverFox>
so if you bought like, 10 stocks, I want the average of those 10 stocks
<SilverFox>
it doesn't matter if they were from 10 years ago or yesterday
<SilverFox>
because the price you bought them at doesn't change
<SilverFox>
the average price is the average of the price you bought the stocks at
<SilverFox>
so if the stock price goes above that average, you are at profit, if it goes below, you are at loss
<SilverFox>
to make the stock buying/selling experience easier for the end user, rather than having to calculate it based on an infinitely long list of stocks and prices
<SilverFox>
so whatever it is that gets me that, I want it, and I need to understand and break it down so I can code it in
<UmbralRaptop>
I want to say that there's some formal term like cost basis or price basis
<SnoopJeDi>
probably both
<SnoopJeDi>
investopedia is useful
egg|laptop|egg has joined #kspacademia
<egg|laptop|egg>
!choose dichotomy|bisection
<galois>
egg|laptop|egg: Your options: dichotomy, bisection. My choice: bisection
<galois>
egg|laptop|egg: Your options: tetrachotomy, quadrisection. My choice: quadrisection
egg|laptop|egg has quit [Remote host closed the connection]
<e_14159>
SilverFox: That looks like it's achievable by simply storing the sum of prices, and the number of stocks bought. Buying a new one means adding to both, and computing the average price just happens on the fly.
* UmbralRaptop
really should get less bad at sleep someday
egg|laptop|egg has joined #kspacademia
egg|laptop|egg has quit [Ping timeout: 189 seconds]
<kmath>
<PaulGCornish> I was researching Pluto in work today & found out that when astronomers named Pluto, one of the names they rejected… https://t.co/MaUB4rN0d1
<SnoopJeDi>
!or rename our bindings after Asimov or choose some other name
<galois>
SnoopJeDi: rename our bindings after Asimov
<SnoopJeDi>
good bot
<galois>
=]
<SnoopJeDi>
someone (whom I follow on twitter, surprisingly!) is unfortunately squatting `asimov` on PyPI for their thesis, but there are a bunch of other good names from his canon available
<SnoopJeDi>
!or giskard or baley
<galois>
SnoopJeDi: giskard
egg|cell|egg has quit [Ping timeout: 190 seconds]
egg|cell|egg has joined #kspacademia
egg|laptop|egg has joined #kspacademia
egg|laptop|egg has quit [Remote host closed the connection]
<egg|cell|egg>
Whitequark : I think shoving the cat through its flap may indeed have turned on a lightbulb after a few tries
<UmbralRaptop>
feline transport equation
egg|cell|egg has quit [Ping timeout: 190 seconds]
<SnoopJeDi>
猫nary curves
egg|cell|egg has joined #kspacademia
egg|laptop|egg has joined #kspacademia
egg|cell|egg has quit [Ping timeout: 190 seconds]
egg|laptop|egg has quit [Remote host closed the connection]