I can haz automated richez b1tchez... eermm, yes | Options

Now, what news on the Rialto?
noddy
Posts: 11318
Joined: Tue Dec 13, 2011 3:09 pm

I can haz automated richez b1tchez... eermm, yes | Options

Post by noddy »

ive decided i might aswell use my coding skills for something amusing - playing with historical stockmarket data and seeing just how clever an automated system has to be to make money.

im barely beyond baby noises in regards such things and its going to be a long learning curve.

first step is getting the goodies to play with and preferably for free, so far i have found the following resources.

http://computeraidedfinance.com/2012/05 ... a-sources/
http://stackoverflow.com/questions/7545 ... stock-data

if anyone else has good sources of data or prior art or commentary that might be useful feel free!
ultracrepidarian
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

People have been doing this a long time, most software packages have backtesting as far as I know. My first exposure was in the late 90's iirc.

Anyway, it is fairly common, I googled "stock market backtesting" and got over a half a million hits. Never done it (although have seen it), but I imagine you can save yourself a lot of effort using stuff that's already out there.

It doesn't really end up working from what I've seen, but it is highly educational. I would encourage you to look into it.
Censorship isn't necessary
User avatar
Nonc Hilaire
Posts: 6168
Joined: Sat Dec 17, 2011 1:28 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Nonc Hilaire »

HFT trading by big players who pay no commissions or premiums to borrow YOUR stock for short sales have made technical analysis irrelevant. The best data available is just what they paint on the tape.

I'd forget the programming and just settle down at a good craps table and play a Martingale system. Kinda slow but more sure, and at least you would get free drinks, a free buffet and your winnings would not be MF Globaled.
“Christ has no body now but yours. Yours are the eyes through which he looks with compassion on this world. Yours are the feet with which he walks among His people to do good. Yours are the hands through which he blesses His creation.”

Teresa of Ávila
noddy
Posts: 11318
Joined: Tue Dec 13, 2011 3:09 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by noddy »

Mr. Perfect wrote:People have been doing this a long time, most software packages have backtesting as far as I know. My first exposure was in the late 90's iirc.

Anyway, it is fairly common, I googled "stock market backtesting" and got over a half a million hits. Never done it (although have seen it), but I imagine you can save yourself a lot of effort using stuff that's already out there.

It doesn't really end up working from what I've seen, but it is highly educational. I would encourage you to look into it.
learning was my intention - looking for patterns and coding rules and refining those rules is pretty much how my brain works now, it seemed the best way to get a sense of things.
HFT trading by big players who pay no commissions or premiums to borrow YOUR stock for short sales have made technical analysis irrelevant. The best data available is just what they paint on the tape.

I'd forget the programming and just settle down at a good craps table and play a Martingale system. Kinda slow but more sure, and at least you would get free drinks, a free buffet and your winnings would not be MF Globaled.
:-) i gamble all the time with my time and effort, i rarely if ever gamble with money..

i will only commit real money to it if i ever started doing well on the realtime data .. which is unlikely but hey, ive solved some intricate patterns before so why not have a play.

the most likely outcome is that i just learn alot and even if i decide that my instincts will do better than my rules, the process of doing it is the thing that drives the grok.
ultracrepidarian
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

As for algorithms, before computers could execute them that's how people made decisions in their mind anyway, all this talk about them being nefarious is completely anti-intellectual.

Trading changes, and so the goal is not to come up with a fail safe algorithm (impossible) the goal is to acquire the knowledge to create the best algorithm for the moment, or whatever time period is relevant to you.
Censorship isn't necessary
User avatar
Azrael
Posts: 1863
Joined: Thu Dec 22, 2011 8:57 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Azrael »

noddy wrote:ive decided i might aswell use my coding skills for something amusing - playing with historical stockmarket data and seeing just how clever an automated system has to be to make money.
A better idea would be to use the computer to buy and sell options. You could program the computer to find violations of put-call parity, which is based on the idea that a long position and a synthetic long position should have the same payoff and profit, while the same is true of a short position and a synthetic short position.

Short term on-the-money and near on-the-money options are already traded to death; but I think that there are still opportunities in out-of-the-money options with maturity dates a few months out. If you write puts out-of-the-money which will mature in a few months, you're essentially selling insurance, which can be a good business.

If you were to make any progress at this, I'd be interested in hearing it.

I don't think you're system will have the speed to beat the market if you're just trading stocks or very short term, on-the-money options. In that case, your competition has spent a fortune to get real estate right next to the exchange and a massive amount of infrastructure to save microseconds.
cultivate a white rose
User avatar
Azrael
Posts: 1863
Joined: Thu Dec 22, 2011 8:57 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Azrael »

