Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

darthtrader2.0

Algorithmic Trading with MATLAB Webinar

Recommended Posts

I just watched this yesterday:

http://www.mathworks.com/company/events/webinars/wbnr30376.html?id=30376&p1=50647&p2=50649

 

I was always curious as to why someone would use Matlab over a more specific trading software but after watching that video I have to say I'm completely floored. They use a simple moving average system as an example and the visualization tools are light years beyond anything else I've ever seen.

The one backtest shows this color coded 3d plot of how the different MA parameters effect a sharpe ratio...just amazing.

The only downside I can see with matlab is the price of the software and the datafeeds that connect to it are somewhat limited to the higher end of things(reuters, bloomberg).

note:you do have to fill out a brief questionaire, it would probly be worth it to just create an account at the site as they have a few other webinars for finance that look pretty interesting.

Share this post


Link to post
Share on other sites

I found this too

http://www.matlabtrader.com/

 

It has stuff to get matlab hooked up to interactive brokers.

Note the full matlab version is $5000 with the toolboxes you would want. The student version is 99 bucks. Pretty sweet deal to get your feet wet it would seem.

 

Here is the datafeed toolbox, pretty lame that it jumps from yahoo to bloomberg, lol.

http://www.mathworks.com/products/datafeed/description3.html

 

anyone ever mess with the esignal or dtn API?

Share this post


Link to post
Share on other sites
  darthtrader2.0 said:
The only downside I can see with matlab is the price of the software and the datafeeds that connect to it are somewhat limited to the higher end of things(reuters, bloomberg).
If your current data feed can output live to excel then you should have no problem. Matlab can grab data quickly and efficiently from an opened (via DDE/ActiveX) or saved excel file. It takes literally just a few lines of code to check, grab, and add new data from excel to a database. Of course there are other ways to accomplish the same task. The price is pretty steep unless A) You are a student or B) You have a decent income.

 

For awhile now I have done all my back testing and system building in Matlab. However, just recently I have started transferring all my charting over to it. It wasn't my original plan, but at the moment it seems to be the best (only time will tell). My current plan is to be fully charted with Matlab by the fall.

Share this post


Link to post
Share on other sites

Ahh great info Hlm.

Could you describe your setup and process in more detail?

Do you analize and store tick data? If you are storing things what DB are you using?

Do you use multiple strategies? Thats one thing that seems nice with matlab and absurd that so much retail autotraders can't handle more than one strategy at once.

Share this post


Link to post
Share on other sites
  darthtrader2.0 said:
Could you describe your setup and process in more detail?
Well, it depends on what you are looking for in your charting software. Retail charting platforms are great for when you are first learning and want to look around and experiment. Once you figure out and decide on what exactly you need to become consistently profitable, you should carry those over to the new platform. Of course I mean for only those that want/need such an environment (not for everyone). Since I am still in the process of moving completely over to Matlab, I am still using SierraChart to take care of my data storage. In SierraChart there is a study called "Worksheet Study/System/Alert" where it uses DDE to constantly update an open Excel file with x amount of data (drops last bar when new one added). If you want multiple time frames you just add the study to another chart with the same Workbook name and it will automatically place it in the second Sheet. This is nice since only one Excel file has to be open.

 

Sample Excel Data from SierraChart...

ESU8  144 tick - #1                        
Date Time        Open        High        Low          Last          Volume  #of Trades
39640.67705    1239.75    1239.75    1239.50    1239.75    625      56
39640.67689    1239.75    1240.00    1239.50    1239.75    1965    144
39640.67662    1239.50    1240.00    1239.50    1240.00    2849    144
39640.67626    1240.00    1240.25    1239.50    1239.50    2106    144
39640.67601    1240.00    1240.25    1239.50    1240.00    2398    144
39640.67572    1240.75    1241.00    1240.00    1240.00    2873    144

At which point you can grab in Matlab with...

ExcelFile = ddeinit('excel','c:\data.xls:Sheet1');
ExcelData = ddereq(ExcelFile, 'r4c1:r8c7'); 
%started with r4 because r3 isn't completed yet

To check for new data you could do something like...

CurrentTime = ddereq(ExcelFile, 'r4c1');
if CurrentTime ~= LastTime
i=1;
   while(CurrentTime ~= LastTime)
       NewData = ddereq(ExcelFile, ['r4c1:r' num2str(i+4) 'c7']);
       CurrentTime = NewData(end,1);
       i = size(NewData, 1);
   end
