Calculate price to earning and price to sale value for given dataset
Too calculate these values, information contained in the company's financial statements (income, balance, or cashflow) will be needed along with the price.  Google finance does not maintain this information for BME.  You will need to find another source for this information or analyze another another symbol's financial section (BAC for example).
nice work! really enjoyed looking through your website. do you see any possible application of Machine Learning (specifically tensorflow) to this? I was thinking about building a trading bot that uses data from various APIs as a strategy just as an experiment but I'm wondering what your insights are. You're realizing the perils of using a DCF analysis.  At best, you can use them to get a range of possible values and use them as a heuristic, but you'll probably find it difficult to generate a realistic estimate that is significantly different than where the price is already. Outside of software that can calculate the returns:  You could calculate your possible returns on that leap spread as you ordinarily would, then place the return results of that and the return results for the covered call position side by side for any given price level of the stock you calculate, and net them out. (Netting out the dollar amounts, not percentage returns.)  Not a great answer, but there ya go. Software like OptionVue is expensive The three places you want to focus on are the income statement, the balance sheet, and cash flow statement. The standard measure for multiple of income is the P/E or price earnings ratio  For the balance sheet, the debt to equity or debt to capital (debt+equity) ratio. For cash generation, price to cash flow, or price to free cash flow. (The lower the better, all other things being equal, for all three ratios.) You bought 1 share of Google at $67.05 while it has a current trading price of $1204.11. Now, if you bought a widget for under $70 and it currently sells for over $1200 that is quite the increase, no? Be careful of what prices you enter into a portfolio tool as some people may be able to use options to have a strike price different than the current trading price by a sizable difference. Take the gain of $1122.06 on an initial cost of $82.05 for seeing where the 1367% is coming. User error on the portfolio will lead to misleading statistics I think as you meant to put in something else, right? That is true. You will not be able to reconstruct the value of the index from the data returned with this script.  I initially wrote this script because I wanted data for a lot of stocks and I wanted to perform PCA on the stocks currently included in the index. Ok maybe I should have went into further detail but I'm not interested in a single point estimate to compare the different options.  I want to look at the comparable NPVs for the two different options for a range of exit points (sell property / exit lease and sell equity shares). I want to graph the present values of each (y-axis being the PVs and x-axis being the exit date) and look at the 'cross-over' point where one option becomes better than the other (i'm taking into account all of the up front costs of the real estate purchase which will be a bit different in the first years).  i'm also looking to do the same for multiple real estate and equity scenarios, in all likelihood generate a distribution of cross-over points.  this is all theoretical, i'm not really going to take the results to heart. merely an exercise and i'm tangling with the discount rates at the moment. ( t2 / t1 ) - 1 Where t2 is the value today, t1 is the value 12 months ago.  Be sure to include dividend payments, if there were any, to t2.  That will give you total return over 12 months. "Treat each position or partial position as a separate LOT. Each time you open a position, a new lot of shares is created. If you sell the whole position, then the lot is closed. Done. But if you sell a partial quantity, you need to create a new lot. Split the original lot into two. The quantities in each are the amount sold, and the amount remaining. If you were to then buy a few more shares, create a third lot. If you then sell the entire position, you'll be closing out all the remaining lots. This allows you to track each buy/sell pairing. For each lot, simply calculate return based on cost and proceeds. You can't derive an annualized number for ALL the lots as a group, because there's no common timeframe that they share. If you wish to calculate your return over time on the whole series of trades, consider using TWIRR. It treats these positions, plus the cash they represent, as a whole portfolio. See my post in this thread: How can I calculate a ""running"" return using XIRR in a spreadsheet?" Unfortunately I believe there is not a good answer to this because it's not a well posed problem.  It sounds like you are looking for a theoretically sound criteria to decide whether to sell or hold.  Such a criteria would take the form of calculating the cost of continuing to hold a stock and comparing it to the transactions cost of replacing it in your portfolio. However, your criteria for stock selection doesn't take this form.  You appear to have some ad hoc rules defining whether you want the stock in your portfolio that provide no way to calculate a cost of having something in your portfolio you don't want or failing to have something you do want.  Criteria for optimally rebalancing a portfolio can't really be more quantitative than the rules that define the portfolio. If you have two other assets whose payoffs tomorrow are known and whose prices today are known, you can value it.  Let's say you can observe a risk-free bond and a stock. Using those, you can calculate the state prices/risk-neutral probabilities. NOTE: You do not need to know the true probabilities.   The value of your asset is then the state-price weighted sum of future payoffs. "I don't have a formula for anything like this, but it is important to note that the ""current value"" of any asset is really theoretical until you actually sell it. For example, let's consider a house.  You can get an appraisal done on your house, where your home is inspected, and the sales of similar houses in your area are compared.  However, this value is only theoretical.  If you found yourself in a situation where you absolutely had to sell your house in one week, you would most likely have to settle for much less than the appraised value. The same hold true for collectibles.  If I have something rare that I need cash for immediately, I can take it to a pawn shop and get cash.  However, if I take my time and locate a genuinely interested collector, I can get more for it. This is comparable to someone who holds a significant percentage of shares in a publicly held corporation.  If the current market value of your shares is $10 million, but you absolutely need to sell your entire stake today, you aren't going to get $10 million.  But if you take your time selling a little at a time, you are more likely to get much closer to this $10 million number. A ""motivated seller"" means that the price will drop." Yes, exactly. VaR is just a single tailed confidence interval.  To go from model to strategy, you need to design some kind of indicator (i.e. when to buy and when to short or stay out). In practice, this will look like a large matrix with values ranging from -1 to 1 (corresponding to shorting and holding respectively) for each security and each day (or hour, or minute, or tick, etc.), which you then just multiply with the matrix of the stock returns. The resulting matrix will be your daily returns for each stock, you can then just row sum for daily returns of a portfolio, or calculate a cumulative product for cumulative returns.  A simple example of an indicator would be something like a value of 1 when the price of the stock is below the 30 day moving average, and 0 otherwise. You can use a battery of econometric models to design these indicators, but the rest of the strategy design is essentially the same, and it's *relatively* easy to build a one-size-fits-all back-testing code.  I'll try to edit this post later and link a blog that goes through some of the code.  Edit: [Here](http://www.signalplot.com/simple-machine-learning-model-trade-spy/) is a post that discusses implementing a simple ML strategy. You can ignore most of the content but if you go through the github, you'll see how the ML model is implemented as a strategy.  An even easier example can be found from [the github connected to this post](http://www.signalplot.com/how-to-measure-the-performance-of-a-trading-strategy/), where the author is just using a totally arbitrary signal. As you can see, deriving a signal can be a ton of work, but once you have, actually simulating the strategy can be done in just a few lines of code.  Hopefully the author won't mind me linking his page here, but I find his coding style to be very clean and good for educational purposes. If annualized rate of return is what you are looking for, using a tool would make it a lot easier.   In the post I've also explained how to use the spreadsheet.   Hope this helps. The price-earnings ratio is calculated as the market value per share divided by the earnings per share over the past 12 months. In your example, you state that the company earned $0.35 over the past quarter. That is insufficient to calculate the price-earnings ratio, and probably why the PE is just given as 20. So, if you have transcribed the formula correctly, the calculation given the numbers in your example would be: 0.35 * 4 * 20 = $28.00 As to CVRR, I'm not sure your PE is correct. According to Yahoo, the PE for CVRR is 3.92 at the time of writing, not 10.54. Using the formula above, this would lead to: 2.3 * 4 * 3.92 = $36.06 That stock has a 52-week high of $35.98, so $36.06 is not laughably unrealistic. I'm more than a little dubious of the validity of that formula, however, and urge you not to base your investing decisions on it.