Ologhai Jones Posted October 23, 2013 Share Posted October 23, 2013 I've recently put together a few somewhat disparate ideas into something that, for the want of a better term, I'll call a stock market investment strategy. Being reasonably able to write computer software, I've set about trying to simulate how well my idea for a strategy might perform. To do this, I needed to be able to simulate the price movements of individual stocks. I have worked out a method to do this, and have been using it in the simulations I've been tinkering with. However, I've been wondering if any of you can see any obvious problems, or perhaps suggest better approaches to simulating stock price movements. Here's the gist of how I simulate individual stocks (I'm not saying it mimics what stocks do precisely, but I'm hoping it represents how stocks behave at least somewhat): First of all, I set some upper and lower boundary on how much the price of an individual stock can change in a month. The strategy I'm playing with actually seems to benefit from volatility, so I've been quite restrictive here and set it to +/- 5%. In principle, the number's not important, though--it just puts a limit on how much a stock price can move by in a month. Then, for each stock purchased, I initialise it with a random fiddle factor I'm calling 'quality'. This is a number between -100 and 100 and represents a percentage; specifically what proportion of the maximum allowed stock price change will an individual stock move by in the current month. If we stick with the +/- 5% from a moment ago, that means a stock with a quality of -100 will lose 5% in a given month, a stock with quality of -50 would lose 2.5%, a stock with +50 would gain 2.5% and so on. As each month goes by, any stocks that remain in the portfolio have their quality adjusted by +/- 20 (but still within the limits of +/- 100), and around we go again. For reasons of prudence and pessimism (basically to assume 'bad luck' when it comes to stock picking), initial stock qualities, although random, are skewed so that the average is -20 (rather than the 0 you might normally expect). In addition, for the same reason, instead of making the quality change +/- 20, I've actually made it -25 to +15. This means that the stocks picked are normally worse than average, and they tend to deteriorate in 'quality' over time. Finally, because I'm imagining that the stocks I'm simulating are from the FTSE 250, I take the underlying percentage change in that index and adjust all stocks' base movements by this amount to produce final stock prices for the current month. Just to spell it out with a single example: Stock A has a quality of +20 this month, so, all else being equal, it would rise by 1%. However the FTSE 250 happened to fall by 2.5% this month, so this stock is actually deemed to have fallen by 1.5%. Next month, due to the random quality adjustment, it will have a quality of +5 (and therefore a base share price change of 0.25%), but next month the FTSE will fall by 1.5%, so the stock will actually fall by 1.25%. Hopefully this makes sense (although I'm aware it's probably a long and fairly dull read). Please do let me know your thoughts. Is this even a moderately reasonable simulation of stock price movements? Or is there a different (but hopefully similarly simple) way of producing numbers that better represent reality? Quote Link to comment Share on other sites More sharing options...
Fatmanfilms Posted October 23, 2013 Share Posted October 23, 2013 There is no limit to how far a share can move up or down in a month, a fall to 0 or several hundred percent increase can & do happen. I've recently put together a few somewhat disparate ideas into something that, for the want of a better term, I'll call a stock market investment strategy. Being reasonably able to write computer software, I've set about trying to simulate how well my idea for a strategy might perform. To do this, I needed to be able to simulate the price movements of individual stocks. I have worked out a method to do this, and have been using it in the simulations I've been tinkering with. However, I've been wondering if any of you can see any obvious problems, or perhaps suggest better approaches to simulating stock price movements. Here's the gist of how I simulate individual stocks (I'm not saying it mimics what stocks do precisely, but I'm hoping it represents how stocks behave at least somewhat): First of all, I set some upper and lower boundary on how much the price of an individual stock can change in a month. The strategy I'm playing with actually seems to benefit from volatility, so I've been quite restrictive here and set it to +/- 5%. In principle, the number's not important, though--it just puts a limit on how much a stock price can move by in a month. Then, for each stock purchased, I initialise it with a random fiddle factor I'm calling 'quality'. This is a number between -100 and 100 and represents a percentage; specifically what proportion of the maximum allowed stock price change will an individual stock move by in the current month. If we stick with the +/- 5% from a moment ago, that means a stock with a quality of -100 will lose 5% in a given month, a stock with quality of -50 would lose 2.5%, a stock with +50 would gain 2.5% and so on. As each month goes by, any stocks that remain in the portfolio have their quality adjusted by +/- 20 (but still within the limits of +/- 100), and around we go again. For reasons of prudence and pessimism (basically to assume 'bad luck' when it comes to stock picking), initial stock qualities, although random, are skewed so that the average is -20 (rather than the 0 you might normally expect). In addition, for the same reason, instead of making the quality change +/- 20, I've actually made it -25 to +15. This means that the stocks picked are normally worse than average, and they tend to deteriorate in 'quality' over time. Finally, because I'm imagining that the stocks I'm simulating are from the FTSE 250, I take the underlying percentage change in that index and adjust all stocks' base movements by this amount to produce final stock prices for the current month. Just to spell it out with a single example: Stock A has a quality of +20 this month, so, all else being equal, it would rise by 1%. However the FTSE 250 happened to fall by 2.5% this month, so this stock is actually deemed to have fallen by 1.5%. Next month, due to the random quality adjustment, it will have a quality of +5 (and therefore a base share price change of 0.25%), but next month the FTSE will fall by 1.5%, so the stock will actually fall by 1.25%. Hopefully this makes sense (although I'm aware it's probably a long and fairly dull read). Please do let me know your thoughts. Is this even a moderately reasonable simulation of stock price movements? Or is there a different (but hopefully similarly simple) way of producing numbers that better represent reality? Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 23, 2013 Author Share Posted October 23, 2013 (edited) There is no limit to how far a share can move up or down in a month, a fall to 0 or several hundred percent increase can & do happen. No argument from me there. As I indicated in my OP, my 'strategy' seems to benefit from more rather than less volatility, so I've deliberately produced a relatively 'calm' simulation of price movements (while still feeling that most stock price movements probably hover within 5% of the underlying index most of the time). Can you suggest a better mechanism for deciding by how much a given stock price will change in a month. I accept my +/- 5% is rather naff, but it's simple (and when adjusted by the movement of the underlying index) probably averages out about right. If I am to include larger price movements, how might this best be achieved given that (I assume) larger movements are in a minority and (again, I assume) most stocks (that is to say their changes in price) will probably more or less follow the trend of the underlying index on average? Edited for clarity (hopefully). Edited October 23, 2013 by Ologhai Jones Quote Link to comment Share on other sites More sharing options...
bearwithasorehead Posted October 23, 2013 Share Posted October 23, 2013 I've recently put together a few somewhat disparate ideas into something that, for the want of a better term, I'll call a stock market investment strategy. Being reasonably able to write computer software, I've set about trying to simulate how well my idea for a strategy might perform. To do this, I needed to be able to simulate the price movements of individual stocks. I have worked out a method to do this, and have been using it in the simulations I've been tinkering with. However, I've been wondering if any of you can see any obvious problems, or perhaps suggest better approaches to simulating stock price movements. Here's the gist of how I simulate individual stocks (I'm not saying it mimics what stocks do precisely, but I'm hoping it represents how stocks behave at least somewhat): First of all, I set some upper and lower boundary on how much the price of an individual stock can change in a month. The strategy I'm playing with actually seems to benefit from volatility, so I've been quite restrictive here and set it to +/- 5%. In principle, the number's not important, though--it just puts a limit on how much a stock price can move by in a month. Then, for each stock purchased, I initialise it with a random fiddle factor I'm calling 'quality'. This is a number between -100 and 100 and represents a percentage; specifically what proportion of the maximum allowed stock price change will an individual stock move by in the current month. If we stick with the +/- 5% from a moment ago, that means a stock with a quality of -100 will lose 5% in a given month, a stock with quality of -50 would lose 2.5%, a stock with +50 would gain 2.5% and so on. As each month goes by, any stocks that remain in the portfolio have their quality adjusted by +/- 20 (but still within the limits of +/- 100), and around we go again. For reasons of prudence and pessimism (basically to assume 'bad luck' when it comes to stock picking), initial stock qualities, although random, are skewed so that the average is -20 (rather than the 0 you might normally expect). In addition, for the same reason, instead of making the quality change +/- 20, I've actually made it -25 to +15. This means that the stocks picked are normally worse than average, and they tend to deteriorate in 'quality' over time. Finally, because I'm imagining that the stocks I'm simulating are from the FTSE 250, I take the underlying percentage change in that index and adjust all stocks' base movements by this amount to produce final stock prices for the current month. Just to spell it out with a single example: Stock A has a quality of +20 this month, so, all else being equal, it would rise by 1%. However the FTSE 250 happened to fall by 2.5% this month, so this stock is actually deemed to have fallen by 1.5%. Next month, due to the random quality adjustment, it will have a quality of +5 (and therefore a base share price change of 0.25%), but next month the FTSE will fall by 1.5%, so the stock will actually fall by 1.25%. Hopefully this makes sense (although I'm aware it's probably a long and fairly dull read). Please do let me know your thoughts. Is this even a moderately reasonable simulation of stock price movements? Or is there a different (but hopefully similarly simple) way of producing numbers that better represent reality? Hi - nice idea - but it's not clear how the model links to a strategy - can you say more? Also if you are kind of correlating all your simulated stocks to changes in index that's potentially problematic as many are inversely related to changes in index. Other poster already pointed to another issue, in that many, many stocks even in 250 will vary by more than 5% over even small time frame. For example two of my actually owned stocks changed by 7% just today! Extreme volatility and long-term rises and declines that appear totally random make the stock market impossible to model, I would have said. Finally it seems possibly 'dangerous' to correlate 'quality' (even as an abstract variable) with propensity to change price, if I understand your modelling properly. I think we'd need to understand more about 'why' this modelling is required. Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 24, 2013 Author Share Posted October 24, 2013 Hi - nice idea - but it's not clear how the model links to a strategy - can you say more? Also if you are kind of correlating all your simulated stocks to changes in index that's potentially problematic as many are inversely related to changes in index. Other poster already pointed to another issue, in that many, many stocks even in 250 will vary by more than 5% over even small time frame. For example two of my actually owned stocks changed by 7% just today! Extreme volatility and long-term rises and declines that appear totally random make the stock market impossible to model, I would have said. Finally it seems possibly 'dangerous' to correlate 'quality' (even as an abstract variable) with propensity to change price, if I understand your modelling properly. I think we'd need to understand more about 'why' this modelling is required. I've been using real historical data for the FTSE 250 index itself, and, if I thought it was feasible, I would use equivalent data for all of the constituent companies. Although it may be theoretically possible to gather such data, I don't think I can realistically do that, what with one thing and another[1]. Unless someone can tell me different? Therefore, I have two choices: 1. Try to simulate some approximation of how stocks behave, or 2. Forget it! I realise that, as described, my current method doesn't directly simulate everything (as you and Fatmanfilms have pointed out)[2]. The question is, over a long enough period (i.e., a decade or longer), will my simulation represent the typical average behaviour of stocks? It's true that, every few months, I might find myself holding a stock that's halved in value (or even gone bump), or a stock that's doubled in value. Over a decade or two, though, will relatively occasional events such as this effectively act as noise that averages out at about the same as my simulation? To summarise: it's not that I necessarily need to simulate precisely how all stocks behave (or could behave), but that my method adequately represents how stock prices change (even collectively) over a reasonable timeframe. So, in lieu of being able to use actual historical data, I need some relatively simple way to represent the typical, average movement of stock prices. And I'd be happy to change to another method if anyone can think of one that's clearly superior to mine (as long as it's not too tricky to implement)! [1] The number of companies involved over the last thirty years, the promotions and demotions, the mergers, the bankruptcies, and so on. [2] Although, in my simulation, stock prices can rise or fall faster than the underlying index, or rise or fall in contradiction to the movement of the underlying index. Also, I could increase the average volatility (a maximum of +/- 5% may be too calm), but I've deliberately calmed it to be pessimistic about my strategy's performance because it does do better--quite a bit better--if I set it to, say, +/- 10%. And better still if I set it to +/- 20%. Quote Link to comment Share on other sites More sharing options...
bearwithasorehead Posted October 24, 2013 Share Posted October 24, 2013 I've been using real historical data for the FTSE 250 index itself, and, if I thought it was feasible, I would use equivalent data for all of the constituent companies. Although it may be theoretically possible to gather such data, I don't think I can realistically do that, what with one thing and another[1]. Unless someone can tell me different? Therefore, I have two choices: 1. Try to simulate some approximation of how stocks behave, or 2. Forget it! I realise that, as described, my current method doesn't directly simulate everything (as you and Fatmanfilms have pointed out)[2]. The question is, over a long enough period (i.e., a decade or longer), will my simulation represent the typical average behaviour of stocks? It's true that, every few months, I might find myself holding a stock that's halved in value (or even gone bump), or a stock that's doubled in value. Over a decade or two, though, will relatively occasional events such as this effectively act as noise that averages out at about the same as my simulation? To summarise: it's not that I necessarily need to simulate precisely how all stocks behave (or could behave), but that my method adequately represents how stock prices change (even collectively) over a reasonable timeframe. So, in lieu of being able to use actual historical data, I need some relatively simple way to represent the typical, average movement of stock prices. And I'd be happy to change to another method if anyone can think of one that's clearly superior to mine (as long as it's not too tricky to implement)! [1] The number of companies involved over the last thirty years, the promotions and demotions, the mergers, the bankruptcies, and so on. [2] Although, in my simulation, stock prices can rise or fall faster than the underlying index, or rise or fall in contradiction to the movement of the underlying index. Also, I could increase the average volatility (a maximum of +/- 5% may be too calm), but I've deliberately calmed it to be pessimistic about my strategy's performance because it does do better--quite a bit better--if I set it to, say, +/- 10%. And better still if I set it to +/- 20%. Okay, I think I get it. Sounds like a plan. Perhaps consider running it alongside a sample of real historical data for a sample of sector stocks to compare. I can't remember the detail but maybe you can incorporate 'Beta' - volatility and correlation to index, as I hinted at above - these stats are available free - I used to use the market data in FT for this as one of a number of heuristics in stock picking. I still don't quite see what you hope to gain from doing this simulation. Stocks are not a closed system and not subject to mathematical laws or thermodynamics :-) It is perfectly possible for a whole market to fall for a generation - I like to remind myself that the market is a sum of all the irrational greed and hopes of a society, with some extra volatility thrown in. It really is the madness of crowds plotted on a graph with little correlation to anything in the real world - even GDP. Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 24, 2013 Author Share Posted October 24, 2013 I still don't quite see what you hope to gain from doing this simulation. Stocks are not a closed system and not subject to mathematical laws or thermodynamics :-) It is perfectly possible for a whole market to fall for a generation - I like to remind myself that the market is a sum of all the irrational greed and hopes of a society, with some extra volatility thrown in. It really is the madness of crowds plotted on a graph with little correlation to anything in the real world - even GDP. I understand where you're coming from... BUT I've taken all that into account. You see, I've worked out an incredible new stock market investing strategy that cannot possibly fail, that will make anyone who tries it tremendously rich, AND that requires no financial market know-how, experience or talent to be able to execute. Actually, what's really frightening is that I'm half serious. In a decade or so, I'll let you know how it's going... Quote Link to comment Share on other sites More sharing options...
bearwithasorehead Posted October 24, 2013 Share Posted October 24, 2013 I understand where you're coming from... BUT I've taken all that into account. You see, I've worked out an incredible new stock market investing strategy that cannot possibly fail, that will make anyone who tries it tremendously rich, AND that requires no financial market know-how, experience or talent to be able to execute. Actually, what's really frightening is that I'm half serious. In a decade or so, I'll let you know how it's going... Let us know how it goes I have an acquaintance who kept scrupulous records of Brent Crude for 10 years and modelled a 'system' of buying/selling on a certain trigger of MDAs. On paper he was 40k up and then started doing it for real. Then we had the financial crisis and he lost 20k of real money which then wiped out his leverage. He tried something similar in silver recently - guess which way he was betting? Quote Link to comment Share on other sites More sharing options...
R K Posted October 24, 2013 Share Posted October 24, 2013 There's probably already an 'indicator' designed to do something along the lines you're thinking of which might save you some work. Perhaps take a look at:- * ATR - average true range * Bollinger bands * Standard deviation * Keltner channels etc etc over whatever period is relevant. there are good explanations of how these are calculated on stockcharts here (written by Arthur Hill I think) http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators For UK stocks and indices you can find most of these indicators on google, yahoo, marketwatch etc etc, or perhaps http://digitallook.com/ or ADVFN. Have fun! Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 25, 2013 Author Share Posted October 25, 2013 There's probably already an 'indicator' designed to do something along the lines you're thinking of which might save you some work. Perhaps take a look at:- * ATR - average true range * Bollinger bands * Standard deviation * Keltner channels etc etc over whatever period is relevant. there are good explanations of how these are calculated on stockcharts here (written by Arthur Hill I think) http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators For UK stocks and indices you can find most of these indicators on google, yahoo, marketwatch etc etc, or perhaps http://digitallook.com/ or ADVFN. Have fun! Thanks! I've played about with some of these charting methods before, but I'd thought that they were a means to help analyse past data to try to help predict future movements (although whether they really are useful for this is uncertain, at least to me). It's clear, for example, that Bollinger Bands help show volatility that might otherwise not be obvious just by looking at the underlying price data--and they really do help show volatility... but whether the Bands (along with how price data interacts with them) can be reliably used to predict future movement... who can say? (Not me anyway.) I have been aware of chartist retrospectively highlighting those cases where the future appears to have been predicted by such-and-such a line crossing the lower boundary of some band or other, but I wonder whether those times when it didn't seem to predict anything in particular simply get brushed under the rug more often than not! Anyway... simulating individual stock price movements... How would you see these methods being useful in doing that? Sorry if it's obvious and I'm just too dense to see it (quite likely ). Quote Link to comment Share on other sites More sharing options...
R K Posted October 25, 2013 Share Posted October 25, 2013 Thanks! I've played about with some of these charting methods before, but I'd thought that they were a means to help analyse past data to try to help predict future movements (although whether they really are useful for this is uncertain, at least to me). It's clear, for example, that Bollinger Bands help show volatility that might otherwise not be obvious just by looking at the underlying price data--and they really do help show volatility... but whether the Bands (along with how price data interacts with them) can be reliably used to predict future movement... who can say? (Not me anyway.) I have been aware of chartist retrospectively highlighting those cases where the future appears to have been predicted by such-and-such a line crossing the lower boundary of some band or other, but I wonder whether those times when it didn't seem to predict anything in particular simply get brushed under the rug more often than not! Anyway... simulating individual stock price movements... How would you see these methods being useful in doing that? Sorry if it's obvious and I'm just too dense to see it (quite likely ). First of all, I set some upper and lower boundary on how much the price of an individual stock can change in a month. The strategy I'm playing with actually seems to benefit from volatility, so I've been quite restrictive here and set it to +/- 5%. In principle, the number's not important, though--it just puts a limit on how much a stock price can move by in a month. Agree, all indicators are backward looking in the sense that no-one can know the future. Your volatilty boundaries must also (presumably) be using some historic assumptions ? Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 25, 2013 Author Share Posted October 25, 2013 Agree, all indicators are backward looking in the sense that no-one can know the future. Your volatilty boundaries must also (presumably) be using some historic assumptions ? For my (currently) +/- 5% figure, when I originally set it, I just plucked a figure out of nowhere. At the time, it happened to be +/- 10%. As I mentioned, with a little experimentation, I noticed that increasing this range improved my results, so I deliberately chose the smaller +/- 5% figure--although this was still not based on anything, other than just being an easy round number. Subsequently, I downloaded the FTSE 250 data and worked out the average (i.e., mean) positive monthly change to be around 4% and the average negative change to be about 3.5%. Those results didn't appear to show that my 'out of thin air' figure selection was especially any worse than any other figures I could've chosen. I sort of wish I could say it'd been more scientific than that, but it hasn't. Quote Link to comment Share on other sites More sharing options...
Ologhai Jones Posted October 30, 2013 Author Share Posted October 30, 2013 When an investment simulation shows that a strategy appears to be a roaring success, one is inclined to be sceptical. So, in the (kind of ) hope of breaking the spell, I thought I'd try to improve the realism of my simulation of stock price movements. Towards this end, I downloaded price data for a few randomly chosen FTSE 250 constituent companies to try to get a 'feeling' for month-by-month stock prices, e.g., how much stocks' values can change from month to month. Getting a feeling is about all I'm capable of--I lack the mathematical skill to quantify anything--but, based upon that I've started using another approach to simulating stock prices. It seems reasonably clear that stock price volatility varies quite substantially between companies (no surprises there I suppose), so I decided to assign some kind of volatility rating to each stock. When I randomly generate a stock's price movement for a given month, its volatility rating acts as a single standard deviation of the price change (in percentage terms). For example, if a stock has a volatility rating of 0.04, this means that there's a ~68% chance that this stock will move by +/- 4% in a month, a ~95% that it'll be within +/- 8%, and so on. Stock volatility ratings are also normally distributed; they can be as low as 0.01, and have a standard deviation of, say, 0.06, meaning that there's a 95% chance of a stock's volatility being up to 0.13 (a score of 0.13 would mean a 95% change of month-by-month stock price variations of up to +/- 26%). Occasionally, stock price volatility is higher (5% of the time, over 0.13 and up to about 0.19), which would cause (5% of the time) stock price fluctuations of between +/- 38% to +/- 57%... and on rarer occasions, more extreme than that. Just to be clear, I've chosen these numbers because of my 'feeling' after having looked at a selection of randomly chosen stocks' prices is that they seem to more or less represent what I'm seeing, but it does intuitively (for what little that counts) seem to me that it's a much more realistic representation of what stock prices do. Despite this rather major change to the way in which I simulate stock prices, the strategy I'm simulating still seems to be... yep, a roaring success. It looks like the only way to know is to spend a few years risking some money. *Gulp*. Quote Link to comment Share on other sites More sharing options...
bearwithasorehead Posted November 14, 2013 Share Posted November 14, 2013 When an investment simulation shows that a strategy appears to be a roaring success, one is inclined to be sceptical. So, in the (kind of ) hope of breaking the spell, I thought I'd try to improve the realism of my simulation of stock price movements. snip It looks like the only way to know is to spend a few years risking some money. *Gulp*. Amen to that. Ever tried a poker system with simulated money and then for real?? How about starting your system for real, but gradually, by risking only 1%, then 10% of whatever wealth you can afford to lose. I've done this with basic value-investing and it gave me the steep learning curve with real losses along the way which I needed. If I hadn't made those losses then I don't think I could have really kept focussed on the 'good' aspects of my strategy. I've been down 95% on a play, and had two stocks go bust. A salutary lesson. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.