Nonc Hilaire wrote:HFT trading by big players who pay no commissions or premiums to borrow YOUR stock for short sales have made technical analysis irrelevant. The best data available is just what they paint on the tape.
You're right. Day trading stock by individuals is no longer viable.
I'd forget the programming and just settle down at a good craps table and play a Martingale system. Kinda slow but more sure,
Casinos have caught on to that. If you're a very big fish, you might be able to talk them in to bending the rules a little; but otherwise you'll lose money in the long run.
and at least you would get free drinks, a free buffet and your winnings would not be MF Globaled.
Depends on where you go. A lot of casinos are no longer so generous about drinks, food, etc. anymore.
cultivate a white rose
User avatar
Nonc Hilaire
Posts: 6168
Joined: Sat Dec 17, 2011 1:28 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Nonc Hilaire »

Azrael wrote:
Nonc Hilaire wrote:I'd forget the programming and just settle down at a good craps table and play a Martingale system. Kinda slow but more sure,
Casinos have caught on to that. If you're a very big fish, you might be able to talk them in to bending the rules a little; but otherwise you'll lose money in the long run.
and at least you would get free drinks, a free buffet and your winnings would not be MF Globaled.
Depends on where you go. A lot of casinos are no longer so generous about drinks, food, etc. anymore.
It's been a while since I've been to a casino (12 years - same as my daughter's age), but the key to running a successful Martingale system is to find a table that has a low enough minimum bet and a high enough table limit to let you play nine doublings. Hopefully allowing 5x odds, because the house has no percentage on odds. Odds is the only even bet on the floor.
“Christ has no body now but yours. Yours are the eyes through which he looks with compassion on this world. Yours are the feet with which he walks among His people to do good. Yours are the hands through which he blesses His creation.”

Teresa of Ávila
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

"Day trading" is as viable as ever, HFT has lowered trading costs dramatically and it's never been cheaper and faster to trade.

Long term out of the money put selling is low yield per risk.
Censorship isn't necessary
User avatar
Azrael
Posts: 1863
Joined: Thu Dec 22, 2011 8:57 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Azrael »

Nonc Hilaire wrote:
Azrael wrote:
Nonc Hilaire wrote:I'd forget the programming and just settle down at a good craps table and play a Martingale system. Kinda slow but more sure,
Casinos have caught on to that. If you're a very big fish, you might be able to talk them in to bending the rules a little; but otherwise you'll lose money in the long run.
and at least you would get free drinks, a free buffet and your winnings would not be MF Globaled.
Depends on where you go. A lot of casinos are no longer so generous about drinks, food, etc. anymore.
It's been a while since I've been to a casino (12 years - same as my daughter's age), but the key to running a successful Martingale system is to find a table that has a low enough minimum bet and a high enough table limit to let you play nine doublings. Hopefully allowing 5x odds, because the house has no percentage on odds. Odds is the only even bet on the floor.
But every casino that is still in business has thought of the Martingale a long time ago. In the long run, you'd lose money.
cultivate a white rose
User avatar
Azrael
Posts: 1863
Joined: Thu Dec 22, 2011 8:57 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Azrael »

Mr. Perfect wrote:"Day trading" is as viable as ever, HFT has lowered trading costs dramatically and it's never been cheaper and faster to trade.
Do you have some stats on this? This goes against everything I've read lately.
Long term out of the money put selling is low yield per risk.
I really don't know . . . do you have stats on this? Any references? I'd be very interested.
cultivate a white rose
User avatar
Juggernaut Nihilism
Posts: 1417
Joined: Mon Feb 13, 2012 7:55 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Juggernaut Nihilism »

Day trading is not viable. Most estimates are that 80-90% of day traders lose money. It works for a few people, at least for awhile, but that doesn't make it viable. It might work for Mr. Perfect, but calling it viable would be like a professional poker player telling you that cards was a realistic career path. The vast majority of people come in, drop off some money, then leave.
"The fundamental rule of political analysis from the point of psychology is, follow the sacredness, and around it is a ring of motivated ignorance."
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

Azrael wrote: Do you have some stats on this? This goes against everything I've read lately.
1. Juggs is right, dt is not very viable, but it is no less viable than at any other point in time. I don't often daytrade on purpose, for a good reason perhaps that could be gotten into later, but I know quite a few people who pull it off. To me it's too much like a job.
2. Spreads and commissions are at all time lows, largely because of HFT provided liquidity. Fills are essentially instant. It's wonderful. Most HFT pop culture literature is A grade BS.
I really don't know . . . do you have stats on this? Any references? I'd be very interested.
Just pick a stock and start looking at some contracts. Let's say that you pick 3-4 months out, $10 out of the money, the longer you go out the lower profit per month you make. The most profitable options are generally about 6 weeks out or less (time decay increases as you get to expiration). So the further out you sell you get a diminishing premium per month of time. This being November you could sell Aprils in scenario 1 or sell a January, let it expire and then sell a Feb or a Marxh, let it expire, then sell an April and you would make more money in scenario 2.

When selling premium your straight odds of winning are 2 out of 3, but keep in mind your upside is limited and your downside "unlimited" (the real limit is when the stock reaches zero on put but unlimited on a call). To restate your two winners could be much smaller than your loser.

When you add in that premium selling is about limited upside and very large potential downside, you could win 5-6 times in a row, make a little profit, and lose 10 times that much on one loser, just looking at raw odds. Short term bull put spreads with a good premium mitigates this.
Censorship isn't necessary
User avatar
Juggernaut Nihilism
Posts: 1417
Joined: Mon Feb 13, 2012 7:55 pm

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Juggernaut Nihilism »

Mr. Perfect wrote:Just pick a stock and start looking at some contracts. Let's say that you pick 3-4 months out, $10 out of the money, the longer you go out the lower profit per month you make. The most profitable options are generally about 6 weeks out or less (time decay increases as you get to expiration). So the further out you sell you get a diminishing premium per month of time. This being November you could sell Aprils in scenario 1 or sell a January, let it expire and then sell a Feb or a Marxh, let it expire, then sell an April and you would make more money in scenario 2.

When selling premium your straight odds of winning are 2 out of 3, but keep in mind your upside is limited and your downside "unlimited" (the real limit is when the stock reaches zero on put but unlimited on a call). To restate your two winners could be much smaller than your loser.

When you add in that premium selling is about limited upside and very large potential downside, you could win 5-6 times in a row, make a little profit, and lose 10 times that much on one loser, just looking at raw odds. Short term bull put spreads with a good premium mitigates this.
To everyone reading this: This is all good advice, but if any of it is news to you, do not even consider putting your money at risk. For options traders, the above advice is like telling a new poker player that 3-of-a-kind beats 2-pair... if you are just learning that, then don't go putting your savings at the same table as actual players. At least with poker, you can practice with dimes and nickels as long as you can find other people who are serious about getting better. For trading, you need to at least risk enough capital to overcome commissions and taxes in order to make it worth your time.

In this environment, Mr. Perfect should be trading to make money. If he has been doing this for a long time and can make money whether things go well or not, that's great. The other 99% of people, however, should be focused on hedging and protecting themselves, plain and simple.
"The fundamental rule of political analysis from the point of psychology is, follow the sacredness, and around it is a ring of motivated ignorance."
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

Tbh I do get into a little trouble here, I'm an A grade dumb@$$ but for some reason this material has never been confusing or intimidating and tbh I seem to be gifted at it, and I assume everyone else can just pick it up. So yes put all the disclaimers on it, I probably make it sound too easy. A lot of people get wiped out trading options, this is true, but to me it's like parachuting, as your education goes up they your odds of disaster approach zero.
Censorship isn't necessary
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes.

Post by Mr. Perfect »

This should help, if no one has seen it.

Image
Censorship isn't necessary
User avatar
Typhoon
Posts: 27242
Joined: Mon Dec 12, 2011 6:42 pm
Location: 関西

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Typhoon »

This is evolving into a very interesting thread, I hope that it can continue to develop.
May the gods preserve and defend me from self-righteous altruists; I can defend myself from my enemies and my friends.
User avatar
Nonc Hilaire
Posts: 6168
Joined: Sat Dec 17, 2011 1:28 am

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Nonc Hilaire »

Good chart by Mr. P.

The best rule of thumb regarding options I was ever given was to always sell on or before halfway to expiry.
“Christ has no body now but yours. Yours are the eyes through which he looks with compassion on this world. Yours are the feet with which he walks among His people to do good. Yours are the hands through which he blesses His creation.”

Teresa of Ávila
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Mr. Perfect »

Typhoon wrote:This is evolving into a very interesting thread, I hope that it can continue to develop.
It seems to help if people ask questions. No question is a dumb question.
Censorship isn't necessary
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Mr. Perfect »

Nonc Hilaire wrote:Good chart by Mr. P.

The best rule of thumb regarding options I was ever given was to always sell on or before halfway to expiry.
Halfway from what?

It sort of depends, like I say I rarely sell premium more than 6 weeks out. I do a deep in the money what I call a synthetic position spread where you sell a deep in the money call say 10-20 points and buy an at the money put, same expiration. The time premium collected from the call in theory offsets what you pay for in the put, so it's a little trick to pick up some free money in theory, I'm sure the accountants would disagree, but it makes me feel good. This is a bearish play, so the opposite would be a short stock and long synthetic position, spread with the call being at the money and the put being in the money. This would be a trade when you expect a sloppy pull back, you can pull 10 points out pretty easy.

There is an argument over what I call "decision risk", wherein you are in a position and due to volatility you may close a position like this out of fear timing of expiration. To me though it is entirely psychological. If you are afraid of expiration buying a little more time seems to help, but I really don't do it anymore.
Censorship isn't necessary
noddy
Posts: 11318
Joined: Tue Dec 13, 2011 3:09 pm

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by noddy »

thankyou everyone and especially mr p for your contributions.

i have many many questions to ask!

for the moment im still doing the groundwork of turning opaque industry terminology into noddy speak - which can be a slow process but coming from the computer industry is hardly new or problematic :)
ultracrepidarian
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Mr. Perfect »

Noddy something to add to the Present Value discussion, while you pursue that.

Stock picking is generally driven by 4 things, Fundamental Analysis, Technical Analysis, news, and randomness.

Almost everyone that invests gravitates to one of these or a mix of these.

Fundamental analysis is studying company financials, like sales and profits/earnings/corporate income (these terms are all virtually identical and can be used interchangeably), balance sheets, income statements, and a boatload of ratios and formulas (p/e and various measures of present value). Any conventional resource usually covers this material somewhat adequately, I have some tweaks on it when you get the basics.

Technical Analysis is reading stock charts. This carried a lot of stigma for a long time but really everyone does it now whether they know it or not. A great beginner book is "The Visual Investor". The beginner concepts you can google would be "support, resistance, and moving averages". More advanced indicators would be stochastics, MACD and or Bollinger bands. There are really a ton of them, so it helps to prioritize. Anything by Martin Pring is pretty good and you should check out candlesticks fairly early on. I think the "Visual" book covers the basics.

News investing is just reacting to news affecting the market or your stock in a time horizon of hours and days, sort of more day/swing trading, and there really isn't a book that I know of.

Randomness is it's own topic, Random Walk Down Wall Street is still the tome on that one I think, i don't know that it justifies a whole book. He just says it's all random, so diversify. Or something.

I subscribe to all these. In the longer term shares follow financials, as you go shorter the charts start to rule, news items have tradeable effects measured in hours and days, whilst randomness ie unpredictability just happens on occasion (ceo embezzles money, or scores an unexpected contract). It cuts both ways.

All of these factor in. Over time you will find that your natural trading intuition is suitable for a certain "time horizon", ie you will find that you hold stock for a certain time period. For me, my average trading position is about 4 months, with a large standard deviation. Real large. But everyone is different. Point being that your natural instincts determine which kind of analysis carries the most weight, and it helps to get good at that one. For me, with my natural holding periods chart reading is the most useful, but I bring everything else into play anyway. I think if you pick one to the exclusion of the rest you're sort of depriving yourself of resources.

And as always, remember that one of the most important rules is that 97% of all stocks are untradeable. Keep looking till you find one you can make sense of. Don't waste time forcing it.

Also, the single most important thing in investing is money management, which we'll get to later.
Censorship isn't necessary
noddy
Posts: 11318
Joined: Tue Dec 13, 2011 3:09 pm

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by noddy »

much to think and learn, thanks again.

im glad you brought up these topics aswell, the instinctual understanding of whats going on does seem to a magor factor in success - or lack of it.
ultracrepidarian
User avatar
Azrael
Posts: 1863
Joined: Thu Dec 22, 2011 8:57 pm

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Azrael »

Nonc Hilaire wrote:Good chart by Mr. P.

The best rule of thumb regarding options I was ever given was to always sell on or before halfway to expiry.
Good advice. And, if you write puts, buy them back on or before halfway to expiry. That minimizes risk.
cultivate a white rose
Mr. Perfect
Posts: 16973
Joined: Mon Dec 12, 2011 9:35 am

Re: I can haz automated richez b1tchez... eermm, yes | Optio

Post by Mr. Perfect »

Good point Az, good point, but allow me if I may;

buying back early we haven't discussed yet, and will probably confuse a lot of people, but you DEFINITELY should be looking at that.

The chart I posted assumes no change in price, if the price goes the way you want time premium decreases not due to time but due to delta (so to speak), and it makes sense to free up your margin before expiration when you are happy with your profit. There is no reason to hang around for 3 weeks when your option costs very little to close.

The actual decision to close a position I think should be more flexible than your rule, but it becomes obvious as you go through the process.

Stop loss decisions are important also, as always.
Censorship isn't necessary
Post Reply