Building Quant Equity Strategies in Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you okay so can you hear me do I need to be standing near this or can you hear me okay on the mic okay okay so I guess I want to start off by the disclaimer that I'm not a computer scientist I think I learned Python in the past year or two so my background is as in basic science started off doing research my undergrad degree was in physics I decided I wanted to do something more squishy did biophysics was really interested in basically how the brain works and when I left grad school and came to my senses and realized I didn't want to get a faculty job which I'm allowed to say because my husband did stay and it does have a faculty job so I know what a good choice I made yeah I realized that I could do all the fun data analysis side stuff without getting my hands dirty harming mice or stuffing grad students into functional magnetic resonance images and I realized all this data actually I mean so cameras talk on on quando like that was basically my dream that I felt like there's this case out there there there's all this data that can be analyzed in that's that's the quant world like you just get all the data for free at the time I didn't realize you actually pay a ton of money to get it but you know you don't have to get your hands dirty and that was a big attractant for me so after grad school I went work for a company called star mine which was based in San Francisco they basically did equity stock selection models and so on my background in the quant space is heavily biased in sort of the equity space as a lot of what I'm going to talk about today but again I come into this not as a computer scientist I think of myself as someone who writes code when I absolutely have to to do something more efficient than what I would do in in Excel and I'm going to give you I've got sort of like a two-part talk I'm going to give you a little overview of what quanto peon is just to give you guys some context and then what I'm going to do is talk about what our so just like there's going to be some good follow-ons from Tamara stock so we're also interested in crowdsourcing what I'm try to talk about today is basically what are the the crowd of people using quanto pian to write Python algorithms to trade stocks were they doing what use are they making of our platform so what is quanto pian it's an algorithmic investing platform so we host data and we have a back tester to allow anyone so it's an interesting audience of a lot of folks that are in the field our audiences is basically individual retail investors or really could be anyone so anyone who wants access to data and back testing to basically build a quant strategy and deploy it against their own account and trade stocks with it and for a lot of people who are in the industry that sounds like a crazy and futile thing to even try to do I know I came from most recently working at Thomson Reuters had to admit that but coming from that background I when I first talked to quanto peon told them you can't do this there is nobody who fits that a Venn diagram of like wants to write Python has money wants to trade their own account and there are like so I was really proved wrong and once they really proved me wrong I was like all right now then I want to be on that team because that sounds way more fun than what we're already doing so we're a platform community of quant scientists hackers collaborating to find investment ideas basically also follow on Tamara's presentation we fully support the don't charge anything model so we're a pre-revenue company we also have venture backing from Silicon Valley and so all of our end-to-end solution is free right now our model will be to eventually charge for live trading as a paid service but right now it's still free and we're powered by an open source Python backtester so zip line is our Python back tester you can go look at it contribute to it fork that code do whatever you want with it which lots of people do on our hosted platform we've run over a million years of historical simulations on quanto peein so we're we're really starting to see what happens at scale and we're becoming I'm sure we're still really small but I think the Amazon clouds are like are still pretty happy to have us around running all these simulations and paying them for for access to their servers so what we've been doing lately some of you guys I see folks that I'm familiar with from our New York meetup series so what we've been doing lately we're really interested in this idea of connecting people together in the community so we've actually just rolled out peer-to-peer direct messaging we have a lot of people on the platform who maybe they do use their real name maybe their day job they don't really want people to know who they are they work at have fun they're doing this as a hobby and so in the past we've had people want to talk to each other and they can't figure out who they are so as of last week if someone posts something in our forums and you think it's interesting you can go to their profile and send them a message and if they want to they can email you back we started off with research data and basically creating like back-testing framework but in January we went into a public beta for actually connecting your algorithm against a real money account with Interactive Brokers so you can go today and trade real money with Interactive Brokers and if you want to sign up for that you can so if you want to use your paper account literally anybody can do that like right now you could go clone an algorithm and launch it against an ID demo account if you want to trade it against real money account we're trying to be a little more responsible and roll you on to doing that so you need to get on a waiting list yes the algorithms are all by default proprietary and if you want to you can publish them to our forums and share them so the same idea you tell people this and who are in the industry and they say no one will ever publish anything to your forums ever and it's interesting to see like what people do publish and why there's a range of motivations they're obviously not publishing like what they feel like is their alpha but they're publishing a lot of interesting stuff and that's really what I'm gonna talk about today okay so that's the sort of quanto piant overview now this is what I want to talk about which is quant strategies from the crowd this image fit better with the prior title that I had on here which was more about like do-it-yourself Quan strategies but I just still wanted to leave it because I really I'm a big Jonah Hill fan so I'm going to talk about what quant strategies have we seen people in the crowd building on our platform so right we're passing like there's a zero dollar price point we're casting a really wide net like anyone who wants to can come onto our platform and if they can code in Python they can write an algorithm and they can share it in the community I can't talk about what people do on our platform when they don't share it because I said that's proprietary but I think it's interesting to talk about what they do share so what what does a non-professional need to build a profitable equity strategy this is just sort of a little bit of a like let's get on the same page like how we're thinking about what people are doing so and these are opinions that I hold so what I think they should be doing and they are not always doing this is starting with an intuition so you know man-on-the-street can have an intuition like I think that this is a systematic way that the stock market works I want to write an algorithm to describe it we certainly have people who try to start with no intuition and just sort of like sort everything and find emerging properties again my bias point of view is like start with an intuition and if you want to use our platform basically it's all about back testing and assuming that to some degree what you back test is going to be what happens in the live market and then forward testing that so you need something that's reproducible now this is another good point following on camera stock you need access to data so as an individual trying to trade a strategy if your strategy is dependent on data that you either can't afford or can't get access to or can't get access to in a timely fashion for when you're alpha decay plays out then you can't trade it right so I think that actually I think this is one of the major limitations with what people are building on our platform today and it's something we're interested in thinking about more about how to how to make that a caste a broader data net so we provide minute bar pricing data and then we provide a couple methods that I'll talk a little bit about to pull in your own data but right now it's just pricing so you can imagine that sort of like limits what what you can do natively trade trade trade level pricing so open high low close traded prices for each minute so what's on there yep it's free just equities so we're just i 2001 i think okay and lastly execution and capacity right so if you're an individual you're not sitting on a trading desk the types of strategies that will work for the amount of money that you want to put to work and you know our platform is not a low latency platform our data i'll show you our our ide and our event handling method basically runs once per minute so if you want to do a strategy you're going to be able to place orders at most once per minute they'll get sent to ib and they'll get executed within about a second but you're not talking a low latency platform where it would be a great idea to try to do a scalping market-making type of strategies that's our education front i'm just constantly trying to tell people like don't worry about the latency because you're already you've already lost that game if you want to play that latency game go get a job in a chive tea shop yeah you've already lost that game go do something else or go work for an hf tea shop minute li yeah it's just domestic us right now it's like yes we are databases something like six seven thousand securities ETF's yep something like that yeah yeah I think those are in there I think those are in there yet I'll show how you can do the CID lookup so you can look yourself and see what's in there no it's whatever's in so we buy our live pricing data from Nanak's so it's whatever all the u.s. listed equities that are traded on the exchanges that Nanak's provides I could I can provide the link to what that pricing sources so right now because that's our core pricing source that defines our universe basically yep yep yep yeah we have so we have what I would call a pretty basic slippage model we have got a couple we've got a fixed slippage model in a volume share slippage model that we've implemented it's all open source so like sometimes people will come along and be like that's amazing I can't believe you have anything and other people are like that's totally JV like you should look at my slippage model and what I say is like Greek braid it and you know put it on github and we'll pull it in fantastic so it's pretty basic right now what I tell people to do if they want to really trade it with their IB account is use your IB demo account and then you're going to see what Ivy's modeling is going to show you and then treat it with a small amount of money and then like you'll get that data like very quickly and see yeah okay oh options um we get asked a lot for FX options futures I think that we would love to do all of those things and we would love to make it global so we would love to do everything I think the way we'll prioritize it is going to be based on two things which are not the same way of sorting the universe so what people are asking for and what we think they will make money doing so we specifically want to be really transparent with profitability statistics and when I've looked at retail level FX and options and a lot of different stuff that people want to do like they just basically it's like a casino and like we're not interested in being the house that wins on high churn we're interested in like building a platform where people can really understand what they're doing and have access to profitable strategies which is not to say I think that that rules out options but I think when we do what we need to do it in a really thoughtful way and try to also bring that education bar up and try to be able to help people implement strategies that that you know reasonable so I will be shocked if we get to it this year honestly but it's possible second half of the year options would kind personally I think options equity options will come before like FX I think for like the view we have so I wanted to talk and we'll see in the interest of time I can always skip through these but I wanted to talk about sort of five basic accessible quant strategies that I've seen implemented by the CEM you members on quanto pian so I know for some folks here that this is going to be at like a completely super simplistic level what I hope you'll get from this is that you'll see that this is something that everyday Joe Schmoe who happens to know Python and have an interactive brokers account is doing on our platform and for each of them I'm going to give you an example that has a link back to an algorithm so if you're interested like right during the talk we're after you can go and look at examples of code for each of these and sort of see you know what you think about people are doing what people are doing and look at it yourself and and start playing with it okay so I guess I'll run through to give it just quickly so how I've categorized sort of five basic strategies I wanted to talk about we're you know mean reversion so the the price that something so you've got like a price that a company is trading at and you know you're understanding okay there's some random walk happening like I think the price is you know still the value of this company is still the same $10 a share something that's trading at 12 like I think that's going to come back down so that's your view you can turn that into a Python algorithm and trade it basically same kind of idea for momentum is just saying like but you know or it could keep going up because you know everybody notices now that it should be $10 it's $12 they think that trend is going to keep going so a lot of basic Quan strategies are built on basically the interplay and sort of tuning hack time horizons right of mean reversion and momentum these are two really common strategies that people use on our platform because all the data that you need for these strategies is price data I'm going to talk about those valuation you know bargain shopping buy low sell high sentiment so there's this idea that you know if you can tell what the market sentiment whether it's through social media or I'm going to use a much more sort of sort of conservative example you can tell what people are feeling about a stock maybe you can predict its price and the seasonality is another really simple example so I want to take a poll at this point I've kind of given a way probably how do you sort it out but I'd like to check what you guys think are the most popular strategies among tail or individual quants first - yep well we'll see those have to wait till the end see okay so I'm going to use a really specific example this is a really common example that you see people trying to get at I think a lot of why Paris trading is so popular is I'm not sure this is it like a retail sort of focused audience but as anyone familiar with Ernie Chan raise your hand if you're familiar with earn each and every one on quanto peon apparently is familiar with Ernie Chan and if you decide to post something and you want people to look at it put in your title Ernie Chan thinks that the strategy that I wrote is great or I copy this word-for-word out of Ernie Chan's book and like people love that anyway what's the intuition behind a pair strategy there's a good intuition right so find two assets that are linked to some the same underlying value and if you if you really think that basically these two assets are should be priced in some way we're like they're both kind of representing you know the same value you can just watch them and see when they're the market is valuing them differently in your view is that they should be in lockstep you can look at the spread right and you can do just you know really basic you know rolling z-scores and say okay I just want to check and like every time the market gets out of step and actually values these two assets differently I want to buy the spread or sell the spread and assume that the spread is going to collapse back down so really really simple intuition which to me makes it a good candidate for you know an individual sort of coding something up the data that you need is just pricing data so if you're doing this and you want to do it on like a daily strategy that data is available through like Yahoo Finance or Google Finance if you're doing it through quanto peein you can use our minute level data so the day is pretty accessible the capacity yeah okay that's definitely an issue with pairs trading so you're talking about like two securities so depending on what two securities you pick you might have a pretty small capacity strategy if you find what you think is an interesting pair of trade with like a profitable spread and you try to put very much money against that you know very quickly you could you could collapse that trade so what are some common pitfalls I mean ugh like so just data mining like so you tell someone about pairs trading and I guarantee the very first thing that any engineer and mathematician will say is like okay I get it so let's write this thing that then scans every possible pairwise combination of every set of assets and we don't care what they are at all or if they're linked we'll just find out like when this happens and obviously like that can work you know like that's a you know been a profitable thing at certain time scales but in the retail market where you're not having any latency advantage like the idea of really just sort of blindly data mining I view it as like a common pitfall so I try to encourage people like try to understand that you are finding two things that you think are linked to the same the same underlying value okay so I this is a sophisticated audience I don't need to go through the simplistic examples here but just you know a graphic to give the idea of you know what you're doing basically is looking at the distribution of the spread between these two asset prices and you're basically saying you know I want to notice when the asset price spread comes into the tails of the distribution and like by probability it's going to go back into the middle of the distribution so that's what I want to do I want to buy the spread sell the spread and bet that these the pricing between these two socks is going to reverb okay so here's a nice example of a Paris trade that oh peter is Peter here okay so who whose american name that I use is Peter is one of our New York meetup members so he contributed this strategy and it was one of our most viewed strategies so I thought this would be a good example and let me here alright we'll do it at the end if there's time so what I wanted to do was jump out and show you the code for this algorithm I'll leave that as an exercise for you to find on your own or I'll see if I can get to it at the end but basically this is an example of what a back test looks like after you've coded up an example pairs trading strategy so you know just like I said you've going to take these two stocks and and try to trade the spread between them and so this is how the strategy has performed you can do some really basic stuff on our site that's sort of researching mostly it's aimed at back testing and live trading but you can create a custom plot so here he's gone ahead and plotted a lot of the intermediate steps in defining the para stream so you can look at what are your inputs in a model that you're putting together and plot those through time okay so so para straight is a really common example and then momentum trading so intuition behind a momentum trade right is that you're going to look at you're going to be looking for what you think is well my view is looking for basically the behavioral bias of hurting so the idea being that when a stock or a sector or industry is doing well there's maybe some information really underlying like why there's an appreciation of price in that area of the market and that information even in the Internet age that that type of information and buying into that disseminates at like a much slower rate than you might think if you you know sort of subscribe to efficient market theory so this phenomenon is well documented of course a lot of places it's you know you do have high levels of efficiency and you know you're not going to be able to make money off of this but there's still corners of the market especially if you can can trade in small capacity strategies where you know momentum works I mean there's a reason it's still one of the main factors in you know a lot of quants like large multi factor models so common pitfalls reversals can be devastating especially when using leverage I think that's the easiest way to say that so how would you code this up in quanto pianore in a python method so what I think is the simplest way to do it is really simple rules based approach so one thing that you can do is basically rank a universe of stocks based on the returns price change over some prior horizon and say great I want to buy the stocks that have had the most praised appreciation in the last week month what have you I know the research group that I used to work with we did a lot of stuff with multiple time horizons so we would look across you know how efficacious is various trailing windows of momentum and we would create like a blended average of those and there are some really really simple examples of that that you can take a look at so here's one so this is posted by another quanto peon member and he's actually looking at so another popular celebrity on our site is meb faber so also if you decide not to pimp your strategy with Ernie Chan's name the vain favor is another really good one to use yeah yep on our site so we actually don't let you download the data so the part of the way that we're able to deliver the service for free is that our deal with our initial data vendor and the deal that I am shopping to lots of other data vendors is we're not a Redistributor of data we're a redisplay for data so you can't actually download our data the way you can the data from quando but you can basically run your back test and then live trade there are still restrictions given that you're running it on our servers and those will probably change and will probably end up when we eventually have some sort of a paid model will probably like allow you to pay for a more server space but right now for bandwidth constraints when we're running minute simulations we limit you to selecting like a hundred CID universe or our stock universe and if you're running we have a daily simulation mode which you can use to basically try to get either like a larger breadth of stocks a couple of thousand stocks maybe one or two thousand if you're running over aggregated daily data so yeah we throttle that which is mainly to control like our hosting costs there's no like technical reason that we have to do that we don't we make it really hard for you to pull anything off of the site which is basically to try to assuage the concerns of our data vendors I think that it's a very reasonable request to ask to be able to download stuff like your transactions and positions tables and those kind of things right now you really can't do that in any convenient way but I think once we solve the like security concerns that like let you parse what's your content that you created from the vendor content then like we'll make that easier okay okay so what I'll do I'll see you at the end if I can hop out and show some examples in code if I can get some IT support but also I'm going to publish these slides and share them with you guys so you'll have all the links to these example strategies you can go take a look at the code yourself all right so valuation everyone loves a bargain this is supposed to be Warren Buffett I think in this cartoon or they should love a bargain I guess the idea is that not everyone realizes an appropriately value is a bargain otherwise this wouldn't work but the idea is to basically use fundamental ratio analysis in a systematic way so look at stocks that are trading at what you think are cheap multiples and try to find cheap stocks and buy them try to find expensive stocks and sell them perhaps exploit some differential sorting of the of that using using those metrics so the problem with this type of strategy is that it requires good data coverage so it requires data that we're not providing to our users out of the box right now requires yeah it requires understanding what you're doing so it's easy to say like I'm going to look at PE but if you actually want to be able to go and grab the PE or create the PE for a very very large universe of stocks across multiple sectors there's issues of normalizing that data there's issues of knowing the fact that different companies report at different times and aligning that the PE you're looking at and comparing two stocks on is actually for the same calendar eyes time period lots of headaches of data manipulation and overhead there so this is a little bit harder capacity you're going to want to buy lots of risky small cap stocks which will look great until you get totally screwed and some and my favorite I'll say yeah some cheap stocks are cheap for a reason that one I really thought of when my friend was explaining to me that he reversed his Bitcoin arbitrage and as on Mount GOx the price of Bitcoin started to go through the floor they realized like this is the stealing bitcoins we're ever going to get and there's like buying more and more and more bitcoins right until the exchange froze so that's really an equity example but there's the catch a falling knife at it some stocks are cheap for a reason so how would you implement this it's reasonably straightforward if you decide to grab data from Quan Dell for example and and this is the example I'm going to show you does that so inside of quanto peon we've got a method called fetcher which basically lets you grab CSV data from anywhere on the Internet so HTTP HTTPS if you either create a CSV file of your own data and post it to a public Dropbox folder you can grab that you can grab data straight from quand L so when Tamara showed the little like drop-down grab this data to excel they also have an awesome generate the API call for this data and we've built a method that basically is wrapped around that and they've been nice enough to share with us like a large authentication key so that users that want to basically directly plug Kwan Ville data into our back tester can do that we'd love to like keep making that easier and easier so anyway you need to get that data what if you've if you've got the consideration now where you've got you know comparable PE value across some universe of stocks then you're now you you know most of the battle is one you're going to rank that universe of stocks based on the PE and you're going to decide that you want to buy or sell one one side of that distribution in practice you know quant models you know hedge funds or institutional shops are going to do really complicated versions of this where they're looking at lots of different backward-looking ratios they're also going to look at forward-looking estimates ratios which sautéed is even more difficult to get a hold of and align properly and they're going to make lots of sector-specific adjustments and add other bells and whistles but at a simple level if you have you know a couple of fundamental ratios you can sort a universe of stocks and surface some interesting ideas in a systematic way a lot faster than you would be able to do you know one at a time that researching them so this example I hesitate to point you to because I just checked and I think we need to update our kwon dole link but there's a great example that I'll make sure it gets updated and if I could show the code we'll see if that'll work you can grab basically all the fundamental ratios from quand elle and pull them into quanto pian and this is a really simple algorithm that uses like one ratio and sorts a very small universe of stocks which is why it looks so awesome near the end here it's just a couple of stocks so so evaluation is something that I think if we made the data easier to get at we'd see a lot more of but you are seeing people do this okay so sentiment the example that I want to use for sentiment is one that I worked on a lot in my past life as a researcher so short-sellers the intuition of trying to look at shorted stocks as a sentiment indicator is basically that shorting stocks is hard and expensive and risky and not everybody is willing to do it and the people who are willing to do it better know what they're doing or they're not going to be around to do it tomorrow so we think of it as like the smart money basically looking and seeing how much short interest or how many shares are short in publicly traded stocks is publicly available data you can find it for example on NASDAQ has a list of the short interest levels of all the stocks listed on their exchange for the example that I'm going to show I think I scraped Nasdaq site and grabbed like a static historical or a static snapshot of short interest across a universe of securities so this phenomenon is also you know documented in the in the literature it's not like a revelation one of the constraints about the data that's available so I said like you can find it you can scrape it on Nasdaq but it's not perfect the requirement is that the this data is made available by monthly so every two weeks the exchanges have to report the short interest level across all of the stocks that they they're listed on their exchange but for whatever reason they don't make it public for another five days or something like that so not only do you have like a pretty low frequency snapshot of what's happening with the free publicly available data it's your also lagged in time real time daily short interest data aggregated from brokers is available for a pretty big ticket price I think it will keep coming down but as you can imagine like that's that's valuable data capacity the capacity can be small of course I guess it's kind of the same caveat for all these strategies like it can be a small capacity strategy depending on what stocks you're trying to trade and of course people that that are so we built a model around this data set when I worked for a quant Equity Research firm and as I would go and try to explain people like this is so awesome you should totally follow what the smart money is doing and we pitch this part of it the biggest pushback we would get was like that's great so you want to put me in a lot of small cap highly shorted stocks you'll need a short day and so what am I going to do when there's a short squeeze and there's like liquidity constraint and all the shorts are trying to unwind their positions so that's a very valid concern and it's something that you want to be aware of one of the ways we tried to address that problem was we tried to basically overlay like a volatility type signal to try to look for are there stocks that are heavily shorted but basically are less risky we tried for a long time to find a short squeeze indicator and I know like if you could truly say you had found a good short squeeze indicator that was predictive you could sell that for a lot of money because because people are afraid so like so afraid of getting caught in short squeeze we could not find anything better than historical volatility to basically predict future volatility if anyone has a short squeeze indicator you should post it on Timur's I'm Kuan DeLand sell it just people would buy it okay so how do you implement this basically you rank the stocks in your universe based on so I said there's a short entrance level you need to normalize this right because different companies have different numbers of shares outstanding so the way that people normally build a sentiment signal on short interest is they take some normalized ratio so maybe days to cover is a commonly used number so take the number of shares that are held short and divide that by the average daily trade share volume so you have some sense of the days to cover name means how many days of average daily trading would it take for all the shorts to unwind their positions so if that number gets you know higher both there is a bit more bearish sentiment about that stock out there in the market but also you know by the same token the risk of that stock having a squeeze potentially you could think of as going up because if suddenly something happens where you know that stock is not a good short anymore like they are drug company and suddenly their drug does get approved by the FDA but everybody thought it wasn't going to it would be a great example of when having like a five-day unwind of all the short positions could be a very painful position to be in okay so that's the signal that we're going to use and so this is an algorithm that actually I collaborated on with Faust John Fawcett the quanto peon founder and we posted so basically it has a static snapshot of data in it it would be cool actually if someone would update this but it basically grabs historical days to cover for universe of stocks and ranks them and shorts the most shorted stocks and buys the least shorted stocks so again we've plotted what the turnover is some some you know intermediate steps in the in the process that we wanted to look at and then all of these by the way I'm showing right of course are are posted and you can find them via these links but they're also in our community page so I guess I should point out they all come with this little button in the upper right that says clone algorithm so they're all of these algorithms are open sourced and you can copy them because you can see you know 379 people decided I want to copy this days to cover algorithm and play around with it modify it and use it maybe use it okay question on that one yeah we don't have that in art so we don't have that I would have to look at the IV demo account and see what they do the borrow rates is really valuable data and I think you get it like from the broker when you're trading but I don't think that we can get it and like roll it up and build a model at least not like easily I think that that's like area where that's basically that I would say is in your is what you're going to get in your walk forward testing with like actually putting some small amounts of capital in there and seeing I don't think we have and they it's probably worth us having that conversation with them again so we've been like a little fly buzzing around the elephant that is IB but we're actually starting to get some good traction and more and more people going and opening accounts with them saying oh I'm here because I want to trade with quanto peon so they might be more willing to talk to us yeah we don't have that right now right now our slippage model basically we have like a volume share slippage model and so it's really just basically driven by what does our historical like volume data look like and so we say okay you can never be more than 25% of the volume in any given minute or day and then we penalize you and adjust the price like based on what how much volume you are so it doesn't have like you know it doesn't have that data there another question No so right now we support market orders and limit orders so all you can do is you and like one stock at a time so Ivy has like I don't even know how many different or methods and they have like pairs and baskets so we don't have any of that yet we have like the very simplest case you basically can say I want to order you know Apple 100 shares and it will end its a market order it will go straight to IB and it will get filled we use one execution algorithm right now which is their smart order router if you're familiar with execution through IB we tried using something fancier and we caused more harm than good so we started we're starting off with sort of the simplest case yep yep so you can basically kind of create your own you know baskets but it's not like it's executing as a basket through IB you're not getting guaranteed that it's going to get executed together or anything like that but we have had lots of requests for lots of different order types one that I really think we should do is we've had a lot of requests for so if you have like a you know we have the structure setup where you could order every minute but if you really want to be trading and rebalancing on like over the course of a day and all you want is like view op over the day execution we don't like we make you write the code to like you know execute the order yeah it felt like a little bit owner us right now so I think that that one I would view is like highest on my list to add is like view up over the day I think would would be like really helpful to do a question yep you can see your P&L so this is this screenshot is doesn't show you the full back test results panel if I can get figure out how to get out of the presentation mode I'll show you when you actually get back test results you have a bunch of different tabs with like your unrealized gains and losses your transactions a bunch of other like the risk statistics broken out so we have you know we have some amount of stuff if we don't have what you want click feedback and say this is what I want I don't think we have like a portrayed like an average portrayed P&L which I think would be really nice okay so seasonality I will just go blow through super super quickly there are like these are real popular on the Internet's so looking at are their calendar driven fun flows or seasonal things like selling may go away or January predicts the rest of the year so is there simple stuff about the calendar that like is just tied to either structural things in the market or behavioral things that just are persistent anomalies so these are these are great to try because the data you need is just the pricing data plus a calendar and the capacity of course you know if you actually think you find something that's systematic with big you know liquid securities then you could have a good strategy the simplest example would be just basically trying to use seasonality and time the market I like this one just because I think it's like people will ask me like I would like to try playing around with algorithms on quanto peein but I don't know how to get started maybe I know Python maybe I don't and this is like the simplest possible example that I think you can start with so this is an algo that I put up that just says I think it was me I don't know yeah it is it just says sell in May and go to bonds and when you get to October buy back into the stock market and what's fun is it's like the simplest possible case type of thing but you can get a feel of basically how you can some simple systematic rules and look at performance through time and people liked this one okay so we reviewed those five basic strategies and I said I would show you what has been popular so this is sort of the first slice of the type of analysis that I think is going to become really cool for us to do and then share which is now that we've gotten you know 17,000 quants quasi quant scientists hackers aspirational people in the field together we can start looking in aggregate at what they're interested in what they're doing we were not looking at the proprietary algorithms that they write but once they're actually really doing lots of live trading we'll be able to know in aggregate also how they're doing so this is the first slicer first sort of view that I thought of taking on that which is I basically just ran a query looking at every post that had ever been posted to quanto be ins forums and I ranked it I ranked those posts three different ways so how many times was there are how many replies did the post generate so what were there are things that generated a lot of conversation on the conversation threads how many views did they get so was this something that you know maybe that people didn't talk about a lot but you know quietly we record every time the algorithm is viewed so quietly just everyone's looking at it and then I looked at how many times was it cloned or how many times did someone come to the site find you know my finds any chance you know an implementation of a Paris trading strategy and say yeah I want to copy that code into my own account so I ranked the universe three different ways and then just created a simple combo rank and thought it was cool to look at what were the top 25 most shared algorithms of all time and so from these I called that sort of set of five kind of classic strategy types which are the ones I called are highlighted here and then I added the valuation one so I think this one really if someone can explain this to me so the there was a paper that was published by I think this guy Tony Cooper looking at using Google search terms to predict market movements and that's like a pretty runaway success on our forums even though if you go and look at the thread like the thread is basically all about how it doesn't work and it's over fitted to like just a debt keyword at a certain specific historical time and like doesn't seem to have so I really don't know why this has so much staying power like it goes away and then like someone will find it and surface a link to it or like tweet about it or do something and like everybody's back I think these are just people really wish the Google search terms predicted market movements and this is like a view of that I don't know but a lot of the other stuff in this top 25 list I think really is pretty interesting content that surfaced yeah yeah yeah okay so Omar is something linear regression which someone in here must know okay so it's like some like certain type of linear regression strategy I forget what it exactly stands for online moving average reversal that sounds right so it's like an updating an updating mean reversion kind of thing I think people also love when you post stuff that has like long complicated acronym sounding things or like just really hard math terms like they I don't know that is extremely popular as opposed to just some simple like this thing makes money and then I feel like nobody clicks on it but if you're like you don't know what these letters mean together people are like that is probably gold I want to get that one I think that's my interpretation is there another question oh here second part of your question so we don't have I don't think we have enough data on real money trading to get meaningful results of profitability yet so so on the back testing results I haven't looked at that yet I'm actually getting it cleared with our board that I'm allowed to do that I think it should be fine so we take really seriously like as you can imagine right if you go and tell people I want you to take your money printing algorithm and upload it to the internet to a website where you have this password-protected thing and we're going to rent it for you against the market and we promise we're not going to steal it like you have to do a lot of work to build the trust that people will do that so we take that extremely seriously we take our security really seriously we store all the algorithms encrypted and we don't look at them ourselves we unencrypted them to run them against the market and then re-encrypt them and we have a internal system that logs any time anyone ever goes and - someone's algorithm and it has to be matched up to a request that someone submits where they have to click a link that says I'm having trouble with my algorithm I would like you to go look at it and debug it for me so that's a long way of saying I haven't started looking at the aggregated performance data yet right now we have about a thousand algorithms that are running live in simulation so we know that they're out of sample testing they're an algorithm that someone has deployed against our simulation engine so it's getting 15 minutes delayed pricing coming in every day I think that would be the first most interesting data set to look at that like actually has enough algorithms that there'd be something there and then you know we're building out more data every day on what people's real money trading looks like and my goal you know what I feel like we'll be successful if we can find people that can write profitable algorithms so like for us it's important that we can have some means of knowing that people are doing well to the best expectation we could have and then I think if we can do that and in a way that doesn't violate privacy we can communicate that back out to the public I think that would be like really interesting to people and would be helpful yeah social network Toro and the interaction among yeah so our our seed funder spark capitol is an investor in eToro that's what it's called something like that I don't know if it will drive profitability I think that there's a very there's a huge pent-up I think demand among people in the quant finance world to actually like talk to each other and understand what people are doing and be able to say okay we're going to keep our proprietary alpha secrets but there's all this stuff that's commoditized you know out there and you know we can actually do better as a community then we can staying completely siloed so I don't know if it's going to drive like people's individual algorithms profitability I think it's going to be meaningful for how quants interact with the marketplace for their services in the long run so I think there's been like a trend to be more open and FERC wants to like actually capture more of the value that they create or that sort of like part of our vision and I think by giving them a platform that's not linked to their day job that's open where they can talk with their peers like that can potentially be a valuable thing and also it's certainly a learning platform so if you get folks that are coming in that are totally new to the field and then you have people that are experts that are for whatever reason willing interested happy to talk with them on our forums and certainly for those people who are coming in who don't know that much you know their their probability of success for sure is going to go up because they're going to see you know one thing I love is people will come on and we don't currently have a margin model like baked into our bag tester so which and if someone would like to write a margin model and contribute to our open source project I'd be great we're working on it but it's not top yet so what happens is people come to the site and they clone like a sample algorithm that we have that says you know buy Apple and they set it up in some way that basically just buys Apple every single minute of every single day and we don't stop them from doing that so they are like this looks amazing guys I found this strategy which is like long Apple and it kills it because like it's just like free leverage for like five years following Apple go and what's great is like so people will start and they'll make really common mistakes and then like three other people will be like Oh buddy you know you caught like you know first rule of like you know go back and verify like that you're not trading more than you have so seeing that people are able to learn from each other in this like safe environment without like hopefully starting off and putting real capital at risk I think that's another big part of the value okay so here's the current breakout of how popular each of these classifications of strategies have been and so just like we thought right so momentum and mean reversion are you know the ones that we really have the data to drive they're what's popular right now what I'm really excited to see is how does this picture evolve over time as hopefully we achieve our goals of adding more and more content to the platform that's accessible to retail investors price points so I'd imagine that if we can and actually you'll notice values not even on here so I put in that value screen thing with cuándo but that did not make the top 25 most viewed algorithms so what I'd love to see is you know as we get more content that you see people starting to adopt like a broader spectrum of strategies and then of course what's going to be awesome is if we can show here like what is the universe of strategies and which ones are actually profitable at an individual level I would be really excited to be able to come back and show those results and I already said what's missing okay questions they're only in Python so you can see what I'm doing now yay alright so right now they're not there's like no way of sorting so the community this is what the community thread looks like you see what is most recent and everything gets bumped down we have like a search capability so like if I want to type in honey Chan there we go so here you can see like here's the strategy or actually this is more recent version this is a good one so here's a more recent version of that same pair trade that I was talking about so this guy Aiden who I then actually connected with on LinkedIn and I think he lives in Australia and works for designing like autopilot and navigation software I now I'm LinkedIn connected to at least five people who are autopilot navigation software or missile guidance so if you need any expertise in missile guidance I have like a new really core competency in my network of that so anyway here's an example right so I can search by name I found out an algorithm about Ernie Chan so Aiden's posted a pose where he says like oh hey I wrote this strategy it's right from Ernie Chan's book here's a link to his book there's a previous version you can go to that here in this case I used a common filter people love that because it sounds mathy so here I can go see his source code so it's Python so really quickly sometimes I'm running out of time but I did want to show you this the way our back tester is set up is there's basically two methods that you invoke so you can import any library that we've wait-listed if we haven't wait-listed it you can ask for it if it's a library that has hidden in it something that says like open all your source documents and email all your data out to me like we will not waitlist that that's mostly what we get asked for like somehow but anyway if we don't have it we'll try to waitlist it we do a lot of stuff with pandas numpy sci-fi etc so there's an initialized method that gets run once at the beginning of the backtest or once per day if it's a live trading algorithm so here you can do stuff like say what stocks you want in your universe so we have our own security identifier and I'll clone this algorithm so I can show you how that works and how you add so if you go to the forum and you copy somebody's algorithm you get brought to our IDE so you get this window where you can start writing Python code let's say that you wanted to try some different stocks so like you can basically go in and start to add another stock that you might want to look at so we have our sid method lets you look up stocks by their name so like let's say i wanted to look for facebook so we have an auto lookup that lets you start typing the name of the stock and it will find our security identifier that we use so you can add securities to your universe here this is where i mentioned there's methods for setting a slippage model and a commission model they're zeroed out here but you can put in if you know your commission structure you can put a fixed commission per trade not better there you go okay okay so then so the initialize method gets run once then this handle data method right here which goes a little bit on below the page this gets run every minute so if you want to run a strategy that just needs to execute like at 9:31 or one certain hour of the day you just basically put a wrapper in this that says if it's not the time i want to trade pass but this handle data method gets run once per minute so at most you can do something once per minute submit orders to the market once per minute so this is basically what you have access to the only UI settings are over here so you decide like I want to run a backtest from what date to what date what's my initial capital B is going to be do I want to run this as a minute simulation or do I want to use the daily back of the envelope simulation and then you can run a build on that oh and I did it for dates that are in reverse order we'll see if it builds so you can build it and you can back test it that's telling me that I added a stock that doesn't have a date range that's overlapping with the other stocks so let me really quickly go and see I thought there was like one other example that I wanted to show well let's just go look here what I owe ya I know okay since I have this browser open there's one last thing I want to show this will take a second to update so still with all the like research stuff what people really care about and are interested about is that they can write an algorithm that they then deploy against their own Interactive Brokers account so this is my super simple past algorithm that's deployed against my Interactive Brokers account when you open up a live trading algorithm the plots update like through history so you get to enjoy the painful early drawdown that my strategy had in the first few days and I really almost turned it off I was like oh it's just tracking the market but I just can't take this this downside of like the first week of February so what you're seeing here is if the window fits so here's what you get in your live trading dashboard you get a performance like equity curve basically your algos performance in blue against the benchmark in red you get to see what positions you hold so I have a strategy that just buys equal weighted of nine sector ETFs and I want it to be sort of testing at Trading's working so every single day it's actually checking is it still equal weighted across these nine sector ETFs and if it's not it's placing trades so I can see right here my current positions like as it updates through time and then I can see down here what orders and fills have I placed so when I launch this strategy on January 24th you can see I placed a bunch of market orders for these nine sector ETFs they don't move that often they don't need to be rebalanced every single day I'm doing that so you see okay every day like maybe I'm at most like a share or two out of line with one of these and I place those orders so when I look at this like right I can go back and say what was the source code that's deployed that is under the hood and this algorithm that's deployed against the market so I can go and see that source code and I have an ability to log information out to myself I think this one just tells when it rebalances so nothing particularly exciting yeah you can't that's another really commonly requested so the benchmark is just the returns to SPI right now we have a long list of API feature enhancements and that's like pretty high up the list but right now you can't do that yeah I think I have time for like one more question maybe okay good we don't right now and that's like a daily licensing thing so right now the only way that we let you select a broad swath of stocks in like an unbiased way we have a daily dollar volume universe that we compute so you can use it's called like set universe and you can ask for some tranch of stocks based on liquidity and we update that universe quarterly I've been looking at so I've been looking at lots of different
Info
Channel: Python Quants
Views: 130,420
Rating: 4.9001188 out of 5
Keywords: Quantitative Analyst (Profession), Python (Software), Building (Ontology Class)
Id: nCKzRY_JV4c
Channel Id: undefined
Length: 58min 40sec (3520 seconds)
Published: Tue Jul 22 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.