Personal Algo Trading

njhowie

Thinks s/he gets paid by the post
Joined
Mar 11, 2012
Messages
3,953
Note, this thread is about outright trading - so please don't come here looking to bash me or anyone else posting with how day trading is a fools game, you can't time/beat the market, etc., etc. Completely irrelevant to the topic. If you've come here to attack anyone or preach your opinion, please leave now. This thread has to do with Active Investing for those with a high-tech/software background.

That being said...

Any software developers here that are into trading? Ever considered/thought/dreamed about writing your own algo trading system and see how your programming might do in the market? Now is the time to do it!

Both TD Ameritrade and ETrade provide public APIs for developers to roll their own - direct programming interfaces in to their platform. Couple that with free commissions, and why not give it a try? Take $5k or $10k of your play money and see what you can come up with. You can do your coding in any language you're comfortable with that can interface with a REST API. Believe it or not, my system and tools are written in Visual Basic and Excel. You could use Java, Python, really anything you are good at programming with.

In January 2020 a friend pointed me to the TD API. I then spent a couple months developing an automated system. When it was ready, I spent another couple months running in a sandbox and fine tuning it. Come May, I turned it on live and it's been running on its own since. I'm not insanely rich like Jim Simons (yet), but it's been profitable and it's exciting watching it run, analyze what it's doing, fine tuning. Depending on what the market is doing, my system on average is executing between 10 and 50 round trip trades a day. Since May of last year, it's done 3400 round trip trades. Ultimately, I'd like to see it doing 500 to 1000 a day!

Key here is that you have so much flexibility in how you develop your system - buy or sell 1 share at a time if you like, penny stocks, etc. - the commissions are free (some small limitations with TD), so there's no penalty for experimenting. You determine the rules and the level of risk.

For anyone who has interest, below are the links to TD and ETrade and the documentation on their APIs. It only took 5 minutes to get set up with a developer account on TD. I haven't used the ETrade API, but when I quickly reviewed it a while back, it looked extremely similar to the TD API.

https://developer.tdameritrade.com

https://developer.etrade.com/home
 
Last edited:
Wow, this sounds really neat! Has it worked / been lucrative NJHowie? Do you need to invest in TD or eTrade to open an account and have access to the tools.

Darn, I need to retire soon so I have more time to learn/ execute stuff like this.

Thanks.
 
It is neat, and I believe that developers now have the ability to do for themselves what they've been busting their hump doing for the Wall Street firms. Who would believe it possible to be able to compete in the same space as the big firms with nothing more than your home computer(s) and an internet connection?

With TD you do not need a TD brokerage account to just sign up and open the developer account. However, the moment you want to use the API, you are going to need a TD brokerage account to run the trades through. I'm not familiar with what ETrade requires, but it's likely similar.

ETrade provides a sandbox for running offline and testing - so maybe you do not need a brokerage account there to use the sandbox. TD does not provide a sandbox - so I developed my own, but using a real brokerage account there.

As far as being lucrative, the returns have been multiples above market returns. My portfolio turnover numbers are insane. Having just finished August, year to date my portfolio turnover has been roughly 110x! That's not 110%, but 110 times the portfolio size. My approach is extremely low risk, not looking for home runs, just lots of singles and quickly compounding the returns. It's worked well thus far.
 
Thanks, very interesting. I just signed up and registered for the tools on TD. I will have to find some to to learn and study this but it sounds like it’s worthwhile to “play” with.
Thanks.
 
Can you briefly describe the human machine interface. Do you pick or limit the stocks or the algo? Does the algo have complete control on buys and sells, or do you set limits? Does the algo do any puts or calls? Any AI in the algo code? Sounds interesting.
 
This sounds great! I’ll check out the E*TRADE side of things. Looking forward to it, thanks for posting!
 
Can you briefly describe the human machine interface. Do you pick or limit the stocks or the algo? Does the algo have complete control on buys and sells, or do you set limits? Does the algo do any puts or calls? Any AI in the algo code? Sounds interesting.


You can program it to do whatever you want. If you can dream it and translate it into source code, you can do it.

Human machine interface? My system runs lights out, hands off.

You can use TD's API with the following instruments - stocks and options are no problem:

"assetType": "'EQUITY' or 'OPTION' or 'INDEX' or 'MUTUAL_FUND' or 'CASH_EQUIVALENT' or 'FIXED_INCOME' or 'CURRENCY'",


The way I've developed my system, it has a universe of about 1000 stocks to work with, which I've downloaded as a results set from screening in Fidelity's system. The algo can do what it wants with any of them from that point forward. It has complete control over buys and sells. However, I can monitor the current positions, and manually sell if I want. I could also manually buy if I wanted. But my objective was for me not to touch it.

Dream of the logic you would want an automated system to perform if you had the resources to scan data on thousands of stocks in real time. Something you wouldn't possibly be able to do manually. That's where the value is.
 
Does your algo use any fundamentals, or is it exclusively momentum?
 
Does your algo use any fundamentals, or is it exclusively momentum?


As part of the screening process to get the universe of stocks I feed in to the system (which I do maybe once every few months), I do query on some fundamentals. However, at run time it is solely focusing on technicals/momentum - RSI/MACD.
 
Kudos to you, njhowie! What you did sounds like fun and some hard work!

I'm too old, slow and not a programmer to do anything like this, but wish I could!

Cheers! :cool:
 
Yikes! My first reaction was Howie’s been hacked!

