Using R in real time financial market trading

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everyone my name is Ellen as well so I'm going to be talking to you today about how I use our in trading markets so another been a in the last few months has been a few meetups where people have pitched products and I sort of let you know that I'm not teaching anything I'm not trying to sell you anything just kind of back to basics just letting you know how I do things a few people have asked what this t-shirt is about it's um I'm actually the the chief executive of a company called Autochartist a small unknown group it's actually based out of Johannesburg South Africa um myself and my colleague Jing Mei who's sitting at the back or soon as we insured we just here in Austin with the rest of the companies in South Africa we we do we sell a product for retail traders that tries to forecast the market for retail traders it has nothing to do with what we're talking about today I'll just wear the t-shirt so it is what it is if any of you want to get in touch with me after the meetup we don't have a chance to ask me questions about how I do things I let my business card but again this is not a work-related thing this is just my experience there's many of you which are I think of maybe a lot more broad knowledge about time series forecasting that I do again I'm I have a certain level of expertise my expertise certainly lies I'll guess more in financial markets rather than answer is forecasting but the two go hand in hand for me and I'll just try to show you what we do I'm the chief objective okay there we go all right is that okay slightly all right so just a show of hands as has anybody ever traded traded maybe actually who hasn't traded ah that's that's going to be that's going to say alright okay and and you'll try the traders do trade stocks or futures of fire so okay stocks who trade stocks ah okay in futures Forex or in currencies no one okay cool alright so I only trade foreign currencies interesting enough and and the the reason why I actually trade foreign currencies is because I find it to be manageable set of instruments when I moved to the US about just under three years ago and and I look at the available amount of instruments that are on the unlit a the New York Stock Exchange or Nasdaq or Amex it's for somebody who comes from a country where I think there's about twenty or forty liquid instruments to a country where is like two thousand liquid instruments for me I haven't wrapped my mind yet around taking all that data and actually crunching it doing way will will attest to the fact that I'm quite thoughtful and I try to do things from start to end I am so taking on a massive data mining project like the New York Stock Exchange for example for me is right now is it's something I can't I can't do in my life right now so so we're not when I look at when I look at trading and the reason I chose affects is because it creates you know there's let's say I'm seven or eight arguably eight currency pairs that that really perform about 97 98 percent of the world's currency trade and so when you're starting to analyze seven or eight instruments it becomes a lot more computationally feasible to start analyzing the stuff although the the the converse to that is that you'll find that most they're almost because there's so much liquidity and so much trade within focus within those specific instruments you find that the that the the movement of those instruments is actually pretty much as close to random as you can as you can get so so to find anomalies is extremely difficult and and furthermore because foreign currency or what they call an OTC instrument over-the-counter instrument you can't friend around really so so so let you save an example of what an OTC instrument is and it's important to understand this is is that I can walk up to someone say hey I've got ten pounds in my pocket I'll give you ten pounds you give me fifteen dollars back right I don't have to go and give my ten pounds to an exchange somewhere and then my counterpart gives it to exchange right there's no exchange in the middle um foreign currencies by their very nature are what they call over-the-counter instruments it's an unregulated exchange right which means that you don't sometimes you don't even know who your counterparty to your trade is right so it's not all about execution and latency like you get a you know a lot of these there's some books lately you know flash traders and all the stuff that's been written lately about people front-running trades and you know getting you know a millisecond faster onto the exchange than somebody else in an OTC market that that kind of thing plays plays less of a role so that also creates an interesting dynamic um so for those of you that have never traded before what you see in front of you is really a a chart of I chose euro dollar and that's the example I'm going to be working on today you're a dollar the little chart on the left is just a snapshot I took from here in finance of the day's trade accurate dollar and and I guess the next slide I just want to talk about you know just some terminology so the people that have never traded before understand what I'm talking about so that's who you who have traded just bear with me for like five minutes until I bring everyone up to the same level so so in financial markets if you look at let's say every every trade that's happened on the marketing and you see the real chance on the left and that little trade just for a few hours has you know and literally had tens of thousands if not hundreds of thousands of trades and so um sometimes it's difficult to visualize and to understand you know to compute such a massive amount of data and so what people in the in the financial world have done correctly or incorrectly it's convenient it's a question of convenience is created this concept of what they call a candle which is really a a summary of a whole bunch of movement right so so if you look at the at the at the picture on the left hand side that is that is a candle and that what it basically depict is a range of movement within a certain period of time okay so let me walk up to that candle actually and show you what I mean so so open is where this candles are that that was the first trade that happened or that or time close is where the last trade happen for a period of time and then there's a high and is allotted a shadow or lower shadow or the up away from the lower wick and so this creates like this can looks like a candle and so importantly is like people have created these green candles and red handles inch pits and a blue movement within certain period plan for movement and circuit paths but really the way to look at these things it's just a a tool for visualization and in a way to to summarize to summarize data so that's one piece of terminology that you that you need to kind of be aware of and I want to spend too much time I hope kind of everyone got the basic gist of what I was trying to say in the next thing is two different types of trading which is trading lung and trading short now trading long is what we all conceivably understand it's it's we buy low and we sell high right we buy a stock for add back and we sell it for a back ten and we've made 10% on our on our money okay so that's that's great that's an easy one so does anyone want to stand up and volunteer to explain how you trade short okay so so so so so let's say this gentleman over here so what is your name Peter Peter has got Peter who's got some apples stuck right and and I think that Apple is going to go down right so what I do and I say hey Peter listen can I borrow your Apple stock for a couple of days okay so so Peter gives me Apple stock and I and I and I pain let's HSA apples at 100 bucks right so I give him 100 bucks for his Apple stock right all I owe Peter is an Apple stock okay so so I have I'm sitting with some Apple stock right so now I go into the market and I'll sell it to someone who wants to buy it and sell the Apple stock and now I've got at the same time I've got 100 bucks and the Apple stock goes up let's say to all they take they take goes down so I'll make it easy it goes down to 90 bucks all right I think AHA it's gone down to 90 bucks I'll go back to the person that I sold it to at 100 I say I'll buy it back from you for 90 yeah this guy's panicking he wants to get out of the market he thinks apples thank you he sells it back to me for 90 and so I give him 90 I'm now up ten bucks and all I do is I give Peter he's shares back all right because I just lent it for him so I'm up ten bucks I'm up ten percent so that's the way you can actually don't have to trade only I shop buy cheap and sell expensive you can also sell expensive and buy cheap to make money the other way and and it's slightly more expensive to do that on the stock market but in the forex market and it's much easier because you're always trading an instrument or on say I'm sitting in cash right in my pocket I'm sitting in US dollars right I'm always trading one instrument to get some x'q I'm buying your a dollar I think euros going up and and dollar is going down if I'm selling your dollar I think the other is going up and euros going down so it's you know it's it's really just like the inverse of each other but essentially the concept is you can go you can trade up or you can trade down okay so now spent enough time on that nonsense okay so now what I'm what I'm going to do today is I'm not going to you know show you how to forecast the market I'm not going to give you the secret sauce I'm just gonna walk through two very simple examples that that Jingwei and I put together over the last days just to show you the kind of thing that we do the carnet the kind of thing that that we that we analyze a a few of you I had some conversations before the severe of you asking me some really difficult questions about you know other industries and stuff and you know I have a vague understanding of well I would say Baker I have a certain amount of depth of understanding of time series forecasting but I wouldn't say I mean I'm an expert you know um if any of you are looking for kind of them I would say the de facto standard in our for doing time series forecasting which takes into account seasonality I think I think it's a professor high demand or Hindman that I don't if the interview aware of this package is called forecast package just look for the vignette on on Google it's called our forecast package and you'll find it it's got a lot of pretty good seasonal analysis type stuff but that's not what we're going to do today because when you use that package to forecast the market you literally get a 50 50 percent chance of getting sideways with a normal probability on the end of it so you it's pretty pretty uses for doing that okay so all right example one so my first example is going to be very simple my next example is going to be slightly more complex and this the second example I'll actually take it into a trading environment and actually back test it and pour test and show you how how I do things but the first example is is very simple and this comes this we're going to leverage on that knowledge of the candles that up candles in the down candle so so it's a very simple question having X consecutive bullish candles or bearish candles what is the probability of the next candle being up or down right so so you all know the whole thing in statistics steps it's even before when 101 right is that you flip a coin 10 times and it's heads all the time what is the probability of the next one being hit it's 50/50 right doesn't matter if it was 10 times before I said so so the question is really um is there any way that are there any dynamics in the in the in the market that actually give us an age to actually try and predict the market using using those examples and so and so what of what I've tried to illustrate with those errors in it's not very clear but so for example let's say this at three green candle sets three green candles was a probability of a rake and logged would see three green candles a red handle three green candles in a red handle so that the color thing is just a hypothesis you know let's test it and see you know and see and see what happens so if you bear with me for just a moment what I'm going to do is I'm going to switch to my our studio if I can figure out how to do that yeah cool all right okay so um there's the first part of this example that I'm not going to run here because it takes like five minutes to run so I'll just tell you what I did I have some sample data sitting on my hard drive it's euro dollar 60 minute camels that mean I'm analyzing 60 minute movements of euro dollar literally chosen at random there's no reason for it is just people understand an hour if I said it's seven minute candles then you'd probably ask me why 70 you know but people understand hours are chose hours and what I did was I created some some data that basically looks at consecutive consecutive candles so I'll just show you a bit of a bit of that data so so this column over here it tells you whether before this channel is an upward candle every one and if this so zero is needed for a hand and down and and one means it's a it's a foolish handle going up and so what you see here is a little counter variable we output C this is a downward handle downward down or down so this one two three four consecutive down panels and in a forest and Anthony you know one bullish candle one one one one two and in a change of direction and so I created that I didn't run it now in front of you because I takes a bit of time to to run so I'll I'll just the skip skip back but but this from here on out I'm going to I'm going to kind of run run it you know step by step so I create another candle another column where I just create you know what the next candle is just some pre-processing and then I create a table of you know what actually what actually happened so this is a candle versus what the next camera was so it shows you here that this is for example let's say about 50 thousand candles when we had one candle one would handle the next candle was a bearish run which means that you know it's almost 50/50 it looks like at a slight you know a slight bias towards bullish candles and bearish candles so and and and what you will notice is that that it's difficult to add those numbers up so what you will notice is I'll actually just run a percentile table here oh that didn't display very well there it is okay so what you will notice is that um the lower should go down the more consecutive Campbell's you have run the water ability is above I've actually a turn around about the next hand will be the other way so for example when you get down to when you get down to you know what I think I chose seven for the top six or seven there's almost eight handle eight to eight consecutive handles there's a high probability of a point six are a probability of the next handle being the other direction okay so if we wait long enough to be a lot of consecutive finals then you don't we try the other way but which is I think it's in my box or so let's see where that lets see where that goes to this yes this is sorry go better oh this is the data set is 2010 to 2014 yeah it's what a big a big data set so actually I'm going to spoil that I'm going to spoil the the one spoiler town I'll just keep going in okay so next thing what I do is I just create more columns just to make my calculations easier when I would open when I would close I'm not looking at any market conditions at the moment like slippage not being able to open or close at a certain price that I wanted all I'm doing right now is and this is what we do at the office is we is we test hypotheses first within our and then once we have a hypothesis that we've seen that seems to work then you'll see in my next example we actually put into a trading and baptistin environment we actually rigorously test their entries in the exits out of the market but for now I'm just trying to show you how we look at the market and how we test things within our to create these hypotheses so okay right so um now what I do is I basically I chose seven in this example so if there's seven consecutive candles in one direction I want to I want to trade the other way so bla bla bla this doesn't matter now this is a very important line I'm setting my trading costs to zero that means I can get in at the price that I want and after the price that I that I want right there's no there's no trading cost at all for me so I create some profit some balance and it looks like we're going to be gazillion is which is awesome go home and start trading okay so obviously this is tested this is a test on the date on which I modeled it right so it's you know something mixed up okay okay it's like a self-fulfilling prophecy but it gets even worse than that actually because as soon as I set my trading cost to two points and I won't going to what a point is then I'm market neutral so which is which really sucks um I'm kind of making money losing money making in fact I end up end up losing money and I mean if you think about that I'm I'm losing money on the data on which I model the thing so so you can guess what happens with this hypothesis right it's tanked in a trash can and we move on you know to to our next to our next example okay so for this you say two basis points yeah yes yeah so um well we're going into into other areas but um it varies depending on broker and how much you trade so when we trade our own book are we trade at a 1/10 of that but so it all really depends you know but most retail traders if you're trading they take less than half a million dollars you're looking at somewhere of that kind of region yeah so okay and also um it's not only actually it's not only a matter of cost it started sorry I'll just spend a minute on seeing the question it's actually not only a matter of cost actually in the market there's something called slippage as well which is let's say I am I want to buy your $1 at a certain price and then it's just not available in that market at that price right someone's selling it higher or lower or whatever it is and and normally what I like to do in it we're not when our model entries and exits out of the market is I do like to build in a a slippage over and above my cost because that's important if you're trading a very small amount say for your trading ten ten to a hundred thousand dollars of exposure on the market like a really really small amount then you can assume a no slippage because you're in and out but if you're starting to trade higher volumes then if the problem actually gets even it compounds because what happens is you can get in portion of your trade at one price and another portion at a higher price you know you kind of have to look at the average price that you but but normally I like to build in some kind of you know some kind of error error error margin in trick sir okay all right oh sorry that's a trade number yeah the trade number is sorry I should have said that yeah that's a trade number and that's the amount okay okay so what I want to do next is is I wanna quickly flip back to my powerpoint presentation did you mind if I just keep it like this is that is that okay instead of make that fullscreen understand it's just one slide I want I want to show you so so in this example I'm going to get slightly more complex and this one's actually going to end up in a in a trading environment where I'm actually a back testing and forward testing so the hypothesis here is is Eurodollar cyclical okay and and what we're going to do is we're going to we're going to come up with very like a very simple concept to to to test a cyclic ality and so what what we're going to do is we're gonna we're going to smooth out the branch drop you're going to find some turning points where the price turns and then we're going to measure a cyclic ality according to time between the 20 points and cyclic annainsea according to price price movement okay so we're going to be measuring 60 penalty according to motivation to those two axes yes I'm going to do this in mark I'm gonna and if you all want the code I said in the little chat people will ask me for Kodama I'll just post this code with the comments that I have along with some sample data and you guys can play with it just excuse the spelling mistakes behind my comments were just kind of varying this thing so I'm just going to switch back to my studio okay so this is the second example cyclicality so um this is something which is very critical when it comes to what I found is important when it comes to analyzing time-series data what's helped me a lot is making my x-axis a uniform okay now the reason why I do that in the financial market space is because if you work with an x-axis that's a date time what you're doing is you're distorting your market movements when it comes to weekends ok so it adds um you know these straight lines and basically flat markets on the weekends and that really distorts the the analysis so what I normally do when I'm analyzing again this is specific to my domain writing financials in financial market data series so um is I I completely ignore the day times I actually just normalize and that's exactly what I've done here I've literally just added a can you don't actually see that code I wonder what I've done is a how to tell you is I've just added a row number one two three four five six and that's what I'm going to use as my x-axis instead of using a day time because I don't want that that distortion maybe and then what I'm just going to do is I'm just going to do a very simple kernel regression I think that the default is a is a it's a Gaussian kernel and and this is the I've just taken the first 200 points of frost data and here is the smoothed out curve in in red but obviously that that's just the first 200 points right 200 hours of trade obviously this disguise over four years so there's a lot of data which weren't fitting this I just wanted to show you how we can just smooth out the thing I'm again all the numbers here at this presentation are random you guys can take the source code and do what you want up I chose a bandwidth of 10 um if you guys know anything about a regression that's basically just sensitivity to sensitivity to noise so you know the bigger the number the less sensitive it is to noise I wanted to kind of pick up these kind of small movements yet again completely are between I literally just started typing numbers so and then and then what I do is I find some I wrote some code to find some Peaks some drops and then I'll show you what that looks like okay so there's some can you'll see that if there's a red a red dots where around the piece and and green dots where I find the cuffs and so what I've got essentially here is a is is a simpler version of of what I'm trying to analyze right yes it does contain a bit of noise but certainly not your any degree of the kind of noise you really do get in the financial markets right and so and so um I'm now going to as a next step a test the the cyclic allottee of that so I'm just going to create some some distributions to show you okay candle difference versus price difference oh so but the x-axis yeah is the difference in price between each of the training points but and the y-axis is the difference in handed actually shouldn't be the other way around right because handles got the same positive as if it doesn't matter okay so um you can see that certainly the majority of the output of the the cycles happen you know I guess below twenty four thirty or so handles so that gives us an idea of you know this is a clear distinct cluster date right um so it gives us some idea that that you're a dollar at the twenty points are very you know clustered around you know less than thirty candles as well sorry it's not as well no no it does the turning points right that significant turning points of Eurodollar are happened within 30 hours okay widget which is it's a number okay and then literally speaking the price difference granted they are mounted moves right within those 30 you know 30 candles so is is certain you know you know less than this is then can 100 basis points every 100 basis points so so where we can immediately see that that that certainly are you know there's something but already before even back to see this there's something there we need to we need to take advantage of now there are many many different ways of trading a this type of thing you can you can try forecast when the next turning point is going to be to try that um I'm gonna call this example I'm going to try it I'm going to be a little bit kind of extreme and make it a more slightly more difficult problem what what I'm going to do is if we look at this feature is that I want to explain I'm absolutely loves from the graph up into quadrants really up and and I put the major cluster over here on the bottom lid so this is where and again I kind of drew these am fine I didn't do any stats around drawing these lines and just kind of look at the pic actually print around and you survived it with a ruler and you'll compare with a code and give it as you wish um so over here this is you know normal business so I'm I'm actually for this example I'm not interested in in bottle trade I want to do something a little bit different for the song and if you look at this quadrant over yeah and this is a very little movement over a long period of time black markets and this quadrant here is again proportional a lot of movements over a lot of candles right so again up money as I mentioned to the funders that in this now this is quadrant over here this is this is wandering over here for me interesting because this corner is a lot of movement over a short space of time so that that's not interesting for me because because I look at something I can say okay this is a reversion opportunity but I think this is its room too far too far too fast that I think it's going to come back or attitude to normal trading cycles and so and so the example I built is is around trading breath in something that's gone up too far and too fast try trade the other way so we call a mean reversion trading okay all right okay so now so now what I determine I'm looking at my comments as I'm doing this presentation to see what I did so what what I did is essentially amber are these two lines and I and I work with the same tiles for both the yo that the candle differences was that has the price difference and oh actually am i printing them out here somewhere oh I actually haven't oh yeah I'm printing them out and and what I'm doing is I'm actually showing you where they are in terms of distribution of movement right so this is for low prices when she can see the vast majority of the prices who's able in the cycles on over here you know obviously it's not a long tail with you know just this kind of distribution and and and the line that I drew the red line that I drew this is where it lies within this kind of histogram I guess it's just for information so just to show you it works out to be what does it work out to be somewhere like 880 or for ninety percent are basically of movement and and similarly for the full of candles if you recall it to somewhere around thirty or so I drew my line maybe 48 it ended up being about thirty-four thirty-five whatever it was and just to show you what the distribution is of the profit of the canvas you can see quite clearly that it's certainly the majority of finals Eurodollar happen between 10 to 20 candles sure are we all falling asleep yet okay we're getting to the interesting bit now okay so now what I want to do is I'm just gonna just run some code to set up my trades y'all can go through this at your own pace if you want to at home and and so that's what you do it won't fine and then so okay so now so now we're now I basically drew that same kind of equity graph based on this on this theory right so if it goes out too far trade the other way and it but right so whether it's going up or down if it goes up too much too quickly I trade short and if it goes down too much too quickly I trade the other way and so I set my my cost to zero right the killer and I look at it and I'm like whoa again I'm cautiously optimistic as I put it and then I and then I set my trade cost to two pubs which is plenty and did that move up right yes actually it did move so you can see the properties about four so move the ha okay so we're on to something even with the cost of 2 cups there's there's something something here ok so now so now now what I would typically do is I would say okay this this this hypothesis gets upgraded we can we can go to the next level we can actually test this thing out in in real market conditions and can anyone guess what the problem is with this hypothesis then no it's not related ok is there anything statistically at fault here with a sweat can anyone I mean it's I mean up unfair question of me to ask you but but let me let me show you something I want to show you guys something interesting right so now now let's exactly right velocities that but now have a look at what we did if you recall I kind of skipped over it on purpose because I didn't want to ring any alarm bells but I use the regression due to foot thus to smooth it right I use the regression now as you add data points to the end of the series the regression line changes backwards right it so thank you I work out the route the point that the standing the regression and that's the way it stays forever right so if I add more points over here this is turning point could go what in so good that one right because the regression line sort of suits an ass run so so the question is yeah it's nice in hindsight right hindsight is twenty-twenty as you say in the financial markets because you can actually put your curve you know what happened perhaps your regression line takes it to example happen in the future but when you're actually trading real time right going going forward your regression line keeps changing so you might make a little better place a trade based on this turning point you find more data points from yeah then 20 point good would be still on it's a single which as I'm in the market but the reason I'm in the market is just disappeared right that's all I'm pulling the carpet out from and Eve could you forward services no so this is what what this is what I'm going to get you now so okay so um now actually oh I haven't even opened up my trading platform right so so this is really I guess up to here is is where I kind of stepped away from our and and start moving on to a more sophisticated a back testing an old execution platform so let me just close down some trading stuff I'm just going to open up a little example that that I wrote for this or these purple this presentation so so um I guess I'll just spend a minute explaining why I walk away from our at this point in terms of doing a forward a back testing and forward execution um if you want to do very very basic back testing and forward testing you can there's a few a packages out there you can use a coin dealer I think it's one or two other time series packages you can use but this they're quite major major major drawbacks they're there they're only good enough for for cursory evaluation I think the purpose of this presentation is for me to show you how we use our in our real time actual trading environment so that's what I wanted to do so for example when you're using our two little coin flip to to do back testing up or testing you can trade a one instrument at a time if you want to trade multiple instruments at a time and know your equity value your cash value at any point in time and make trading decisions about your available cash at any point in time this kind of event driven market specific financial market specific type parameters they're they're very difficult to model in in our and so what we do as a company is is we is we build hypotheses we test hypotheses up to certain depth in our and then we and then we move on to something more more sophisticated from a from a practicing and forward execution a perspective substitute so i am i use this company a seer share trading and right there there don't do business in the u.s. they're quite big in the UK with a lot of hedge funds in the UK but a little-known company very nice boutique product and one of the reasons why i use them and this is what what we're getting to is actually it gives me the ability to literally copy and paste our code into my trading terminal so i don't need to ask see developers to to redevelop the regression and then spend six months debugging the modeling stuff I can go straight from well almost straight from modeling to to testing and and and not get bogged down on debugging you know a bad bad code and and so I'll I'll spare you the details but essentially what I've done is I've copied and pasted other than the first two lines other than those two lines which is basically getting data from this sheer environment and just putting it into a data frame other than that the rest of us code that I'm highlighting here is literally a copy and paste of the code I had in in my art studio and you can see I've even commented out the GG plots and all those plots that you a copy and paste and and that's the kind of thing I like to do because that gives me a bility to look at this thing and say yeah oh that works great or I have to change a few things go back into our remodel test paste it back into into into sere and you know but but essentially what we're doing here which is I think that the basis of the presentation is this is how we use our in a real time trading environment at and okay well yeah and so and so what we do is I mean again our board I won't or you were the details but essentially our produces some some values you know it produces in this situation the candle the from the price step so it's basically telling me when a certain amount of candles have been exceeded or it's moved a certain amount in terms of price trade right so so all my analytics and everything is sitting in our and then it just spits out a decision oh let me go to the very top and and what I'm doing here is the first line is very important because what I want to do so the winner because it's a regression every single time I get a handle and move in order what I'm doing is I'm recalculating every recalculation paralegals 120 hours or whatever so like a weeks every week I do a new regression a remodel and I suffered new parameters up so that that is very very important and and you find a lot of if any of you trade you find a lot of kind of more amateur quonset what they do is they is they create a model they over fit the model works for a month and then whole thing just collapses okay and then everyone loses their money everyone sad why why why why because they don't they don't adapt right so so what I like what I like to do is I is I like to leverage your computational power which is the reason why I have computers and actually try and change the model as we go along and so I'll actually show you when I back test us how the model actually changes and these these are the percentile so remember those histograms I showed you so on the price difference it was 87 percentile and end on the candle difference it was a 91 percentile and and I'll and I'll and I'll show you how the actual numbers change ed ya know I've literally ran nothing it was just like literally art you can ask you a we sat at the laptop and we just punch some numbers in we drew some lines manually yeah so yeah I'm not giving you the answer if you want the answer can invest in my hedge fund give you G yeah people ask me people think that actually um there's this perception in the market that that um that you build an algo you bother automated trading strategy and then you retire and you sit on the Bahamas and you chill out actually it's completely the opposite because a point zero one percent improvement in your in your performance could potentially mean a massive amount of money so there's constantly work going in no one's sitting on the Bahamas and chilling out like then I can promise you that so but but yeah your aren't it everyone's always constantly tweaking and doing things yeah so I'm not going to kind of bore you with the details essentially this piece of code here isin it's gone up all cells cells when it's gone too high and and puzzle it's gone too low okay now for the purposes of this presentation of kept things really simple once I enter a position I'm going to be super greedy and I'm not going to exit the position until I'm in profit okay so I'm I'm Superman I feel like I'm Superman oh I put it down as $5 if I'm up $5 I'm exiting I'm getting the hell out of it okay so cool so let me try and move this screen showing window I'm going to just set my I've got a back test here and I'm gonna run this back test I want to see what happens it might be a little slow because I'm screen showing it's not too bad okay we're running through I think it's I think it's four years of data again and I think this is this is the date on which our model right so we're expecting pretty good results okay so okay so here are some results we we made six percent per annum and our drawdown was fifty-six percent so it's absolutely shocking but this is what our trade equity curve looks like okay I don't use a trade equity curve I use what they call a mark to market equity cook so a trade equity curve tells you the amount of money you had when you open the trade and the amount of money when you close the trade it doesn't tell you anything about what happened in the middle so let me show you now what really happened in the middle so we can evaluate whether this is a good system or not so I'm just gonna okay so so this is what really happens which the trade equity curve doesn't show you looks like we're making great money and this is the break-even over here goes for absolute all the crap okay and then and then it happens to recover again right and so that's what's missing from a from a trade equity curve so it's important and this is the kind of thing that's very difficult to model within our itself right to action understand what your cash position is at any point in time okay so it's very important to look at that at the at the actual market to market equity curve in your cash position at any point of time so so and it so but now that the price goes up and up and up and there's all these there's a few of these kind of major dips and and so right you know certainly this is worth looking at a little bit more some more dips etc okay so I look at something like this and I and I say okay like okay back-tested not bad um there's clearly a problem I'm holding the positions too long and then I understand because that's purely a matter of the fact that I'm I'm holding my position until I'm in profit right so I'm I'm holding losses forever right and that's how I'm losing all my money okay so there's clearly a problem with my exit strategy right I need to put said some kind of what they call a stop loss when I've lost too much money get the hell out of the market and so and then what I can do is I can actually forward test it Oh actually what I wanted to show you first is so before I'm forward test it I want to show you this is that um you can actually see how my parameters change so remember we started off with like 30 odd candles and a certain amount of of price difference and that's on the top line right we start off at 34 and 0.016 is a price difference and as the thing readjusts itself right we end up at you know thirty two and zero zero eight so the cyclic anity as we've moved through time the cyclicality of the Eurodollar is actually changed and because excuse me because we've had our embedded into our trading system we were actually able to in real time supposedly a readjust our our our trading strategy to take into account the new cyclical characteristics of of euro dollar okay and then and then sorry to disappoint you all and here is the forward test for this okay we just lose everything okay but the reason for that is actually I did some analysis on it it's not because the the model breaks down and I'll show you the trading chart so I'm just doing a lot of chance at you so we lose an insane amount of money because the the in 2014 we're not 2014-2015 the last trading we did was over here at the start of 2014 and the rest of the time we were just holding our position hoping and praying that would be a profit so again it's not a I don't think this is a breakdown in the model that I've presented to you I think it's just because I just thought wasn't the purpose of this thing to build a winning trading system so the exit strategy needs some work certainly I'll send you guys the code you can mess around with it as much as you want put in an exit strategy see where it takes you certainly it'll get you it'll get you going ah sorry yes I was long exactly yeah yeah I was long anything yeah yeah it's actly so it's easy to put in so the trick was putting entry exit saying is that what you don't want to do is you want to give yourself some room to be able to take into account the the market and noise but yet not enough room that you incur too many losses right so it's like a a very tricky balancing act um but I guess that's what you need to jump jump back in at some point and you know so anyway yeah so so anyway this is what I wanted to show you this is how we use use it and what we do is we actually literally take our code and we embed it into our actual running executing algos and we do this on the modeling side this is a Windows package actually our actual real money that we train runs on Linux servers so you know that's our in a Linux environment embedded inside this kind of wrapper so okay so so what we've done is is this CIRA platform and again I'm kind of tech dangerous I'm not I don't know a lot of tech but a little bit a basically at the waist describe to me is that there's like a shared memory space between our and the seer platform and what they do is they interchange data to itself so it's really fast for cr2 they can take a fix and trades and candles and pass them to our let our do some analysis on it splits results back into seer and in Serie makes the trading decisions and then that happens you know both I said Linux because we you know I'm showing your Windows platform but in in a real server based environment it looks very different they aren't pretty pictures and stuff so it you know yeah yeah we have a range we have down from one minute all the way through to daily we have a range so and and also I'm only trading a euro dollar you know I can add this is one of the beauties of being able to use a system which is built around trading I'm you know I can let's say add in another other sylheti backtest so we can actually see I can actually add in just by adding in another instrument to my portfolio I can practice two instruments at the same time right and then what's actually going to happen is that because seer is smart it keeps its own context and for each instrument you can imagine that math cyclicality analysis will be done for a pound dollar I'll have one set of cycles and your dollar and other set of cycles right so so I can quite easily you know use the same rationale to to trade multiple instruments and that's something that we do we trade our our our funds trades on between four and eight different instruments at the same time because we want to manage our risk with more focus on risk management in in returns but you know depending on who you answer yes 60 to be going up was off but it doesn't yet give you any occasion value better you know on our example to show you use 50% of ability made a decision or actually actually we use that for the first example we use the 65 percent probability yeah but but the actually what I didn't show you I didn't take this this thing for the first example all the way to is trading environment because when you go down to that level of a probability of waiting for I think it was seven consecutive candles up or down candles I think he were trading like once a month or something so it's just you know it's great to have numbers and probabilities but in real life you're just missing a lot of opportunities throughout the day and and so it it's not something that that I would even consider even it's simply theoretical it's not something I would consider from a real world trading perspective if any of you got any more questions in come up afterwards I've got my business card yeah if you're too shy to ask me questions you can just drop me an email or LinkedIn me or whatever oh thanks everyone
Info
Channel: Autochartist
Views: 92,943
Rating: 4.7513514 out of 5
Keywords: R coding, Trading
Id: hKDalfhDawA
Channel Id: undefined
Length: 54min 2sec (3242 seconds)
Published: Thu May 28 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.