LastTime = NewData(1,1);
OldData = vertcat(NewData(1:end-1,, OldData); %adds new data

Note: I'm currently not on my Matlab workstation so code above is just a quick example and not necessarily efficient or error free. :)

 

One can also grab from Excel using ActiveX if you don't want to use DDE. Everything is well documented on their site.

 

  darthtrader2.0 said:
Do you analize and store tick data? If you are storing things what DB are you using?
That is one of my summer projects I am currently working on. I will be using MySQL. The great thing about Matlab is that there is an abundance of information on their site under the Newsgroup and File Exchange sections.

 

  darthtrader2.0 said:
Do you use multiple strategies? Thats one thing that seems nice with matlab and absurd that so much retail autotraders can't handle more than one strategy at once.
I am currently automating one strategy that has multiple filtering and analysis steps. Being able to have full control of how data is analyzed and manipulated without boundaries is a big reason why I started using Matlab. Edited by Hlm
Specified that I am currently working on one automated strategy.

Share this post


Link to post
Share on other sites
  darthtrader2.0 said:

Do you use multiple strategies? Thats one thing that seems nice with matlab and absurd that so much retail autotraders can't handle more than one strategy at once.

 

Hello,

 

Thanks for posting this webinar link, I'll be watching it tonight after the market. With regard to multiple strategies, you might be looking at the wrong software. Neoticker can do this just fine and has been able to for a long time (forever??).

 

Thanks again.

 

All my best,

MK

Share this post


Link to post
Share on other sites

Thanks Hlm, great info. I will have to try to get the DDE stuff going with dtn and see how that works, should be a nice learning experience in and of itself.

For database stuff have you ever checked out HDF5? I know thats some heavy duty stuff for large files and matlab can interface directly with it:

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/hdf5.html

I read on one of the quant boards about a guy who mentioned he was mining around 1 terrabyte datasets with it. My only concern with Mysql is that things might get overwhelming size wise rather quickly if i want to store tick data across multiple instruments. My interest here is in a very long term project for high frequency stuff that will take years to get sorted out. HDF5 might be total over kill though, i don't know.

MidKnight, I kind of figured neoticker could do multiple strategies...I guess I've really never read something where neoticker couldn't do "X". There is just something about the program that bugs me though, this visual basic program for win95 feel to it.

Share this post


Link to post
Share on other sites

I've been doing a little analysis in Mathematica, but after asking some people who know their stuff, I'm going to try out Matlab. It seems easier to get moving, and Matlab seems to deal with data better. Wish me luck.

Share this post


Link to post
Share on other sites
  darthtrader2.0 said:
For database stuff have you ever checked out HDF5? I know thats some heavy duty stuff for large files and matlab can interface directly with it:

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/hdf5.html

I read on one of the quant boards about a guy who mentioned he was mining around 1 terrabyte datasets with it. My only concern with Mysql is that things might get overwhelming size wise rather quickly if i want to store tick data across multiple instruments. My interest here is in a very long term project for high frequency stuff that will take years to get sorted out.

The main reason why MySQL is being used is because I am very familiar with it and my programming friend and I have been using it with other projects for years. MySQL can work with a lot of data if done correctly, but if you are looking at storing years of raw tick/volume data without splitting up files it may be beneficial to go with hdf5. To be honest I don't know much about hdf5. I guess I will add that research to my todo list. :)

Share this post


Link to post
Share on other sites
  Hlm said:
but if you are looking at storing years of raw tick/volume data without splitting up files it may be beneficial to go with hdf5.

 

Well I should say I know virtually nothing about database design and what not.

Is that the whole issue with SQL vs a time series database, single file/table size? While I could see the problems that would arrise if you dumped years of tick data into a single table that would obviously be a really dumb way to go about things considering that with financial time series we have the benefit of sectioning things off by the day.

I'll have to try MySql out, I soppose the big advantage would be the learning material available. Maybe at some point we can try a database design thread on here.

Share this post


Link to post
Share on other sites
  darthtrader2.0 said:
Well I should say I know virtually nothing about database design and what not.

Is that the whole issue with SQL vs a time series database, single file/table size? While I could see the problems that would arrise if you dumped years of tick data into a single table that would obviously be a really dumb way to go about things considering that with financial time series we have the benefit of sectioning things off by the day.

I'll have to try MySql out, I soppose the big advantage would be the learning material available. Maybe at some point we can try a database design thread on here.

Yes, much of it depends on how you decide to organize data for your needs be it within the database itself or having separate files.

Share this post


Link to post
Share on other sites

I'm thinking about making a mysql database with live data for this type of analysis. I'd like to get a few years of 1m in a table, and then a week or so of tick data.

 

Does anyone know of a good, reliable way to get data into a mysql database real time?

Share this post


Link to post
Share on other sites
  atto said:

Does anyone know of a good, reliable way to get data into a mysql database real time?

 

Assuming you want to stay away from your datafeeds API, you might be able to get this going if your datafeed can do DDE and assuming matlab can write to mysql, then you could probly do something like what Hlm posted above.

 

I think the bigger question though is if you need to access the database to trade live or just to backtest ideas. If just for backtesting the easiest thing to do might just be to spit out text files of the data from ninja, then parse the text with python or something and shove it into the database at the end of the day. I would think that would be pretty simple to figure out. From searching around this morning I think thats what I'm going to start off with. The more complex issues of datafeed -> database -> matlab -> trade signal/order, well I'll cross that bridge when I come to it.

Share this post


Link to post
Share on other sites

Yeah, I was more interested in live data. If I feel I really need it, I could write a C++ wrapper that takes a live feed and puts it into mysql, tick by tick. EOD I can handle just fine.

Share this post


Link to post
Share on other sites
  atto said:
I'm thinking about making a mysql database with live data for this type of analysis. I'd like to get a few years of 1m in a table, and then a week or so of tick data.

 

Does anyone know of a good, reliable way to get data into a mysql database real time?

 

Hi Atto,

 

I know of one neoticker user who wrote their own datasource (you can do that with the neoticker) so that his datafeed will slot write into SQL server as well as his charts. Of course, he isn't releasing it....but I mention it just as a point of one tool where things like this are quite possible. His name is Michale Kreslik (spelling?).

 

All my best,

MK

Share this post


Link to post
Share on other sites
  MidKnight said:
Hi Atto,

 

I know of one neoticker user who wrote their own datasource (you can do that with the neoticker) so that his datafeed will slot write into SQL server as well as his charts. Of course, he isn't releasing it....but I mention it just as a point of one tool where things like this are quite possible. His name is Michale Kreslik (spelling?).

 

All my best,

MK

http://kreslik.com/forums/viewtopic.php?start=0&t=357

  Quote
My "SQL history engine" MS SQL Server 2005 database create script is attached below.

 

Currenty it features 255 million+ ticks for 16 FX pairs over the last 7 years and the database size is nearly 100GBs with all the indexes.

 

I'm feeding this carefully sifted and clean data to my NeoTicker and I'm also using it as a data source for running various statistics, written in C#.

 

Michal

Share this post


Link to post
Share on other sites
Guest Tresor

Hello Hlm,

 

What would be the hardware requirements for using Matlab for strategy creating, (ii) optimizing (iii) running live charting, (iv) trading signals, etc?

 

There were several components mentioned (e.g. simulink) in the webinar: which components did you purchase or belive are optimal to purchase?

 

Regards

Share this post


Link to post
Share on other sites
  Tresor said:
What would be the hardware requirements for using Matlab for strategy creating, (ii) optimizing (iii) running live charting, (iv) trading signals, etc?
Hardware requirements pretty much depend on the type of analysis you will be doing and if it's time critical or not. Matlab itself does not require much (actual requirements HERE). It shouldn't need more than any other charting software. By nature you may be doing more advanced calculations across a larger amount of data, which then the amount of time required to accomplish a task will be directly related to your processing power. Also, it depends on how your program within Matlab. If you use standard loops instead of vectors it may go slower unless compiled.

 

  Tresor said:
There were several components mentioned (e.g. simulink) in the webinar: which components did you purchase or belive are optimal to purchase?
This is an interesting topic that I have had with several people. It's just like my feeling towards using indicators...find out exactly what information you need, and then look for the indicator that gives you that information. And many times you can't find exactly what you want so you have to build your own. The same can be said with toolboxes. I do own a few of them, but with my current project I am not using any of them. You have to imagine that they would mention as many as they could in the webinar since that's their business. I would figure out what you specifically need and then search the newsgroup and file exchange for answers. However, if you want to know a couple of the popular ones, I would say the Optimization and Statistics Toolbox.

 

I hope that helps some.

Edited by Hlm
Added actual requirements link.

Share this post


Link to post
Share on other sites
Guest Tresor

Hlm,

 

There were two indicators mentioned in the webinar: MAs and RSI. How many indicators are there prebuilt-in Matlab. Would you mind posting a list of them? Or is it the case that there are no prebuilt-in indicators and one has to program them oneself?

 

Regards

Share this post


Link to post
Share on other sites
  Tresor said:
There were two indicators mentioned in the webinar: MAs and RSI. How many indicators are there prebuilt-in Matlab. Would you mind posting a list of them? Or is it the case that there are no prebuilt-in indicators and one has to program them oneself?
If you are looking for a quick way to mimic your current charting platform, the Financial Toolbox would be a good start. However, it requires the Optimization and Statistics Toolbox. This toolox has many indicators and also simplifies the charting process. Again one must just read through the product list and look at the specifics of the toolboxes of interest. I would urge anyone to first make a list of required items and then do the research to find the ways that they can be obtained.

Share this post


Link to post
Share on other sites
Guest Tresor

There seems to be only a few indicators.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • Thx for reminding us... I don't bang that drum often enough anymore Another part for consideration is who that money initially went to...
    • TDUP ThredUp stock, watch for a top of range breakout above 2.94 at https://stockconsultant.com/?TDUP
    • How long does it take to receive HFM's withdrawal via Skrill? less than 24H?
    • My wife Robin just wanted some groceries.   Simple enough.   She parked the car for fifteen minutes, and returned to find a huge scratch on the side.   Someone keyed her car.   To be clear, this isn’t just any car.   It’s a Cybertruck—Elon Musk's stainless-steel spaceship on wheels. She bought it back in 2021, before Musk became everyone's favorite villain or savior.   Someone saw it parked in a grocery lot and felt compelled to carve their hatred directly into the metal.   That's what happens when you stand out.   Nobody keys a beige minivan.   When you're polarizing, you're impossible to ignore. But the irony is: the more attention something has, the harder it is to find the truth about it.   What’s Elon Musk really thinking? What are his plans? What will happen with DOGE? Is he deserving of all of this adoration and hate? Hard to say.   Ideas work the same way.   Take tariffs, for example.   Tariffs have become the Cybertrucks of economic policy. People either love them or hate them. Even if they don’t understand what they are and how they work. (Most don’t.)   That’s why, in my latest podcast (link below), I wanted to explore the “in-between” truth about tariffs.   And like Cybertrucks, I guess my thoughts on tariffs are polarizing.   Greg Gutfield mentioned me on Fox News. Harvard professors hate me now. (I wonder if they also key Cybertrucks?)   But before I show you what I think about tariffs… I have to mention something.   We’re Headed to Austin, Texas This weekend, my team and I are headed to Austin. By now, you should probably know why.   Yes, SXSW is happening. But my team and I are doing something I think is even better.   We’re putting on a FREE event on “Tech’s Turning Point.”   AI, quantum, biotech, crypto, and more—it’s all on the table.   Just now, we posted a special webpage with the agenda.   Click here to check it out and add it to your calendar.   The Truth About Tariffs People love to panic about tariffs causing inflation.   They wave around the ghost of the Smoot-Hawley Tariff from the Great Depression like it’s Exhibit A proving tariffs equal economic collapse.   But let me pop this myth:   Tariffs don’t cause inflation. And no, I'm not crazy (despite what angry professors from Harvard or Stanford might tweet at me).   Here's the deal.   Inflation isn’t when just a couple of things become pricier. It’s when your entire shopping basket—eggs, shirts, Netflix subscriptions, bananas, everything—starts costing more because your money’s worth less.   Inflation means your dollars aren’t stretching as far as they used to.   Take the 1800s.   For nearly a century, 97% of America’s revenue came from tariffs. Income tax? Didn’t exist. And guess what inflation was? Basically zero. Maybe 1% a year.   The economy was booming, and tariffs funded nearly everything. So, why do people suddenly think tariffs cause inflation today?   Tariffs are taxes on imports, yes, but prices are set by supply and demand—not tariffs.   Let me give you a simple example.   Imagine fancy potato chips from Canada cost $10, and a 20% tariff pushes that to $12. Everyone panics—prices rose! Inflation!   Nope.   If I only have $100 to spend and the price of my favorite chips goes up, I either stop buying chips or I buy, say, fewer newspapers.   If everyone stops buying newspapers because they’re overspending on chips, newspapers lower their prices or go out of business.   Overall spending stays the same, and inflation doesn’t budge.   Three quick scenarios:   We buy pricier chips, but fewer other things: Inflation unchanged. Manufacturers shift to the U.S. to avoid tariffs: Inflation unchanged (and more jobs here). We stop buying fancy chips: Prices drop again. Inflation? Still unchanged. The only thing that actually causes inflation is printing money.   Between 2020 and 2022 alone, 40% of all money ever created in history appeared overnight.   That’s why inflation shot up afterward—not because of tariffs.   Back to tariffs today.   Still No Inflation Unlike the infamous Smoot-Hawley blanket tariff (imagine Oprah handing out tariffs: "You get a tariff, and you get a tariff!"), today's tariffs are strategic.   Trump slapped tariffs on chips from Taiwan because we shouldn’t rely on a single foreign supplier for vital tech components—especially if that supplier might get invaded.   Now Taiwan Semiconductor is investing $100 billion in American manufacturing.   Strategic win, no inflation.   Then there’s Canada and Mexico—our friendly neighbors with weirdly huge tariffs on things like milk and butter (299% tariff on butter—really, Canada?).   Trump’s not blanketing everything with tariffs; he’s pressuring trade partners to lower theirs.   If they do, everybody wins. If they don’t, well, then we have a strategic trade chess game—but still no inflation.   In short, tariffs are about strategy, security, and fairness—not inflation.   Yes, blanket tariffs from the Great Depression era were dumb. Obviously. Today's targeted tariffs? Smart.   Listen to the whole podcast to hear why I think this.   And by the way, if you see a Cybertruck, don’t key it. Robin doesn’t care about your politics; she just likes her weird truck.   Maybe read a good book, relax, and leave cars alone.   (And yes, nobody keys Volkswagens, even though they were basically created by Hitler. Strange world we live in.) Source: https://altucherconfidential.com/posts/the-truth-about-tariffs-busting-the-inflation-myth    Profits from free accurate cryptos signals: https://www.predictmag.com/       
    • No, not if you are comparing apples to apples. What we call “poor” is obviously a pretty high bar but if you’re talking about like a total homeless shambling skexie in like San Fran then, no. The U.S.A. in not particularly kind to you. It is not an abuse so much as it is a sad relatively minor consequence of our optimism and industriousness.   What you consider rich changes with circumstances obviously. If you are genuinely poor in the U.S.A., you experience a quirky hodgepodge of unhelpful and/or abstract extreme lavishnesses while also being alienated from your social support network. It’s about the same as being a refugee. For a fraction of the ‘kindness’ available to you in non bio-available form, you could have simply stayed closer to your people and been MUCH better off.   It’s just a quirk of how we run the place and our values; we are more worried about interfering with people’s liberty and natural inclination to do for themselves than we are about no bums left behind. It is a slightly hurtful position and we know it; we are just scared to death of socialism cancer and we’re willing to put our money where our mouth is.   So, if you’re a bum; you got 5G, the ER will spend like $1,000,000 on you over a hangnail but then kick you out as soon as you’re “stabilized”, the logistics are surpremely efficient, you have total unchecked freedom of speech, real-estate, motels, and jobs are all natural healthy markets in perfect competition, you got compulsory three ‘R’’s, your military owns the sky, sea, space, night, information-space, and has the best hairdos, you can fill out paper and get all the stuff up to and including a Ph.D. Pretty much everything a very generous, eager, flawless go-getter with five minutes to spare would think you might need.   It’s worse. Our whole society is competitive and we do NOT value or make any kumbaya exception. The last kumbaya types we had werr the Shakers and they literally went extinct. Pueblo peoples are still around but they kind of don’t count since they were here before us. So basically, if you’re poor in the U.S.A., you are automatically a loser and a deadbeat too. You will be treated as such by anybody not specifically either paid to deal with you or shysters selling bejesus, Amway, and drugs. Plus, it ain’t safe out there. Not everybody uses muhfreedoms to lift their truck, people be thugging and bums are very vulnerable here. The history of a large mobile workforce means nobody has a village to go home to. Source: https://askdaddy.quora.com/Are-the-poor-people-in-the-United-States-the-richest-poor-people-in-the-world-6   Profits from free accurate cryptos signals: https://www.predictmag.com/ 
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.