Compute average price even if I do not have the prices before
What I do have is this (sample only): Stock X: Average Price of all I purchased before = 80 Total Shares = 200 So if Stock X's price today is 100 how do I know how much my average price will be? Using your sample if you buy 100 new shares and the price is 85 for the purpose of this example your previous total cost is $16,000 ($80 average cost * 200 shares).  With the new example you are adding $8500 to your total cost (100 new shares * $85 example cost per share)  that gives us a total cost of $24,500 and 300 shares. $24,500/300 gives us an average cost of $81.67 per share. As long as you have the average cost and the number of shares you can calculate a new average without knowing what the price was for each transaction. It may still become important to find the price information for tax purposes if you do not sell all of those shares at once and use FIFO for your taxes.
A day is a long time and the rate is not the same all day. Some sources will report a close price that averages the bid and ask. Some sources will report a volume-weighted average. Some will report the last transaction price. Some will report a time-weighted average. Some will average the highest and lowest prices for the interval. Different marketplaces will also have slightly different prices because different traders are present at each marketplace. Usually, the documentation will explain what method they use and you can choose the source whose method makes the most sense for your application. "I have been considering a similar situation for a while now, and the advice i have been given is to use a concept called ""dollar cost averaging"", which basically amounts to investing say 10% a month over 10 months, resulting in your investment getting the average price over that period. So basically, option 3." The price inflation isn't a percentage, it's a fixed amount. If the dealer adds $R to the price of both the trade-in and the purchased car, then everyone ends up with the right amount of money in their pockets. So your formula should be: D + T + R = 0.1 * (P + R) You will most likely not be able to avoid some form of format conversion, regardless of which data you use since there is, afaik, no standard for this data and everyone exports it differently. One viable option would be, like you said yourself, using the free data provided by Dukascopy. Please take into consideration that those are spot currency rates and will most likely not represent the rate at which physical and business-related exchange would have happened at this time. Assuming cell A1 contains the number of trades: will price up to A1=100 at 17 each, and the rest at 14 each. The key is the MAX and MIN. They keep an item from being counted twice. If X would end up negative, MAX(0,x) clamps it to 0. By extension, if X-100 would be negative, MAX(0, X-100) would be 0 -- ie: that number doesn't increase til X>100. When A1=99, MIN(a1,100) == 99, and MAX(0,a1-100) == 0. When A1=100, MIN(a1,100) == 100, and MAX(0,a1-100) == 0. When A1=101, MIN(a1,100) == 100, and MAX(0,a1-100) == 1. Of course, if the 100th item should be $14, then change the 100s to 99s. "Probably the best way to investigate this is to look at an example. First, as the commenters above have already said, the log-return from one period is log(price at time t/price at time t-1) which is approximately equal to the percentage change in the price from time t-1 to time t, provided that this percentage change is not big compared to the size of the price. (Note that you have to use the natural log, ie. log to the base e -- ln button on a calculator -- here.) The main use of the log-return is that is a proxy for the percentage change in the price, which turns out to be mathematically convenient, for various reasons which have mostly already been mentioned in the comments. But you already know this; your actual question is about the average log-return over a period of time. What does this indicate about the stock? The answer is: if the stock price is not changing very much, then the average log-return is about equal to the average percentage change in the price, and is very easy and quick to calculate. But if the stock price is very volatile, then the average log-return can be wildly different to the average percentage change in the price. Here is an example: the closing prices for Pitchfork Oil from last week's trading are: 10, 5, 12, 5, 10, 2, 15. The percentage changes are: -0.5, 1.4, -0.58, 1, -0.8, 6.5 (where -0.5 means -50%, etc.) The average percentage change is 1.17, or 117%. On the other hand, the log-returns for the same period are -0.69, 0.88, -0.88, 0.69, -1.6, 2, and the average log-return is about 0.068. If we used this as a proxy for the average percentage change in the price over the whole seven days, we would get 6.8% instead of 117%, which is wildly wrong. The reason why it is wrong is because the price fluctuated so much. On the other hand, the closing prices for United Marshmallow over the same period are 10, 11, 12, 11, 12, 13, 15. The average percentage change from day to day is 0.073, and the average log-return is 0.068, so in this case the log-return is very close to the percentage change. And it has the advantage of being computable from just the first and last prices, because the properties of logarithms imply that it simplifies to (log(15)-log(10))/6. Notice that this is exactly the same as for Pitchfork Oil. So one reason why you might be interested in the average log-return is that it gives a very quick way to estimate the average return, if the stock price is not changing very much. Another, more subtle reason, is that it actually behaves better than the percentage return. When the price of Pitchfork jumps from 5 to 12 and then crashes back to 5 again, the percentage changes are +140% and -58%, for an average of +82%. That sounds good, but if you had bought it at 5, and then sold it at 5, you would actually have made 0% on your money. The log-returns for the same period do not have this disturbing property, because they do add up to 0%.  What's the real difference in this example? Well, if you had bought $1 worth of Pitchfork on Tuesday, when it was 5, and sold it on Wednesday, when it was 12, you would have made a profit of $1.40. If you had then bought another $1 on Wednesday and sold it on Thursday, you would have made a loss of $0.58. Overall, your profit would have been $0.82. This is what the average percentage return is calculating. On the other hand, if you had been a long-term investor who had bought on Tuesday and hung on until Thursday, then quoting an ""average return"" of 82% is highly misleading, because it in no way corresponds to the return of 0% which you actually got!  The moral is that it may be better to look at the log-returns if you are a buy-and-hold type of investor, because log-returns cancel out when prices fluctuate, whereas percentage changes in price do not. But the flip-side of this is that your average log-return over a period of time does not give you much information about what the prices have been doing, since it is just (log(final price) - log(initial price))/number of periods. Since it is so easy to calculate from the initial and final prices themselves, you commonly won't see it in the financial pages, as far as I know.  Finally, to answer your question: ""Does knowing this single piece of information indicate something about the stock?"", I would say: not really. From the point of view of this one indicator, Pitchfork Oil and United Marshmallow look like identical investments, when they are clearly not. Knowing the average log-return is exactly the same as knowing the ratio between the final and initial prices." To calculate you take the Price and divide it by the Earnings, or by the Sales, or by the Free Cash Flow. Most of these calculations are done for you on a lot of finance sites if the data is available. Such sites as Yahoo Finance and Google Finance as well as my personal favorite: Morningstar Right, that's my understanding of the problem too. I tried some of the indices last night (not necessarily the ones you are suggesting), but when pulling them into COMP it only provided the price return, not the total return including coupons. This latter part is still the challenge. "I recently needed to compute a better balance that let us pick and choose what to include in the computed sum without losing information, so I revisited this topic and I'm pleased to say that I've found a solution that works (at least for our data - you may have transactions that this code doesn't recognize, but you can always modify it to match). My solution was written natively for MS SQL Server 2008 or later, it uses a scalar UDF, a VIEW, and a windowed aggregate (SUM OVER (ORDER BY ...) which means it should be almost-syntax compatible with PostgreSQL. MySQL does not support OVER but you can perform a running-sum using a variable with arithmetic addition directly in the SELECT clause. Create a database table with this schema (feel free to exclude columns you're not interested in, such as Option1Name): Create a UNIQUE index on TxnId - you could use it as a primary-key, I suppose. You might be tempted to create a Foreign-Key relationship between ReferenceTxnId and TxnId, however this will fail if you enforce it: we have many transactions where ReferenceTxnId points to a Transaction that doesn't exist. This is usually in the case of [Type] = 'Web Accept Payment Received' AND [Status] = 'Canceled'. We also have some TransactionId values longer than 17 characters: some TransactionIds start with ""U-"" - all pending money requests, I suspect this indicates the transaction is ""unfinished"". Re-download your entire PayPal History CSV files so that you have the latest retroactive updates. Import these CSV files into this PayPalHistory table. Do a simple test to see how bad PayPal's default data is: To find out where the differences are coming from, run this query: (The ORDER BY (...), RowId is to ensure consistent ordering when multiple transactions share the same timestamp) As you scroll through the results, you'll see how the naive SUM is thrown-off from the official PayPal-computed Balance column. So as you can see, the Net column value cannot always be trusted - what we need is to generate our own ""EffectiveNet"" value which is accurate - that is, the value is 0.00 for rows which do not affect the balance, instead of being what they are right now. The problem is, given a single row of data (such as any single row from the example table in my original Question) we have no way of inherently knowing what its ""EffectiveNet"" is. I have devised two functions to help solve this problem, the first function only looks at the ReferenceTxnId, Type and Status column values and generates accurate values for the vast majority of rows - indeed, in our dataset we only had one row for which this approach did not work. I recommend you try this one first and compare the running-sum value to ensure it works for your data: You can use this function in the query like so below, hopefully it should give you an accurate running-sum and balance figure at the end: 8. And here's the view that ties it all together: Used like so: I hope this helps anyone else wanting to do accurate bookkeeping with PayPal Transaction History files!" With near zero marginal cost, and infinite supply, your prices are going to be decided by entry cost, competition, and what the market will bear. Generally speaking, though, there are no accurate models for getting these kinds of optimal prices in advance - your best bet is to test, experiment, and then build a business and market specific model based on what you observe.  Look at the Steam network, as an example. They are in the business of selling 0 marginal cost software (games), in a market with a significant but quickly decreasing entry cost, and with solid competition. Despite being around for years in a mature market, they're still discovering unexpected optimal price points when testing how their customers behave. You can use Google Finance Stock Screener for screening US stocks. Apparently it doesn't have the specific criterion (Last Price % diff from 52 week low) you are (were!) looking for.  I believe using its api you can get it, although it won't exactly be a very direct solution. I don't believe you would be able to with only Net Sales and COGS.  Are you talking about trying to estimate them?  Because then I could probably come up with an idea based on industry averages, etc.  I think you would need to know the average days outstanding, inventory turnover and the terms they're getting from their vendors to calculate actuals.  There may be other ways to solve the problem you're asking but thats my thoughts on it. "You have actually asked several questions, so I think what I'll do is give you an intuition about risk-neutral pricing to get you started.  Then I think the answer to many of your questions will become clear. Physical Probability There is some probability of every event out there actually occurring, including the price of a stock going up.  That's what we call the physical probability.  It's very intuitive, but not directly useful for finding the price of something because price is not the weighted average of future outcomes.   For example, if you have a stock that is highly correlated with the market and has 50% chance of being worth $20 dollars tomorrow and a 50% chance of being worth $10, it's value today is not $15.  It will be worth less, because it's a risky stock and must earn a premium.  When you are dealing with physical probabilities, if you want to compute value you have to take the probability-weighted average of all the prices it could have tomorrow and then add in some kind of compensation for risk, which may be hard to compute. Risk-Neutral Probability Finance theory has shown that instead of computing values this way, we can embed risk-compensation into our probabilities.  That is, we can create a new set up ""probabilities"" by adjusting the probability of good market outcomes downward and increasing the probability of bad market outcomes.  This may sound crazy because these probabilities are no longer physical, but it has the desirable property that we then use this set of probabilities to price of every asset out there: all of them (equity, options, bonds, savings accounts, etc.).  We call these adjusted probabilities that risk-neutral probabilities.  When I say price I mean that you can multiply every outcome by its risk-neutral probability and discount at the risk-free rate to find its correct price.    To be clear, we have changed the probability of the market going up and down, not our probability of a particular stock moving independent of the market.  Because moves that are independent of the market do not affect prices, we don't have to adjust the probabilities of them happening in order to get risk-neutral probabilities. Anyway, the best way to think of risk-neutral probabilities is as a set of bogus probabilities that consistently give the correct price of every asset in the economy without having to add a risk premium. If we just take the risk-neutral probability-weighted average of all outcomes and discount at the risk-free rate, we get the price.  Very handy if you have them. Risk-Neutral Pricing We can't get risk-neutral probabilities from research about how likely a stock is to actually go up or down.  That would be the physical probability.  Instead, we can figure out the risk-neutral probabilities from prices. If a stock has only two possible prices tomorrow, U and D, and the risk-neutral probability of U is q, then Price = [ Uq + D(1-q) ] / e^(rt) The exponential there is just discounting by the risk-free rate.  This is the beginning of the equations you have mentioned.  The main thing to remember is that q is not the physical probability, it's the risk-neutral one.  I can't emphasize that enough.  If you have prespecified what U and D can be, then there is only one unknown in that equation: q. That means you can look at the stock price and solve for the risk neutral probability of the stock going up.   The reason this is useful is that you can same risk-neutral probability to price the associated option.  In the case of the option you don't know its price today (yet) but you do know how much money it will be worth if the stock moves up or down.  Use those values and the risk-neutral probability you computed from the stock to compute the option's price.  That's what's going on here.  To remember: the same risk-neutral probability measure prices everything out there.  That is, if you choose an asset, multiply each possibly outcome by its risk-neutral probability, and discount at the risk-free rate, you get its price.  In general we use prices of things we know to infer things about the risk-neutral probability measure in order to get prices we do not know." "You answered your own question ""whether someone buys is a different thing"". You can ask any price that you want. (Or given an electronic brokerage, you can enter the highest value that the system was designed to accept.) The market (demand) will determine whether anyone will buy at the price you are asking. A better strategy if you want to make an unreasonable amount of money is to put in a buy order at an unreasonably low price and hope a glitch causes a flash crash and allows you to purchase at that price. There may be rules that unravel your purchase after the fact, but it has a better chance of succeeding than trying to sell at an unreasonably high price." "I had  both closing price and adjusted price of Apple showing the same amount after ""download data"" csv file was opened in excel. https://finance.yahoo.com/quote/AAPL/history?period1=1463599361&period2=1495135361&interval=div%7Csplit&filter=split&frequency=1d Its frustrating. My last option was to get the dividends history of the stock and add back to the adjusted price to compute the total return for a select stock for the period."