Seriously it sounds fascinating but I could barely follow the action as observer.
 
Last edited:
Yikes! My first reaction was Howie’s been hacked!


LOL! You know how conservative I am, so I could see how you'd come to that conclusion. But it's also indicative that you can do this in a low risk fashion.
 
Is there a book or some other source that one could study to get an idea about how to go about designing something? I could code it, but I wouldn't know where to start from a concept point of view.
 
Very interesting.


Are you doing this in a taxable account, or can you do this in a tax-deferred account?
 
Is there a book or some other source that one could study to get an idea about how to go about designing something? I could code it, but I wouldn't know where to start from a concept point of view.

If you're looking for books, I would start here:
https://www.google.com/search?q=algorithmic+trading+books

I have not personally used any of them, so can't make a good recommendation. You can also find a fair number of Youtube instructional videos and forums discussing the APIs and how to put together a sample application using it. Play with google and querying with different search terms, you'll find them.

My background was boots on the ground with this stuff, so designing something came naturally.
 
Very interesting.


Are you doing this in a taxable account, or can you do this in a tax-deferred account?


Taxable account...2020 was a learning experience in how to do taxes when you have enough transactions that you crash Turbotax.

I don't believe there's any reason why you wouldn't be able to do it with a tax-deferred account.
 
My background was boots on the ground with this stuff, so designing something came naturally.
Ah, there you go! I'm sure if I designed something, being a total noob, it would effectively be putting money from my account into your account, lol! But it's cool that you can leverage your work experience. My work experience is with coding in the manufacturing / logistics as opposed to finance. My hobby coding is to optimize beer delivery and beer drinking! Just added a feature so that the server can bring you a specific beer without you having to even ask for it.
 
This could be a lot of fun. I might have to give it a shot with a small amount and see what happens.

How bad was tax filing for this account?

One reason I stopped with Robinhood was because they didn’t support tax deferred/exempt accounts and it seemed counterproductive to pay taxes while taking on a lot of risk. And I didn’t want to deal with the paperwork.

If I decide to try this, I’m going to see if I can use a roth.
 
This could be a lot of fun. I might have to give it a shot with a small amount and see what happens.

How bad was tax filing for this account?

One reason I stopped with Robinhood was because they didn’t support tax deferred/exempt accounts and it seemed counterproductive to pay taxes while taking on a lot of risk. And I didn’t want to deal with the paperwork.

If I decide to try this, I’m going to see if I can use a roth.


If you can do it with Roth, then there obviously wouldn't be any tax reporting - easy peasy.

The tax filing wasn't bad at all after I learned how to do it (after Turbotax crashed during download with a message that it wasn't designed to do that many transactions). Though there may be thousands of trades, you can net them all together and put on a single line (one for long term gain/loss and another for short term gain/loss) - so long as there aren't any with special attributes (e.g. wash sale or K-1 reporting) - you can pull it right from the bottom line of your 1099 from the brokerage. For those that do have special attributes you have to individually split those out and report each on its own line, and then net everything else. If you have so many with special attributes that you don't want to even do those individually, you can just net everything together on one line, and then mail a report in your own format which identifies each of the individual transactions and the fields they require (could even be the 1099 from the brokerage) to a special IRS document warehouse address in Austin, TX.
 
This looks like fun. I have the accounts and cash to get started, and I write code all day at w*rk, often against REST APIs. Any chance you'd open-source your algo howie? lol
 
This looks like fun. I have the accounts and cash to get started, and I write code all day at w*rk, often against REST APIs. Any chance you'd open-source your algo howie? lol


It sounds like you'll come up to speed quickly and do just fine Henry...I put a good amount of effort in to what I created, and not really enthusiastic about simply giving it away. There are lots or resources available online as far as algorithms you can simply replicate, sample code, wrapper APIs, and video tutorials.
 
Interesting thread.

As someone with a lifetime in software I've been coding my own strategies using C# in a platform called NinjaTrader (somewhat silly name but it is a good piece of software, and the free version offers plenty of functionality).

Using the trading platform APIs would work just as well I'm sure.

Mainly focus on swing trading meaning a few days rather than intraday but that is just a flavor.

Keeps me amused during retirement, and sometimes makes me $.
 
Very interesting.
Are you doing this in a taxable account, or can you do this in a tax-deferred account?

Some brokers (such as TDA) offer a limited margin IRA trading account, which works well because it skips the settlement delay, but to comply with IRA regulations it does not allow one to actually go on margin.
 
If you can do it with Roth, then there obviously wouldn't be any tax reporting - easy peasy.

The tax filing wasn't bad at all after I learned how to do it (after Turbotax crashed during download with a message that it wasn't designed to do that many transactions). Though there may be thousands of trades, you can net them all together and put on a single line (one for long term gain/loss and another for short term gain/loss) - so long as there aren't any with special attributes (e.g. wash sale or K-1 reporting) - you can pull it right from the bottom line of your 1099 from the brokerage. ....

I wish I knew that back when I was actively trading! Here's one ref for it:

https://www.hrblock.com/tax-center/income/investments/reporting-multiple-stock-trades-on-schedule-d/

You can aggregate all short-term and all long-term covered transactions and report them as single-line entries directly on Schedule D. A covered transaction is one where your broker provided a 1099-B Form to the IRS that:

Show acquisition date and basis
Don’t require any adjustments or codes

-ERD50
 
Back
Top Bottom