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
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
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.

 

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.

 

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

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
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
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
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

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
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
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

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
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.

 

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
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

    • Date: 7th April 2025.   Asian Markets Plunge as US-China Trade War Escalates; Wall Street Futures Signal Further Turmoil.   Global financial markets extended last week’s massive sell-off as tensions between the US and its major trading partners deepened, rattling investors and prompting sharp declines across equities, commodities, and currencies. The fallout from President Trump’s sweeping new tariff measures continued to spread, raising fears of a full-blown trade war and economic recession.   Asian stock markets plunged on Monday, extending a global market rout fueled by rising tensions between the US and China. The latest wave of aggressive tariffs and retaliatory measures has unnerved investors worldwide, triggering sharp sell-offs across the Asia-Pacific region.   Asian equities led the global rout on Monday, with dramatic losses seen across the region. Japan’s Nikkei 225 index tumbled more than 8% shortly after the open, while the broader Topix fell over 6.5%, recovering only slightly from steeper losses. In mainland China, the Shanghai Composite sank 6.7%, and the blue-chip CSI300 dropped 7.5% as markets reopened following a public holiday. Hong Kong’s Hang Seng Index opened more than 9% lower, reflecting deep concerns about escalating trade tensions.           South Korea’s Kospi dropped 4.8%, triggering a circuit breaker designed to curb panic selling. Taiwan’s Taiex index collapsed by nearly 10%, with major tech exporters like TSMC and Foxconn hitting circuit breaker limits after each fell close to 10%. Meanwhile, Australia’s ASX 200 shed as much as 6.3%, and New Zealand’s NZX 50 lost over 3.5%.   Despite the escalation, Beijing has adopted a measured tone. Chinese officials urged investors not to panic and assured markets that the country has the tools to mitigate economic shocks. At the same time, they left the door open for renewed trade talks, though no specific timeline has been set.   US Stock Futures Plunge Ahead of Monday Open   US stock futures pointed to another brutal day on Wall Street. Futures tied to the S&P 500 dropped over 3%, Nasdaq futures sank 4%, and Dow Jones futures lost 2.5%—equivalent to nearly 1,000 points. The Nasdaq Composite officially entered a bear market on Friday, down more than 20% from its recent highs, while the S&P 500 is nearing bear territory. The Dow closed last week in correction. Oil prices followed suit, with WTI crude dropping over 4% to $59.49 per barrel—its lowest since April 2021.   Wall Street closed last week in disarray, erasing more than $5 trillion in value amid fears of an all-out trade war. The Nasdaq Composite officially entered a bear market on Friday, sinking more than 20% from its recent peak. The S&P 500 is approaching bear territory, and the Dow Jones Industrial Average has slipped firmly into correction territory.   German Banks Hit Hard Amid Escalating Trade Tensions   German banking stocks were among the worst hit in Europe. Shares of Commerzbank and Deutsche Bank plunged between 9.5% and 10.3% during early Frankfurt trading, compounding Friday’s steep losses. Fears over a global trade war and looming recession are severely impacting the financial sector, particularly export-driven economies like Germany.   Eurozone Growth at Risk   Eurozone officials are bracing for economic fallout, with Greek central bank governor Yannis Stournaras warning that Trump’s tariff policy could reduce eurozone GDP by up to 1%. The EU is preparing retaliatory tariffs on $28 billion worth of American goods—ranging from steel and aluminium to consumer products like dental floss and luxury jewellery.   Starting Wednesday, the US is expected to impose 25% tariffs on key EU exports, with Brussels ready to respond with its own 20% levies on nearly all remaining American imports.   UK Faces £22 Billion Economic Blow   In the UK, fresh research from KPMG revealed that the British economy could shrink by £21.6 billion by 2027 due to US-imposed tariffs. The analysis points to a 0.8% dip in economic output over the next two years, undermining Chancellor Rachel Reeves’ growth agenda. The report also warned of additional fiscal pressure that may lead to future tax increases and public spending cuts.   Wall Street Braces for Recession   Goldman Sachs revised its US recession probability to 45% within the next year, citing tighter financial conditions and rising policy uncertainty. This marks a sharp jump from the 35% risk estimated just last month—and more than double January’s 20% projection. J.P. Morgan issued a bleaker outlook, now forecasting a 60% chance of recession both in the US and globally.   Global Leaders Respond as Trade Tensions Deepen   The dramatic market sell-off was triggered by China’s sweeping retaliation to a new round of US tariffs, which included a 34% levy on all American imports. Beijing’s state-run People’s Daily released a defiant statement, asserting that China has the tools and resilience to withstand economic pressure from Washington. ‘We’ve built up experience after years of trade conflict and are prepared with a full arsenal of countermeasures,’ it stated.   Around the world, policymakers are responding to the growing threat of a trade-led economic slowdown. Japanese Prime Minister Shigeru Ishiba announced plans to appeal directly to Washington and push for tariff relief, following the US administration’s decision to impose a blanket 24% tariff on Japanese imports. He aims to visit the US soon to present Japan’s case as a fair trade partner.   In Taiwan, President Lai Ching-te said his administration would work closely with Washington to remove trade barriers and increase purchases of American goods in an effort to reduce the bilateral trade deficit. The island's defence ministry has also submitted a new list of US military procurements to highlight its strategic partnership.   Economists and strategists are warning of deeper economic consequences. Ronald Temple, chief market strategist at Lazard, said the scale and speed of these tariffs could result in far more severe damage than previously anticipated. ‘This isn’t just a bilateral conflict anymore — more countries are likely to respond in the coming weeks,’ he noted.   Analysts at Barclays cautioned that smaller Asian economies, such as Singapore and South Korea, may face challenges in negotiating with Washington and are already adjusting their economic growth forecasts downward in response to the unfolding trade crisis.           Oil Prices Sink on Demand Concerns   Crude oil continued its sharp slide on Monday, driven by recession fears and weakened global demand. Brent fell 3.9% to $63.04 a barrel, while WTI plunged over 4% to $59.49—both benchmarks marking weekly losses exceeding 10%. Analysts say inflationary pressures and slowing economic activity may drag demand down, even though energy imports were excluded from the latest round of tariffs.   Vandana Hari of Vanda Insights noted, ‘The market is struggling to find a bottom. Until there’s a clear signal from Trump that calms recession fears, crude prices will remain under pressure.’   OPEC+ Adds Further Pressure with Output Hike   Bearish sentiment intensified after OPEC+ announced it would boost production by 411,000 barrels per day in May, far surpassing the expected 135,000 bpd. The alliance called on overproducing nations to submit compensation plans by April 15. Analysts fear this surprise move could undo years of supply discipline and weigh further on already fragile oil markets.   Global political risks also flared over the weekend. Iran rejected US proposals for direct nuclear negotiations and warned of potential military action. Meanwhile, Russia claimed fresh territorial gains in Ukraine’s Sumy region and ramped up attacks on surrounding areas—further darkening the outlook for markets.   Always trade with strict risk management. Your capital is the single most important aspect of your trading business.   Please note that times displayed based on local time zone and are from time of writing this report.   Click HERE to access the full HFM Economic calendar.   Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE!   Click HERE to READ more Market news.   Andria Pichidi HFMarkets   Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in Leveraged Products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • AMZN Amazon stock watch, good buying (+313%) toi hold onto the 173.32 support area at https://stockconsultant.com/?AMZN
    • META stock watch, local support and resistance areas at 507.48, 557.84 at https://stockconsultant.com/?META
    • TMUS T-Mobile stock, watch for a top of range breakout at https://stockconsultant.com/?TMUS
    • KULR KULR Technology stock watch, pullback to 1.25 triple support area with bullish indicators at https://stockconsultant.com/?KULR
×
×
  • Create New...

Important Information

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