"It is not the responsibility of the language to force good looking code, but the language should make good looking code possible." -- Yukihiro MatsumotoI just discovered the power of Ruby!!!
More later,
MT
The critical ingredient is a maverick mind. Focus on trading vehicles, strategies and time horizons that suit your personality. In a nutshell, it all comes down to: Do your own thing (independence); and do the right thing (discipline). -- Gil Blake
"It is not the responsibility of the language to force good looking code, but the language should make good looking code possible." -- Yukihiro MatsumotoI just discovered the power of Ruby!!!
"And don't write longer, more obtuse code because you think it's faster. Remember, hardware gets faster. MUCH faster, every year. But code has to be maintained by programmers, and there's a shortage of good programmers out there. So, if I write a program that's incredibly maintainable and extensible and it's a bit too slow, next year I'm going have a huge hit on my hands. And the year after that, and the year after that.Great quote! Read more on this topic here.
If you write code with more code that's fast now, you're going to have a hit on your hands. And next year, you're going to have a giant mess to maintain, and it's going to slow you down adding features and fixing bugs, and someone's going to come along and eat your lunch." -- Wil Shipley
"Be careful about using the following code -- I've only proven that it works, I haven't tested it." -- Donald KnuthI have finally started my dynamic allocation of equity project. This is something I've stewed about for several weeks...okay...maybe months. But, after meeting with Jon for lunch this weekend...I finally got the motivation back to begin work on the project. Thanks Jon!
******Begin of Code***********************
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("TaylorTree")
cursor = conn.cursor()
SQL = """
create table MarketDaily
(
Symbol text,
Bar SQL_DATE,
Open float,
High float,
Low float,
Close float,
Volume float,
AdjClose float,
primary key (Symbol, Bar)
);
"""
cursor.execute(SQL)
******End of Code***********************
******Begin of Code***********************Fetch from Table:
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("TaylorTree")
cursor = conn.cursor()
SQL = """
insert into MarketDaily
(Symbol, Bar, Open, High, Low, Close, Volume, AdjClose)
values
(
"YHOO",
20060801,
20.00,
25.00,
19.00,
22.00,
50000,
22.00
);
"""
cursor.execute(SQL)
conn.commit()
******End of Code***********************
******Begin of Code***********************
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("TaylorTree")
cursor = conn.cursor()
SQL = "select * from MarketDaily"
cursor.execute(SQL)
# Retrieve all rows as a sequence and print that sequence:
print cursor.fetchall()
cursor.close()
******End of Code***********************
******Begin of Code***********************
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("TaylorTree")
cursor = conn.cursor()
SQL = "drop table MarketDaily"
cursor.execute(SQL)
******End of Code***********************
******Begin of Code***********************After spending a lot of time getting all that going...I then turn back to pytables. Maybe I need to dig deeper there. Found some very good documentation here. But, I'm still sitting here...nothing. Hey, someone give me some motivation on working with this bad boy! Anybody have any experience to share in regard to pytables? If so, bring it on! I need some mojo!
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("TaylorTree")
cursor = conn.cursor()
def UpdatePrice(sym, b, o, h, l, c, v, ac):
SQL = """
insert into MarketDaily
(Symbol, Bar, Open, High, Low, Close, Volume, AdjClose)
values
(
'%s',
%s,
%s,
%s,
%s,
%s,
%s,
%s
);
""" % (sym, b, o, h, l, c, v, ac)
cursor.execute(SQL)
conn.commit()
******End of Code***********************
******Begin of Code********2 lines. Now, I'm sure there is a much easier way to call a COM Object in C# that what I was trying to do. If anyone out there knows how...please leave a comment. I'm really interested to see how many lines it takes to connect.
import win32com.client
w=win32com.client.Dispatch("TC2000Dev.cTC2005")
******End of Code**********
"One of the best attributes I know a trader to have is humility. The best traders I know admit to knowing very little about what the market will do or don't pretend to have any kind of secret method or style or edge that others don't have. They just go in to work everyday like a brick layer. Their goal is to lay bricks. One at a time. And hopefully at the end of their life they have built a solid foundation. That's all a trader can hope for." -- Maverick74Found the great quote above perusing EliteTrader this weekend. The thread is titled, Writing Options for a Living, read here. You'll have to be patient because a lot of time is spent with posts from people still believing in the Easter Bunny. But, there are a few gems to be found...especially from Maverick74, riskarb, and a few others.
" Becoming wealthy is like playing Monopoly.. the person who can accumulate the most assets wins the game."
-- Noel Whittaker
The ones who were successful had more emotional control. The ones who weren't successful were either too intellectually insecure and unable to commit to a strategy, too greedy, too emotionally invested in their financial success, too affected by the large swings in equity, or too averse to the risks required to trade well (probably due to a lack of confidence in themselves). One of the things that distinguished the good Turtles from the ones that were completely unsuccessful is their personalities. The traders with a more intellectual and systematic approach to life were much more successful than the emotional traders who really wanted to make a lot of money.And finally, one of the most important insights Curtis makes:
...all successful people owe their success to the help of others. They therefore have an obligation and usually a desire to pass on the craft, to teach and help others.I am thankful that such a thing is true. I owe many thanks to the people that have helped my programming and trading experience grow in the right direction. In a sense, we are all like those baby turtles Mr. Dennis refers to. Just trying to make it out to sea and swim with the big dogs. And avoid the many perils from beach to sea.
"There is no doubt in my mind that systems and styles which offer a rougher ride will hold up more over the long run because not as many traders and certainly almost no institutional money wants the ride.
![]()
You will make more money if you can take the pain. Unfortunately, you will make little or none if you think you can but it ends up that you can't."
- Curtis Faith -
MT
1) Fundamental Driven Markets - cleanest trends and easiest to trade;Plus, I always enjoy it when Curtis shares his Turtles experience. His coffee story reminds me of a few trades from my Melba Toast story.
2) Speculator Driven Markets - perception driven and harder to trade;
3) Aggregated Derivative Markets - averaging out effect dilutes momentum.
"Every now and then go away, even briefly, have a little relaxation, for when you come back to your work your judgement will be surer; since to remain constantly at work will cause you to lose power." -- Leonardo da VinciWell, I had a little break. And during that break I moved my family to Missouri! Yes, we are now in Missouri. Things are going good. Still have so much unpacking to do. But, was able to mow the yard (grass is different here than Texas) and find my grilling supplies for a good steak dinner with a corona or two.
"If you've been pounding nails with your forehead for years, it may feel strange the first time somebody hands you a hammer. But that doesn't mean that you should strap the hammer to a headband just to give your skull that old familiar jolt." -- Wayne ThroopThis quote rings so true. :)
If the majority of investorsLater Trades,
believe they will beat the market return by investing in fundamental
indexing, they will have to earn their above market return at the
expense of other market participants-- but those market participants
aren't anywhere to be had. Those abnormal returns exist because the
"market" has allocated funds in a particular way over the history of
the stock market. If the "market" were to no longer allocate funds that
way, perhaps we would have the indirect benefit of an overall better
functioning economic system, but directly, the market, as a whole,
cannot escape the market return. If everyone believes something to be true, you cannot earn abnormal returns off of it.
The time at my current employer is coming to an end and my new job soon beginning. I'm currently in the process of gathering up all the systems I have designed and supported over the past 8 years and ensuring the documentation is complete and up-to-date and the code nice and tight. I'll be turning these kids of mine over to another programmer to adopt and support. The programmer taking over the systems is a great guy and will indeed treat them well. But, as I'm cross-checking user guides, code documentation, and data dictionaries...I find motivation in the quote below:
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." -- M. Golding
I've always followed a similar mantra...Always design your systems to be supported by someone else even if it will only be supported by yourself. Because our main goal should be to let our code sail...
"A ship in port is safe, but that is not what ships are built for. I want all the youngsters to sail out to sea and be good ships." -- Grace Hopper
Speaking of software...what software tools do you use in your daily routine? Editors? Backtesters? Spreadsheets? Calculators? Here's a breakdown of my software tool set...
Wealth-Lab - Rapid Prototyping! I typically develop one or two trading systems over a 3 to 6 month time-frame. Each day I'll scribble ideas onto pieces of paper. Trying to find ways to improve the system and use Wealth-Lab to test those ideas out.
R Project - Great batch analysis of Wealth-Lab backtests. I'll run a Wealth-Lab simulation that generates a comma-delimited file of the trade output. Then analyze the CSV file with a batch R script that outputs to the terminal or to HTML. Couldn't live without this tool in backtesting and system studies.
ActiveState ActivePython - I can connect to the TC2005 database with Python and parse the securities anyway I please. Build portfolios by sector, exchange, etc. Oh, and ActiveState includes the Pythonwin IDE which is nice. Update: I also can connect to Wealth-Lab Developer with Python and run chartscripts against custom portfolios. Very cool when watching the Python script open and close the Wealth-Lab Chartscripts for each symbol in the list or table you're reading down.
gVim - This is my notepad replacement. I haven't used it very long...but so far so good. Also experimenting with jEdit. If only someone would develop an EVE Editor for Windows!
Excel - Hey, I know...pretty simple huh? Well, sometimes there's nothing better than Excel in dumping data quickly and testing out various scenarios.
Calcr - If you need to quickly calculate something...this website rocks! It can even handle assignment of variables. Such as x=2; x*2. Also the Google Search Bar always works in a crunch as shown in my Amortization Formula post.
Later Trades,
MT
Technorati : Calcr, R, editor, gVim, programming, python, quotation, wealth-lab
Del.icio.us : Calcr, R, editor, gVim, programming, python, quotation, wealth-lab
"Rest: the sweet sauce of labor" -- Plutarch
Testing new blog editor, Zoundry.
As you can see...taking it easy today. Actually taking a break before I begin more clean-up around the house. With putting my house up for sale, getting ready for my trip to Missouri, and completing a big project at my current job...I needed a rest! :)
The above picture is something my daughter and I drew a few weeks ago...a picture of her with her toy dog Danny. Just testing the picture insertion feature of this editor.
MT
Test of new blog editor, Qumana.
By the way, it's really cool to see the excitement surrounding Sun's new Fortress Language:
Deep Market - Fortress Programming Language for Scientific Computing
Wikipedia - Fortress Programming Language
Slashdot - Fortress: The Successor to Fortran?
Sig9 - Fortress
MT
Tags: blog, editor, qumana, fortress
“All changes, even the most longed for, have their melancholy; for what we leave behind us is a part of ourselves; we must die to one life before we can enter another.” -- Anatole France
"The moment one definitely commits oneself, then providence moves too. All sorts of things occur to help one that would never otherwise have occurred. A whole stream of events issues from the decision, raising in one's favor all manner of unforeseen incidents and meetings and material assistance, which no man could have dreamed would have come his way." -- Goethe
"All fixed set patterns are incapable of adaptability or pliability. The truth is outside of all fixed patterns." -- Bruce Lee
Came home today and noticed this hawk checking out our backyard. My daughter and I couldn't believe how close we got before it flew off.
Hope you're enjoying your weekend.
MT
“Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma - which is living with the results of other people's thinking. Don't let the noise of other's opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.” -- Steve Jobs
"Believe nothing, no matter where you read it,
or who said it, no matter if i have said it,
unless it agrees with your own reason
and your own common sense."
-- Buddha
"Success is the sum of small efforts, repeated day in and day out." -- Robert Collier
"To overcome my discipline problems, I've been programming my life to achieve the results I desire."
"Anytime I want to consciously achieve a goal, I figure out how I can setup a process so it would be hard to fail."
“The real voyage of discovery consists not in seeking new landscapes but in having new eyes.” -- Marcel Proust
"...human beings have a target level of risk with which they are most comfortable. When a given activity exceeds their comfort level, people will modify their behavior to reduce their risk until they are comfortable with their level of danger.....if a given person’s level of risk drops too far below their comfort level, they will again modify their behavior. This time though, they will increase their level of risk until they are once again in their target zone."
"You are looking to answer two questions. First, did my change actually help? If the change did speed things up, is there now a new bottleneck? Some part of our program is always going to be the limiting factor -- otherwise your code would be infinitely fast. As you optimize things, it is quite likely that the part you sped up will fade into the background and some other section of the code will become the new bottleneck."
"I don't care if your idea is so brilliantly efficient that it can't possibly not speed things up. If Mother Nature doesn't agree, Take It Out."
"The trouble with optimization is there is no end to it."
"successful hedge fund manager and author, james althucher, states in his new book--"super cash"---- that the trend following funds will be history within the next 10 years. he cites the dismal performance of the major trend funds over the last several years, over leverage, and investors pulling out. his new book is fantastic reading into the cutting edge of hedge funds. definitely check it out!" -- marketsurfer
"Man with one clock always know time. Man with two clocks never sure." -- Chinese Proverb
"Aim for success, not perfection. Never give up your right to be wrong, because then you will lose the ability to learn new things and move forward with your life." -- Dr. David M. Burns
"Why do they always teach us that it's easy and evil to do what we want and that we need discipline to restrain ourselves? It's the hardest thing in the world -- to do what we want. And it takes the greatest kind of courage. I mean, what we really want." - Ayn Rand
Curly: "I'll tell you the secret to life. This one thing. Just this one thing. You stick to that and everything else don't mean sh*t."
Billy: "What's the one thing?"
Curly: "That's what you've got to figure out."
City Slickers, the movie
"Somewhere, something incredible is waiting to be known." -- Carl Sagan
"The biggest secret about success is that there isn't any big secret about it, or if there is, then it's a secret from me, too. The idea of searching for some secret for trading success misses the point." -- Ed Seykota
The idea of searching for some secret for trading success misses the point. It's like golf. Some golfers play to spend time outdoors. They hang out with their cronies, become one with nature, study the greens, reconnect with their muscles, drop into focused concentration and, incidentally, pick up a birdie or two. For others, it's an exercise in finding some new Holy Grail putter. Different strokes for different folks!
In a market in which upswings are likely to equal or exceed downswings, a heavier position should be taken for the upswings for percentage reasons; a decline from 50 to 25 will net only 50% profit, whereas an advance from 25 to 50 will net 100%.
"If I wasn't dyslexic, I probably wouldn't have won the Games. If I had been a better reader, then that would have come easily, sports would have come easily...and I never would have realized that the way you get ahead in life is hard work." -- Bruce Jenner
Every time we go through a bad period in our firm, whether it's for two months or for eight months, people ask me have the markets changed. And I always say the same thing. I say, "Yes, the markets are always changing; but people's reaction to change, more or less, remain the same."
I knew I could not predict anything, and that is why we decided to follow trends, and that is why we've been so successful. We simply follow trends. No matter how ridiculous those trends appear to be at the beginning, and no matter how extended or how irrational they seem at the end, we follow trends.
At JWH, we realize that not only is it impossible to foretell the future, it's not necessary. We rely on the fact that other investors are convinced that they can predict the future, and I believe that's where our profits come from.
We may take a small risk in placing a trade initially, but after we have a large profit we risk it, and that's a risk very much worth taking and one we gladly accept.
Suffice it to say that we embrace both volatility and risk and, for us, risk is that we're going to lose if we risk two-tenths of one percent on a particular trade. That is, to us, real risk. Giving back a profit to you probably seems like risk, to us it seems like volatility.
"In fact, the ironic part of system design is if you want to maximize profits, you must be willing to give back a great deal of the profits you have already accumulated." -- Van K. Tharp
The Six Kase Behavioral Laws of Forecasting
Law Number One: Remember that the objective is profit, not ego-stroking.
Law Number Two: The objective is profitable trading, not proving a thesis or world view.
Law Number Three: When wrong, move on.
Law Number Four: Have confidence in your own intuition. Do not rely on the advice or opinion of others, no matter how well respected they might be.
Law Number Five: Do not read newspaper articles or watch newscasts that discuss the markets in which you have an interest.
Law Number Six: Plan your strategy when the market is closed - when you are rested and thinking clearly.
If you owned an option that was 20 standard deviations out of the money - and I had plenty of those - how many cumulative months of time decay could you sustain if it moved into the money?...it was 67,000 months of time decay.
If you have a 24-sigma even on an option that's 24 standard deviations out of the money, your payoff is 750,000 times your bet.
We're not programmed to deal with variables that can take very large deviations. We tend to not pay at all for things when we don't have reason to pay for them, but overpay when we see a reason.
"Being a scientist can sometimes be depressing. Surrounded by younger versions of yourself, you are constantly confronted by the mismatch between the dreams of youth and the facts of maturity." -- Emanuel Derman, author of My Life as a QuantOne of my favorite quotes and not only applicable to scientists and programmers...but everyone with several years of experience under their belts...and perhaps a few gray hairs to show for it. Heck, even relates to being a parent. Universal theme...I love it!
When I first started getting into systems, I was persistent, objective, and analytical. I've always been willing to say what it is that I do know, and what it is that I don't know. If somebody said to me "this will work" I'd say, "well, why will it work?" What's the proof?"
Great thinking...I believe many of us could apply this type of thinking to our investing strategies.
And Pardo goes on to describe the great Art of Cherry Picking...
They call this sort of thing cherry picking now. So many people, when they're looking at an idea by hand will say, "oh, it worked here, it worked here, it worked there, and boy, did it work great!" They ignore the fact that it had seven losers before this big win, and three more losers before that big win. They're maybe small, but they do add up. They need to be included in the equation.
In a system, risk is uniform and constant. I re-optimize models periodically because conditions and volatility change. You have to adapt to that to get optimal returns. Generally, though, we're risking the same tomorrow that we are today. Most people not only will vary their risk a great deal, but they'll get very skittish when they actually get a profit.
There's a powerful strategy being expressed here. Something Basso mentioned in his Market Wizards interview.
"Trading cannot be taught...it has to be caught. By that I mean you must have a perceptive nature. Without it, buy a system and execute it mechanically."
"I've had experience with this problem (self-sabotage). In short, I found if I had a goal that my self-concious believed was not doable, then I'd self-sabotage my trading. Once I realized this and changed my goals, the self-sabotage stopped."
"If you want to remain emotionless during trading, concentrate on the process and let the outcome happen."
** my favorite one **
"Giant oaks do grow from little acorns. But first you must have an acorn."
"Behind every successful man stands a surprised mother-in-law." -- Hubert Humphrey
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." -- Martin Golding
"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs." -- Maurice Wilkes
He was a cowboy, mister, and he loved the land. He loved it so much he made a woman out of dirt and married her. But when he kissed her, she disintegrated. Later, at the funeral, when the preacher said, "Dust to dust," some people laughed, and the cowboy shot them. At his hanging, he told the others, "I'll be waiting for you in heaven--with a gun."
"The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell
"Any time you sincerely want to make a change, the first thing you must do is to raise your standards. When people ask me what really changed my life eight years ago, I tell them that absolutely the most important thing was changing what I demanded of myself. I wrote down all the things I would no longer accept in my life, all the things I would no longer tolerate, and all the things that I aspired to becoming." -- Anthony Robbins
Collective2: A Marketplace of Trading Systems
Culls through the number of systems in Collective2's site and breakdowns the performance of swing trading versus daytrading. Most interesting part? Only 24% of Collective2's systems average 1% or more per week yet all systems exceed winning percentages of 50%.
Update: Cramer Offers You His Protection?
Asks and answers the question, Does Cramer have an edge? Insights shared: There may be some edge in buying the Cramers sells during the immediate negative returns and holding longer than 6 months. And it seems part of Cramer's edge is issuing buys on a rather large number of stocks. This creates a thin red line where the more stocks issued as buys...take him further away from market beating returns.
End-of-Quarter Effect: Window Undressing?
Is there a tradeable event at the end of quarters? This is something I have tested in the past and my results match their findings...expect market strength after the quarter...not before.
A Slinky (Short-term Reversion) Effect?
A study is performed on the cane walkers of Wall Street. After reading this post...I thought why judge the decline absolutely? Judge against volatility instead?
An Out-of-Sample Test
Discusses James O'Shaughnessy's strategies now used by Hennessy Funds. Interesting the Growth strategy beat Value in out-of-sample testing.
Ideally, a good performance measure should show high performance when the return on capital is high, when the equity/return curve increases linearly over time, and when loss periods (if any) are not clustered.
"I'm not smart, but I like to observe. Millions saw the apple fall, but Newton was the one who asked why." -- Bernard M. Baruch
"No question is so difficult to answer as that to which the answer is obvious." -- George Bernard Shaw
Back-testing can be useful, but I recommend you go one more step. Print out the gory details.And don't miss Basso's famous money management test on a random selection of trades. Profits to losses were setup as a two-to-one ratio and the buys and sells were fed back randomly. The tests showed professionals focused on risk while amateurs focused on gain. Something to think about.
I look for an indication that a trend either exists or doesn't. I like to look for those markets that aren't currently trending, the ones nobody cares about. Those are the markets that are likely to make a move one way or another.
If you mismatch what you're trying to do to who you are and what skills and resources you have, you're always going to be fighting it and never be in sync with it. If, on the other hand, you match your trading system to yourself, then trading can become as easy as breathing.
"If you're ridin' ahead of the herd, take a look back every now and then to make sure it's still there with ya."
Win Ratio: 69.23%Actually, not bad considering it's a first run. The profit factor of 12.54 is really nice considering I typically receive profit factors on first runs in the 5 to 8 range...if the idea has merit. Maybe we're on to something? :)
Avg Profit: 180.34%
Max Consecutive Winners: 8
Avg Loss: -30.68%
Max Consecutive Losers: 2
Max Drawdown: -8.12%
Profit Factor: 12.54
"Winners compare their achievements with their goals, while losers compare their achievements with those of other people." -- Nido Qubein
"All progress is precarious, and the solution of one problem brings us face to face with another problem." -- Martin Luther King Jr.
"To me trend following is more than an investment philosophy it is a way of life. Once I became familiar with how to stick with what is working and get rid of what is not, my personal life as well as my trading saw vast improvements. Unhealthy relationships and losing trades are cut and all I am left with are winning trades and rewarding, supportive relationships." -- Jason Dekker
"Trend following at its core is "simple", but the key lies in the consistent execution of a positive expectation system over time." -- Michael Covel.
XYZ stock closed at $30.00.
Average True Range (ATR) for 5 days: $4.00
ATR Multiplier: 3
ATR Trailing Stop := Close - (ATR * Multiplier) := $30.00 - ($4.00 * 3) := $18.00.
XYZ stock closed at $30.00.
The average closing price of past 20 days: $27.00
Average True Range (ATR) for 5 days: $4.00
ATR Multiplier: 3
ATR Trailing Stop := AverageClose - (ATR * Multiplier) := $27.00 - ($4.00 * 3) := $15.00.
"Only as you do know yourself can your brain serve you as a sharp and efficient tool. Know your own failings, passions, and prejudices so you can separate them from what you see." -- Bernard Baruch
"Don't judge each day by the harvest you reap, but by the seeds you plant." -- Robert Louis Stevenson
"In these times, when so much is written about the "money supply" and when some observers assert that an abundance of money will forestall a slump, it is interesting to note this comment by Senator Burton: "...paradoxical as it may seem, the starting point for crises and depressions may be found in abundance rather than in scarcity, whether of money or capital." -- Humphrey B. Neill in his book, The Art of Contrary Thinking, which was first printed in 1954.
"The reason the contrarian needs to be aware of history, in this regard, is because changes in trend occur before the masses are consciously observant of the fact. Also, because when socio-political conditions seem to revolve and repeat, the average person (of brief memory) is unaware of the "cycle" and is likely to think that a "new" condition has developed." -- Humphrey B. Neil