Our trading system. An informal overview of the work so far.

Our trading system. An informal overview of the work so far.

Show Video

hi this is david with the enzo trading system  and uh today a different video i would like to   do a review of the work we've done so far uh  this is more introspective i guess it's more   for those that may want to embark on a similar  endeavor in the future and about the obstacles the things we found out along the way and they  may be useful to others uh yeah the reason for   sharing is uh partly publicity and also because  i think sharing helps our helps me definitely to   put things in perspective as as they... tell them  out as it often happens so this is our website   uh we started in uh uh february 2018 and we didn't  have an application back then we had the general   idea that we wanted to do a trading system and we  actually called it a bot uh which i think is a bit   of a misnomer because uh what we're really doing  is uh quantitative analysis uh so the bot is more   like the acting uh software but uh the software  that needs to act on a on a useful model one that   has proven to be effective and that's kind  of the hardest part apart in many ways   so what we do we actually develop a training  system the models but also the runtime   so let's see i have a few slides here to  help me along the way um yeah we started 2018   from scratch personally i had no clue what  uh i mean i had an idea what trading was   uh i had no personal experience but i knew  people that tried to get into the field and left disappointed even smart people but i think uh the  real issues really that one needs to be   open to it put a lot of work into it before seeing  any results so it's a lot of sacrifice in terms of   time and and resources so the initial  idea is like you know buy low cell high   it looked very simple uh what do i mean like  uh yeah i mean honestly i was so clueless uh you see chart you see something  like this and then you say   yeah okay i just kind of want to buy around here  and sell around here it doesn't matter maybe i   maybe maybe i buy here in a sell here  maybe it's not so efficient but still   so of course i mean that looks simple enough but  it's never like that uh what really happens in   in truth is that you don't really get a nice  pattern like this it's more like yeah maybe   you you get it for a while and then what really  happens is that it starts to go really down so   you think uh yeah you know i you know i buy here  and sell here i buy here and then when do you sell   now you got into a loss and you probably lost more  than you made up to this point so i mean this is   obvious stuff but if you've never seen it like  me uh in 2018 it seemed you know it's intuitive   you can see fractals you can see patterns and  you realize that you can use them and you can   use them but the problem is that uh then there is the exception that breaks everything else so   in a nutshell that's really  what makes it uh so difficult   so it was uh you know the obvious decision to  jump into machine learning uh not because it's   a buzzword i honestly didn't even think  about machine learning what i thought about is uh   uh yeah let's develop a system that offers  some multiple solutions and then in real time   it will apply the best possible solution and this  is actually on our first and only white paper   uh here there's uh some some graphics that i put  together myself at the time and yeah you know the   you know normally what one does uh without a trading model uh you have to kind of decide the market if   you have a script you then you set up a script and  then you hope that it will work instead uh ideally   you have kind of a multiple realities running at  the same time and then you pick from the best one   of course the the big problem here is that  you pick from the multiple realities which   you know they just did the one the best one  that just did really well but is it going to do   well next and what does it mean next and what  does it mean just now uh so do you base your   your cost function which is what tells you how  valuable an algorithm is uh do you visit on the   last week last few days in the last month you  base it on one year but is it going to translate   well in the market that is going to come so it's  really uh all decisions that are made in the past   in a sense you have to guess what is a useful  portion of the past that will translate into the   future and it's not just the useful portion of the  past the usual full portion of the past that works   with your algorithms which probably by definition  they already they don't do profit anyway so   i mean in an ideal world you have a system that  builds the algorithm itself but that would be   really intelligent and uh then what you end up  doing is creating a system that uh builds a huge   uh overfit which means like yeah really tuned  for the past but really doesn't work well for the   future so this i mean the idea basic idea uh works  but to make it work it's a whole different uh game   but yeah we started with that the basic idea and   i personally started uh working on the strategies  i learned about the the technical indicators which is what everybody talks about is your  stochastics which means like a range of   minimum and maximal within a certain range  in the past once again relying on the past   or uh the line fit you know the market is doing   like this so you you kind of extrapolate  uh direction a linear direction needless   to say these are all things that everybody  thinks about and therefore they don't work   maybe you make a linear extrapolation maybe you  have two linear extrapolations maybe you build a   machine learning system that will try all possible  uh extrapolation based on a different series of   historical uh data and then again you  always have this problem that you constantly   not really finding the right parameters  uh that will translate it to the future   there are there are patterns to be discovered  but they're not that simple that's kind of   uh the problem and they're not forever so  there's a lot of work to find those patterns   and it's not direct necessarily drug human work  you may have an intuition but then you have to   put into the machine and then figure out if it  works and maybe you have a range of parameters   and then you figure out you the a to the machine  you figure out whether uh that's reliable if you   have to find a fixed parameter if you have  to find a range of parameters that that you   select in real time so just just uh this is just a  infinite way of possible possibly doing this stuff   and so then i start testing every possible  strategy everything you can think of   today you know somebody comes  i know anybody who will uh   from time to time will come and tell me you know  did you try this did you try that yes i tried it   uh i tried it maybe not specifically that  thing but in most cases i try to and um   and the tricky part is that some stuff may  actually work but there is many ways of trying it   you know if you try like if it is and  green candles then you buy and if it   is N candles then you sell maybe  in that specific context doesn't work   uh maybe there is something else that you  have to do with it so in many ways sometimes   you can almost make everything work as long  as you put other things together and then   and um but in general you know everybody you know  anything that anyone can think uh of uh i've been   pretty deep into it and i tried uh just about uh  anything and other stuff you can just you just   can't try because it would take you know it would  get you into a rabbit hole and i could easily spend one   year just about anything there's only some idea  you can get some white paper of somebody who says   oh use kalman filter so use this kind of pattern  matching and it works for us yeah in the paper   but the stuff that really works i  think in this world is more secretive   so i come from computer graphics where papers are  published and even there you have to figure out   uh if that stuff really works in practice  if it works for you uh what's the catch and   that's like more an open world you go to the siggraph everybody's happy to present their paper   you go to the game developer conference when  it comes to finance of course it's more like uh   closed secrets because um i mean anything can  can make you money almost instantaneously if   you figure out something it's not that simple  but there are some things that you just don't   want to tell them around so it is kind  of exciting in a way but at the same time   it's tricky because you you just uh um you know  walk in the dark you don't really know if you're   really close to something that works if  you give up on something or some approach   or uh and then maybe you work on that  it happened it happened to me now i have   we only use custom indicators today 2021 and  uh there are many ways it's an original idea that   we came up with like at the beginning but then  it didn't seem like it worked and didn't seem   that it worked and i spent months and years  trying to make it work and then eventually   uh with a certain approach it worked so  some stuff you just throw it away you never   look back some stuff sometimes you look back  it's like okay now it works for some reason   so yeah uh it's maddening but that's kind of how  it works and so yeah we try all sort of uh custom   indicators historical pattern match any kind  of polynomials uh fractal approaches you know   multiple uh levels of uh you know self-similarity  at a different level of frequencies it's just a this joke and yeah and then  you know as i mentioned machine learning   uh the trick about finding the  best cost function which means   how do you evaluate an algorithm so that you  select that algorithm from from now on and   then do you evaluate it you know to work for the  next month for the next year for the next few days   and uh and then you know your evaluation may  have bugs uh you you never realize that maybe   the idea the basic idea was there but  it didn't quite work a common one is uh oops so cost function uh you want to you  deal with uh many times the obvious thing is   evaluating your profit so how do you calculate  your profit because it's very um you you generally   you kind of divide for every uh position you  divide the price of which you sold and the price   which you bought and that relationship  will give you if it is higher than one   it's a positive if it is less than one is  a negative but uh a few times i bumped into   this issue that basically i would sum uh those  values but you you know those are uh not meant   to be summed they should be multiplied  together that's how you you accumulate   something that is uh fractions uh so and that's  why actually uh it is suggested to use uh   logarithms and put as much as possible into  logarithms because then you can sum them   it's just in general it's not like it's  some special voodoo technique is just uh   many times you'll find yourself you want to  sum things out so if you have a logarithms of   of the fractions of the sum of the profit  then you can sum the profits and uh but if   you're summing a profit that are not  logarithms then you have a skewed uh   cost function and uh and the trick is that many  times it will it seems like it works because you   can tune your algorithms around the cost function  it's you you don't really ever have a fixed point   so you can say okay this is my cost function  i rely on this then i'll develop the algorithm   on that and then somehow the algorithm works  on the tested data and then it doesn't work on   the day that you didn't test them perhaps you  bump into cost functions oh this was broken   now you fix the cost function now your algorithm  maybe doesn't work anymore because it was based on   on a wrong premise so it's really important  to i mean yeah you say i i implement machine   learning but any bug can throw you off another  thing that we tried is our genetic algorithms this one is a pretty intensive  on the cpu and on the ram i think yeah if you have a lot of a cpu to spare but um  i mean genetic algorithms frankly because it was   one of the simpler things to implement if  you want to use neural networks maybe it's   better but even then you open up all the  different kinds of can of worms but um yeah the problem is that it's kind of a idealistic  approach where genetic algorithms it's basically   a way to find a solution for a  very complex problem meaning that   you build your algorithm so that is a very  complex algorithm that has a lot of parameters   uh possibly you put all the possible  indicators and then you tell it   you built kind of a virtual machine that builds  some uh op-code and and parameters to use   any possible combination of indicators and then uh  what and then you have this very complex problem   that you put into genetic algorithms what that  what it does is that because you couldn't possibly   test all the combinations you will kind of refine  the combinations in a way and discard some of them   maybe it will discard the ideal  combination but nonetheless so   you will kind of find a good enough solution but  even then it's very intensive i mean actually   this machine is 32 gigabytes and a few times  i had the windows uh just crashing on me   um too much ram too much cpu and and then you you  end up building something that really overfits   um it's not something to discard completely uh  but um it's kind of uh overkill and it will uh   easily lead one to have an overfit solution  which is definitely what you don't want to   have if you want to make money and not just  show some pretty numbers and back tests so and then now we have some early success with  the simple approach which is i called uh the   climb uh which means basically let's see if i if  i have one that i can show it's a reactive algorithm that it will well i don't have it here  let's see one of the markets please it's a reactive algorithm that  will jump on the opportunity uh which is uh instantaneous so whereas other  algorithms with the technical indicators   will try to uh look back like days uh  maybe months and kind of guess what's   happening what's going to happen in the next  few hours and this one really basically jumps i see the spike of volume and it decides  that's a very high volume and then and then   maybe there is some some pattern that detects  uh which i won't necessarily reveal right now   and then it will jump in and buy instantaneously and actually oops and then sell rather quickly if you can manage to have not too many false  positives uh this is kind of a very good bet this is actually our most reliable approach so  far but uh the thing is these opportunities are   quite rare and uh and these patterns they they  tend to vanish so from time to time i wouldn't   know if this one works on year down the  road and in fact since we started uh this   approach i had to review a few times i think  now it's more robust we actually apply to all   the algorithms [markets] but um it's something  that you have to maintain but i think   this is closer to a more realistic solution  it's less uh voodoo is less about uh you know   looking back a lot of in the past and  trying to fight this part so it's really   yeah there's a lot of volume just jump in and  uh and jump out uh it's not so easy but it's   we had some early success uh it was based  on a very high frequency data and it was   really heavy to test and then uh they worked  well in 2018 and 19 then start they stopped   working you never know if it's gonna work  in the next few months then we dropped it   and then i picked it up again and now it works  and it's kind of an example of things that   uh work really well or maybe don't work and then  then you forget about it and then you pick it back   up and then eventually it works it happened  a few times and if i've known before you know   but you cannot know you just have to  live through it and trying to guess and um yeah initially we started working on  multiple market eventually we focus on bitcoin   just because the back testing it's if you have  to test just one market is one thing if you have   to test multiple markets it's more work you have  to optimize your back test and also you have to   have some sort of portfolio management because  it's not enough to say oh yeah i could do well   in this market i couldn't do well on this one but  you know because i can do well in this market then   you know i'll put it online then how much do you  allocate to each market that's kind of the big key   and that was kind of the thing how do you make  a back test that deals with multiple markets   uh you kind of have to build infrastructure to  test for it and this is something that eventually   we implemented only uh this year but back then  we decided it was better to focus just on bitcoin   it was probably for the best uh so and  in 2018 also we started the internal fund uh with a few selected uh friends   so 2019 i don't know what the what the  hell we did it was like more of the same uh uh the algorithms a lot of  uh existential crisis uh uh can we do it fully automated uh you  know you start tweaking you start making   trades by hand some trades by hand you don't  trust the system uh you have to decide uh   can you really improve the system so that you  can trust it or do you just have to wait for the   for the current algorithm to uh do its work that's   that's always that that big question um the  solution is like yet to continuously develop   and uh develop mostly under improve the testing  because that the better the testing the the more   uh reassurance you have that what you have right  now it's something that uh it's workable um yeah   we did develop all our major custom indicators   as i mentioned like whether is an indicator  that tells there is going to be a pump   uh or some other kind of uh indicator the  individual patterns and historical matching uh   but there was like just a lot of work figuring out  what works what doesn't work and sometimes you put   together some indicators and the back tests will  tell you yeah this this is a good algorithm uh   because you mix these uh indicators  together but what you're really doing is   it's kind of uh yeah again overfitting maybe  in the end the other indicator all it did it   was just a save you from some major loss  and a few trades or or you just somehow i   influenced that kind of a butterfly effect  and influenced you to the algorithm to get   a really good trade the you know it was jump  10 20 percent the mid year the year and so   you have to figure out what's the real  usefulness of some indicators sometimes   you put them together and you seem like  they work and then in fact they're just   building randomness maybe you just have to  use separate indicators on several algorithms   uh yeah whatever yeah i mentioned  this already with you know we tried uh   genetic algorithms super algorithms where you  know ideally you build uh you have this uh   virtual machine approach with the code and the op-codes and kind of it's it's an interesting idea   you know kind of like a truly uh genetic  approach where you the code builds itself is a   self-modifying code in a way uh but is it more  like for research and because it takes so much   uh computing power it's better to cut to the  chase and just could uh use a little bit more   brain and know so much about this stuff you know  maybe it will be more interesting research to   to do one day when you know i can kind of retire  so we also explored with the forex markets uh but   uh yeah it looked very hard but honestly  we didn't have a good algorithms anyway   so i didn't know very much what i was doing uh and forex market it was just uh possibly even worse   than uh trading uh bitcoin the key for markets  uh forex markets and even in the crypto today is   really to be able to leverage multiple markets  and really jump on the one that uh that works   best at any given time which of course is not  that easy but it's better than focusing just on   you know japanese yen us-dollars or something like  that and uh back then we didn't have a system to   deal with multiple markets at the same  time so um we explored it and i figured   someday and then uh yeah we still had the internal  fund and it was going just going down i don't   know what bitcoin did to 2019 but uh yeah the  fund wasn't doing so well but it didn't go bust so how much i'm with time i don't know so uh  2020 finally something concrete uh we finally   uh developed a trading client that others could  use so that enticed uh that implied uh using   having a proper uh graphical user interface  having a connection to the server setting up the   signal server meant even more infrastructure  infrastructure up to this point was mostly to data   gathering and uh the build machine all the basic  stuff that one needs to for uh for development   but now it's like it was really  important to have a signal server because if you if you're trading for  yourself locally you just uh   don't really need a server you're just the clients  running and generating signal and doing the trades   if you have to generate the signals and let  others do the trades then it becomes a kind of a   more of a network issue yes that's  uh yeah it's a whole can of worms and uh 2020 was the first year with a set of trades that we did ourselves and  other uh users did and we could match   and uh it was fairly profitable uh so 120 percent but with the maximum down 25 percent uh which uh seemed   tolerable seemed good but uh once you start  playing with leverage it's definitely too much   so we had uh you know we noticed months of  drawdown but we ended up in profit uh we learned a   lesson yeah you have to be patient and that's what  we always say and we continued to work on algorithms   and testing uh finally we implemented the sharpe  ratio and uh i think at this point we finally   put monte carlo validation but with sharpe ratio as  an industry standard monte carlo validation it's   it's more a generic term you can do in many ways  but honestly uh sometimes they they're reliable   sometimes they're not reliable if you have a  few trades these can go really haywire   i mean i have algorithms that work really well and  the monte carlos are crappy these days because   they generate a few trades so we should generate  more trades but if you generate more trades then   then you you know you end up having crappy trades  so uh there are ways to improve these things like   uh sharpe ratio for example we base it on the trades  i think and then maybe better to sectioning uh   instead of basing on the trades based on the  split the trade uh depending on the if it is   spanning multiple days maybe or multiple  hours split for the hours and then do the   subdivide and uh and calculate the sharpe ratio  maybe i don't know but um the sharpe ratio idea   is an industry standard how you really  calculated it's a whole different thing   and uh it's a bit tricky because you want  to tell people oh i have this sharpe ratio   but uh honestly i can just tweak one  thing and it will be better or worse   so it's more like for internal use but you  definitely don't wanna i for myself i'm gonna   rely either on this and not even so much on  this uh when it comes to really evaluate the   algorithms profit and uh the relation of profit  to the drawdowns it's the best evaluation so far and um and then the internal  fund finally it was back to its   original glory so making up the losses  and uh and actually uh back in profit so yeah 2021 uh tricky year we started feeling  uh quite confident we started using leverage and and we started considering  more markets than bitcoin   we've seen a lot of returns up  to may and then with a big drop   it was interesting because a big drop was  actually a success big drops are not a problem   the problem is like what happens afterwards  uh the the volatility of the market and that it's kind of both a negative slope and highly  volatile market that's really what kills you   and um and yeah uh we were kind of  another thing we really didn't have   too many markets only up to five markets  trading so but there wasn't really any   uh true diversification because once bitcoin  starts to move a certain way everything else moves   that way so there was no diversification there  was high leverage and uh the behavior was actually   kind of as expected uh because we did have uh we  didn't know that we were going to have uh possibly   25 percent uh 30 percent maximum drawdown  and with leverage becomes like sixty seventy   if you have 5x maybe even eighty uh  maximum draw down and uh if you see in   the test okay fine then you get out of it but  in practice so it's quite debilitating and uh   yeah that was a kind of a lesson and that as a  reaction we did a major work on position sizing   and the focus really on reducing maximum drawdown um this is something that we knew but uh kind of   you postpone it uh and then you realize even if  it's not the end of the world because we survived the problem is uh maybe you're okay but people  they uh a lot of users they may jump into the   market with our system uh when it's doing really  well and then they get the full brunt of the   maximum down which is which is all the way down  without even ever had the any profit prior so   our internal fund is still kind of a profit even  though i mean we went thousand percent you know   back 50 percent that's i mean that's a big loss  but it's a relative loss we're still in profit   if you come in uh at the top and then you  just get the the losses just to start with   this uh quite stressful and we definitely don't  want to have uh you know negative publicity you   know it's the ideal fund this one that doesn't  give you so much volatility in the fund and um and then we also have the major refactoring of  the build this is more of an internal thing but   how you structure the software  and uh make it more maintainable   switch into libraries that are more standard for connectivity you know uh so this is this  kind of infrastructure that is necessary that   was kind of postponed because up to this point i  was mostly dealing with the runtime by myself and   finally i got l polls on this side of things and  uh this was you know great and necessary and uh   and then we have the support for bybit uh not  only no longer binance only uh it's very important   because finally don't have to rely on a single  exchange and and if we have to implement another   exchange we can we can do it once you implement  the second exchange the third one is not so hard and then uh and now we're focusing more on  generic not genetic algorithms meaning that   instead of focusing so much on bitcoin uh  really trying to make the best possible on   just on bitcoin or ethereum  or just a few selected markets   uh which is a bit of a fool's errand because  yeah you put a lot of effort in there but uh you it's more likely that you end up  overfitting and then you stress a lot when that   when you know if you're only on  bitcoin and you miss some big   jump uh positive jump then that's that's all you  have to demonstrate at that given time and uh   and uh it's basically 100 failure or  it's it's more binary but if you have   an ensemble of markets that you're dealing with  you kind of a little bit of a chance here a little   bit of a chance there and this is definitely  the way forward and actually i'd rather even   also not just uh focus on crypto itself the  ideal uh the final solution would be that uh   we are on multiple markets we're forex we're in   stock market uh i don't really care  i mean yeah uh crypto is great but   uh at the idealistic level but as far as uh uh  trading making money out of it i just wanna   go whatever market uh whatever and  assemble a market so uh works best   so now with uh see what major lessons  uh did we learn definitely i learned   yeah impossible importance of  test infrastructure this was um kind of something that i didn't value as much  at the beginning because it's very easy to say   okay you know this back test looks great uh but  really you have to put just a lot of effort to   try to negate uh whatever positive comes from  a back test i said this before but it's worth   stressing again it's definitely trying to  find holes in your in your algorithms and   trying to make uh tests as reliable as possible  and one option for that is like if you have   a lot of market historical market data then to  that and crypto we don't really have that much   uh so another thing is as is this algorithm this  technique work on multiple uh markets yeah they're   all similar but they're a bit different it's it's  kind of you can consider maybe ethereum and ripple   another and other markets as a variation of uh  bitcoin in fact a testing system that some uh uh   push for is that of generating uh random mutations  of the certain market if i only have a bitcoin   then maybe i generate random mutation and then i  also perform the back tests on those mutations of   the market and on the other side you know you can  consider ethereum or ripple or bnb or whatever as   mutations of the bitcoin so this value into either  building a system that builds random mutations of   given market or just build an algorithm though it  works as well as possible in a variety of markets and um yeah testing uh test the  risk as well always uh deal with the   risk uh worst case scenario also deal with the  fact if you're doing leverage consider uh that   if it is tolerable or not and this is also very  important it's not technical but uh very key importance of a communication with the  whether you're calling users, investors   depending on the kind of product your  but still if you have any sort of uh   if you generate any sort of signals that other  app to use uh you really have to be sure that uh   people understand what they're getting into so some some concept they require a lot of time to  understand and you can't really give a simple   explanation some concepts i i mean i've been on  this for uh you know three years and a half four   years and uh some things eventually they click in  your head but it takes a long time to and this is   my this has been my life uh uh for most of three  years and somebody that jumps in and you you try   to say oh this is the risk uh don't worry about  this but really i mean you can't i cannot give you   a guarantee but statistically this statistically  that and uh and people can easily get scared   so you kind of uh to anticipate the expectations   but to the general level understand  what people generally expect   uh if you know big drawdowns and the lengthy  drawdowns is something that nobody likes   and then it depends on the you know some people  did they they're more obsessed on a daily basis   you know and this is not uh a dig because  that's why i'm also obsessed on a daily basis   but uh is not something healthy i have to do  it because i'm i developed this i'm kind of   responsible for it but uh the better thing would  be to just uh be patient and let the system work   but uh it's easier said than done so and  it depends on the people some people do   more or less emotional they're open to more or  less risk and that they don't really understand   necessarily what kind of risk they're getting into  meaning risk it's usually i mean it's not like   i don't i never seen permanent loss i don't don't  envision that although it is possible but uh the   temporary loss uh the stress that you have to  go through for uh you know seeing months of   of the drawdown can be quite stressful  and uh and what can happen the people   that you know they may pull out uh  thankfully it's must never happen but uh   uh if somebody pulls out after a drop  that's kind of the worst possible case   because uh basically you concretize the the you  solidify the loss and uh you basically remove a   chance of making that backup and i actually heard  the statistic i think it was uh joel greenblatt a   famous uh uh hedge fund manager that  uh he mentioned statistics by which uh   most uh hedge funds they're profitable but  most uh investors even sophisticated investors   in hedge funds they're not profitable  or a good portion of them and that's because   they do play with adding more and removing uh  the from the fund from their own fund and that   in itself is a way of uh trading so uh yeah as i  said it's easier said than done but this is very   important importance of our communication  and uh if you cannot communicate something   then err on the safe side it's always better yeah the  problem the problem is that you want to be on the   safe side but the other uh face of the coin  is that uh if you tell somebody you know take   a very little risk don't use leverage only use  2x something like that and then when you don't   beat the market it's like okay now the bitcoin has  gone up uh all the cryptos going up but we didn't   go up as much and so then you have to say yeah  we didn't beat the market because we took less risk oh i wish i took more risk but uh that's a  bigger discussion and um yeah i'm learning as i go   but uh yeah definitely communication is uh very  important that's very stressful for people and   for us because you really want to prove and you  really want to give as much as possible as quick   as possible but it takes time but uh you know  that's the name of the game you know you wanna   if you don't want to get the heat don't get in the  kitchen we're in the kitchen i'll take the heat   not as much heat you know it's  not so bad but yeah that's uh um yeah i hope something useful came from this   maybe it was just a way for me to to rehash  things but um yeah until next time you know   if you have any questions put it in the  put it in the comments whatever uh see you

2021-10-22 06:19

Show Video

Other news