Timothy Clayton: My Adventures in Automated Crypto Trading | ETHDenver
Ethereum Denver Meetup · July 2016 · 1:06:06
Timothy Clayton, who comes from an economics background, shares what three and a half years of automated crypto trading have taught him. After a quick tour of random walk, fundamental and technical analysis, he explains why he runs a market maker bot that keeps a buy and a sell order open around the price and profits from the spread, using no technical analysis at all. Tips for developers cover API rate limits, tick and minimum order sizes, partial fills, quiet exchange sandboxes and testing against a fake exchange. He reports an 8.8% gain over one trading cycle in a falling market, describes switching from Bitcoin to ether, and warns that money is at risk. Audience questions turn to rented bots and arbitrage.
Speakers
Topics
From Ethereum Denver Meetup, hosted by ETH Denver.
Transcript
[Music] you know I have a background in economics so that's not business that's not Finance that's not investment so I'm coming to it with a little bit of knowledge but not a whole lot in terms of you know what might be going on in the industry so I hope that you know what I'm able to share with you tonight in terms of uh that experience maybe spark some creativity uh some motivation might say give you some pain if you decide that you want to go about writing a Trader um so yeah go ahead and get started uh I'm going to give you an overview here of what I'm going to talk
about I want to take just a real quick look at uh investment schools of thought there's only the big three I'm not going to spend a whole lot of time on this but I think it is some important context that might feed into any ideas that you might have about a Trader I'm going to talk a little bit about what my goals and design criterias were when I first started doing it um since I've been trading for three and a half years if you're currently on the exchanges whether you're involved with they manually or in an automated way and you just got onto them and you find them sometimes frustrating uh I wanted to give you some information that let you know they have actually improved quite a bit so they're they're on an arc that's trending towards um you know easier user experience API client type
experience then I talk just briefly again about some various automated trading strategies and this is where at this point in this talk I want to get a little bit more technical for the developers that are here it was kind of hard thinking about how put this together knowing that the audience is probably going to be half and half but um this is where I wanted to get just a little bit more Technical and provide some information that's uh kind of Broad and true for all the exchanges and maybe give you some tips if you haven't come across these things before and then the last thing I want to talk about is a market maker bot a market maker strategy uh is the one that I run and here I'll get into you know what it is uh there's a lot of different ways to implement it but I wanted to
show you guys specifically how I feel about implementing that strategy um and then we're going to look at some performance metrics on how it's done uh there's a couple of trading cycles that I wanted to look at that we can talk about one being the most recent uh during the Mayhem that happened over the past couple weeks um so yeah let's start here with investment schools of thought uh the first one is called random walk and this is a tenant of that that school of thought it says a long-term Buy and Hold strategy is the best and individual should not attempt to time the markets attempts based on technical fundamental or any other analysis are futile so that's a pretty strong statement there and kind of in opposition to what you think of when you think of writing an automated Trader generally you're thinking of using some kind of technical
analysis to predict where the Market's going to go that you can take up a position and take advantage of that knowledge uh past movements or directions of a stock or overall Market cannot be used to predict its future people got that that's good so uh this is Bert mackel who wrote that he wrote it in the early 70s uh it is a well-respected academic Theory and um yeah I just like to share that because I I don't think a lot of people know that but there's a well respected theory that says you can't do technical analysis and I should say the way that he proved it was he looked at these managed funds and he showed that against the index they weren't beating it so he had a lot of supporting data to go along with
that fundamental analysis that's really just looking at an intrinsic value Company by that's financial statements so you're trying to get an idea or a sense of what the company is worth from quarterly reports and reports balance sheets and once you make some kind of intrinsic determination uh you might look at the stock price you're probably more interested in the dividend and then you make a decision about whether you're going to take up a position on a company and this is where you can just think Warren Buffett he's a he's a heavy fundamental analyst technical analysis uh I think we're people are probably familiar with what this is but it basically says that market price movements are not particular random um out move in identifi that looks Crush there patterns they move in identifiable uh patterns and trends that repeat over
time so this is in direct opposition to um the random walk Theory it says that the future value of Charity can in fact be found in these charts and a quick way that you can remember fundamental versus technical analysis is uh it's difference between looking at financial statements and charts and I've heard it referred to as it's a difference between investment and trading which is kind of an important distinction when you think about Traders how they're not really considered in that bucket of investment so the goals and uh criteria that I had when I first started going down this road uh little Burton was in my head there and part of this you know wasn't that I didn't believe that technical analysis wasn't possible um but I've heard and read and I've seen what
happens with the big fish and big fish is the big firms in Wall Street and when you start using technical analysis you get into this horsepower arms rates and it's not about being right it's about being right first if you're not right first you're trading on all information so I wasn't interested in dipping my toes in that pool because I wasn't going to win that game uh even though the exchanges where crypto gets traded actually do throttle and you can only make certain requests per second if you're doing anything outside of that request cycle where you need horsepower and you can be quicker than the other guy uh I definitely wasn't going to have the money uh to be able to afford the horsepower to do that kind of thing we good cool um the other thing that I was coming to this from and this is just
sort of the mindset that I had was that I was kind of looking at this uh as a passive income generator and you know the notion of farming was in my head the money that I was going to put into it was going to be sort of like buying the land and then the bot was going to be uh you know growing and harvesting crops over time so I wasn't going to be so much concerned with what was happening to you know a portfolio value or my R in a day or day out basis uh I was going to be more concerned that my bot was actively trading uh and most importantly that it was going to be able to survive the down swings which I found out really early on um in Mount Co time if anybody remembers that or if you've been paying
attention to crypto for like two weeks and you've seen ether I mean there could be some pretty dramatic and tumultuous environments so one of the things that I got in my head pretty early was that I needed some sort of strategy to programmatically keep the thing alive in trading so tiny fees um they've always been tiny uh even on the exchanges that have the the flat fee but one of the things that's been introduced oh I wouldn't say it's too fairly recently in the last couple years I think lonc uh switched to a make or taker model last year but what ends up happening there is if you put in an order onto the exchange and it doesn't match with an order right away and it just kind of hangs out there
if and when it executes uh they consider you to be a market maker because you put liquidity on the book and you don't pay a fee at all so that's a free transaction for you if you put in an order and it executes and matches right away with an order on the other side of the book you're considered to be taking liquidity off and that's when you'll pay the fee and it's still really tiny that's not 25% that's uh a quarter of 1% that you pay on the total value of the transaction that you're making uh this was kind of a big one for me you know I think after mount gox it might have been every month or two You' hear about another exchange that got hacked and all the coins were gone and if you don't know there's no government institution that charged with or
probably even interested in recovering your coins in that case so when they're gone they're gone um and when gex well at the time this was coinbase it since changed to gex uh they're insured and that should also say uh Litecoin now too they trade Litecoin so yeah that's a big deal so if they get hacked you know I don't I don't know what that process looks like to get your coins back if it's a pain in the butt but at any rate that kind of um Insurance brings confidence that brings volume that brings trading and that's good for an automated Trader in my mind um I had mixed feelings about this but it it kind of was a big deal GX is backed in part by the New York Stock Exchange um so it was big enough for for the Wall Street Journal to notice back
in January 2015 it was the first time in traditional financial institution uh had taken direct stakes in a Bitcoin Enterprise deposits in withdrawals is kind of a a a big one for me back in uh 2013 I was sending a money order to a po. box in Atlanta Georgia um to a to an exchange called Camp DX which at the time was the only us-based exchange uh and it would take two or three weeks for that to get processed the money to get in my account and of course the first time I sent 10 bucks because I'm sending money to a PO Box in Atlanta Georgia I don't know you know what it's like so things are a lot different now um yeah GX even has withdrawal now
through PayPal so that's that's probably one of the biggest improvements that I've seen is the support that you can get from Banks and payment processors okay just quickly I want to talk a little bit about um some automated trading strategies I won't talk about all these but I want to talk about at least the first to oh and I forgot to mention I'm going to put this presentation up on the Meetup Group after I'm done so um even though I'm only bullet pointing these these things if you're interested in in automated trading and maybe you're short on Concepts or ideas about how you might go about doing that strategy wise uh Investopedia has a pretty good page that gives you all these different trading strategies and what they are um but Trend following is going to be a technical analysis Trader and it's going
to be looking at a technical indicator so one of the big ones is you know is the moving a the 50-day moving average is it is it Crossing up or is it crossing under the 200 day moving average and that means something about which direction the Market's going to go so you implement your positions based on that foresight and that information and you probably have some stoploss uh strategy there as well in case you're wrong or the percentage of time that you are wrong um the good thing about technical indicators is you can avoid some heavy data crunching because you're not aggregating a whole bunch of information and trying to do some predictive analysis about what it means all you're doing is you're you're just kind of looking at these you know one or two or a handful of indicators and when they hit the value that you think is
important that's when your Bot would take action so it's kind of a u you know slim way of doing technical analysis and predictive analysis Arbitrage uh probably a lot of people are pretty familiar with that Securities in general that are traded on different exchanges they aren't trading for the same price at the same time always um so in an Arbitrage situation uh you'd be connected to through API to two exchanges and you would be buying on the one where it's cheaper and immediately selling on the one where it's uh where it's more expensive um kind of a kind of a basic strategy um trading range and me reversion um I'm not sure if I want to get too much well I think I have some yeah I got some time I'm cruising jeez I
should slow down uh so meor reversion is kind of a cool idea it's the idea that you know the the oscillation in prices uh you know of a security kind of oscillates around this mean and with trading range you can sort of set up statistically you know these boundaries around that mean and when the price is Crossing in and out of them um that means something so you you decide on you know your entry and your exit points based upon this uh sort of r that you statistically determine around a mean average um the next four there I would actually have to look up and I wasn't familiar with them before I started researching this presentation but um yeah the link down there at the bottom Market maker I'll be getting into
later Market maker is really kind of an odd duck it's a very interesting kind of strategy uh for some reason when I personify it in my head I always think of it like the second basement of a team like you know he's got a lot of responsibilities but you don't really notice them as long as he's not making mistakes it's just kind of an odd duck okay so now I'm going to start moving into a little bit more of the technical aspects gradually though so I wanted to put this this picture up here um you know sort of as a disclaimer that you know trading is a lot of fun automated trading is a lot of fun crypto is a lot of fun but your money is going to be at risk so so be strategic and intelligent and how you go about it start with a little bit of
money I started with $800 uh to me that was at the time that was actually a but I could afford it uh you know don't use your rent and think you're going to be able to pull it off the exchange at the same amount or higher when it comes time to pay rent I just want to talk a little bit about web portals um when you're deciding on an exchange that you're going to be trading with and the next slide here is kind of you know pretty dramatic difference um but it makes a difference when when I was trading on Camp BX and this is like all you had to go on and it wasn't any different if you logged in um you couldn't really tell where your positions were on the book this page would refresh like every four or five seconds and that was pretty much
all the information you had about what was happening on the market um so yeah you'd have to look at your logs to see you know what prices you had positions at what quantity you were at um and for some reason too I think it's it's either GE I think it's Gemini whenever I log into Gemini I can never tell what's going on with the market on that on that exchange I don't know what it is but it seems very difficult to find out what's going on um whereas this is kind of what you would you would expect more from an exchange especially as a Trader I think I got to point a couple things out here so yeah so these are all my positions here that's the quantity and it tells me where my positions are at and what price
they're at it's got my open orders down here trade history I wish I could close that I don't really ever pay attention to that um but you know you got your Candlestick charts you've got the ability to change the time series you can change the type of chart um it's got your USD balance so it's it's pretty rich in information it's it's organized well and it's easy to to log in from anywhere you know when when you're mobile and and go ahead and see exactly get a better idea of where your Trader might be at how do we understand that Candlestick chart um this one's actually kind of weird but that's a good question so it's it's high low and open and close are the four pieces of information that you're looking at um the ones that actually have a wick on
them like this one right here that was the high this was the low and it was the uh the close and then that was um the open the thick part is the open and close the thin lines are the high and the low yeah and if it's red it closed down from where it opened yeah red is down Green is up and when does The Exchange Define open and close that's a good question um dep the inter depend on the Candlestick size it depends on your yeah your time series would determine how the Candlestick is being tracked so they're probably updating it every
transaction so was that a good day or a bad day for you what day was it you're looking at three hours of trading4 slaughtered I'm trading ether that was a good [Laughter] day um so other things that are good to consider and to think about actually really just to know about when you start getting involved with automated trading uh is the idea that every API that I looked at is going to throttle you on the request that you can make over some period of time um so you'll have to have
some kind of throttling logic within your program to make sure you're not exceeding that limit um gex you know three three requests per second for public endpoints that' be something like get a quote get the depth of the order book there's a public uh 5 seconds for private ones would be like you know post an order cancel an order get an order um but one thing that they do that's really nice is they do allow bursts so if things get uh a little high for whatever reason they'll give you a period of time before they start returning 429 status at you um and they're not all the same bitstamp is you know do not make more than 600 requests per 10 minutes and we will ban your IP address so maybe look at the different exchanges see how they they treat these
different things I'm I'm going to go through tick size this is a a good one to know um it's going to be the minimum price movement or increment that's on the exchange so if we go back to this chart here and if you can see how these are incremented that's probably pretty small but almost everybody has a position at a penny so um a penny is the is the tick size on GX and that's regardless of whether you're trading uh well this is USD to to crypto so USD to eat Bitcoin or Litecoin The Tick size is going to be a penny and really the only reason and maybe this is a little obvious that why you would want to know that uh is any math that you're doing to calculate a buy or a sell price you want to make sure that it it ends up being in whole
Penny amounts because if you were to throw in an order for you know $421 12.5 that would be an end valid request minimum quantity of a buy and sell order so that's the smallest amount that you can either sell or buy um it's 01 on GX and again good reason to know that obviously you want to make sure that you're submitting a valid order uh but there's also another reason um the exchanges do not hold themselves to the minimum um order size when it comes to filling orders so the way that I'm going to try and explain this is let's say you're second on the buy side on the
order book and a market order comes in uh for a sell and the the first order in front of you fills everything but 0.00001 whatever of that market order they will take that fraction that is smaller than the minimum order size they'll take it from your lot that you have to buy that you have your buy order for so if you're doing anything blindly where you just buy and you turn around and you sell it to the exchange without even thinking or checking uh know that you'll need to have some logic to check to make sure that your your orders are actually meeting the minimum order size um what do you do what do you do with your partially filled orders do you wait for them to fill um well when I get into my system a little bit later some
normally I do but if a sellor executes what I end up doing is I is I cancel the order regardless of whether it's partially filled or not if it doesn't meet uh The Exchange minimum order size I persist it until later and so you collect all these partial fills and eventually you have a process that runs when it is up to the minimum order size where you can throw it onto the exchange so so you kill your cells if they don't if they're partially filled no I always leave my cells you're doing that locally what's that on your machine you're not using their system to do that their interface oh no no no this is automated so yeah I'm not I'm not manually doing any of this this is all automated um the AO in there is kind of
interesting I haven't seen other than Camp X um CX was kind of cool like they don't get any respect at all but they were kind of cool so they had an all or none order type which said uh if this order isn't going to fill in its entirety don't touch it and that's a little bit different than the filler kills that you see on the exchanges because a filler kill is more concerned with the immediacy of that order so a filler kill will come in and if it doesn't fill it immediately cancels if it partially fills it immediately cancels the balance if it fills it fills but with an all or none it'll stay on that exchange so you don't have to worry about partial fills uh if there's an all or none or sight self trade prevention uh something else that's important to know about um
you can't buy your own sell and you can't sell your own buy that's just the way that it is I never understood it you know it's like I own the cell why can't I do it but it's it's the way it is on on most of the exchanges um almost all of them except for CX again wasn't like that I'll explain why in a moment uh but on GX the default for that it change as if you're putting in an order and it has a self trade event they cancel the newest but you can configure it on your request there's a an STP parameter you can tell it the cancel newest cancel both or cancel um latest uh so know that that's maybe something that you need to work with Market maker doesn't ever really run into it uh I've run into it a couple
times because I put I've manually put orders on the exchange um and then my Trader was trading and it it was that wasn't a record on database and it hit one of my own orders that I put in manually um but CX they would allow the bid and ass to match or cross so you could you could you could see that the order books actually had the same price on CX there was a buy and there was a sell for the same price and they weren't executing and you knew that that was somebody that was had both the buy and sell kind of an interesting way to handle it uh exchange sandboxes honestly the couple that I've looked at they're pretty quiet there isn't a whole lot of activity on them at all so I I think they're really good for
confirming um you know that you're making the right type of requests and you're getting back the expected responses uh but in terms of testing your strategy in a quick way there's just not a whole lot of activity on them at all what's an exchange sandb uh it's like a you know it's a playground environment that that exactly matches or should exactly match um sort of the rules that are that are on the exchange and you can put in orders you can cancel orders you can place orders they usually give you fake money like you know $10,000 or 10,000 coins to do trading with um but it still requires a user or an automated system on it to make it move and to do stuff and usually there's just not any activity on the sandboxes so it's kind of a development environment um
environment for Developers so yeah expect to be developing and fine-tuning your Bot against the live exchange so again be smart with the amount of money um that you're giving to your Bot initially and if you're really rich don't worry about it I guess you know for me it was it was kind of a concern and I had to think about how I was going to um use my funds and still learn and make mistakes at the same time without paying too big of a price exchange idiosyncrasy so this is just kind of a category that I want to talk about CU you're probably going to come across stuff like this these are things that you can't really find out in
the documentation you're only going to find out about them once you actively start trading and you start to realize the behavior of the API that you're interacting with um on gex when you put in a request for a cancel it doesn't always mean your order canel even if you get back to 200 even if it says yep okay more of like a request to cancel the order and they're like okay we'll get on that um and you got to come back and and see if it actually filed or not but overall I mean honestly GX is is pretty impressive with the amount of volume that they do and I'm sure other apis have their have their little OS synes as well so my one of my sort of secret
dreams when I start this was I was going to I was going to write some code and I was going to run it and then I was just going to cash checks I wasn't ever going to have to touch again um and it's not really true I guess deep down side I knew that but you know the API uh will sometimes change their their responses uh the API will change in ways that'll break your code and sometimes it's a good thing you know the changes that they make uh it's happened twice since I've been trading on um GX which I started trading there I think May of last year and uh you know they didn't have a bulk cancel end point so they took their single cancel endpoint and they made it so that you
could get uh multiple answers multiple cancels um executed executed on the cancel executed at the same time uh you used to get back a status okay um you know Json hash and uh when they changed it to a bulk end point they now return an array of IDs of the orders that that canel so um some might say that's Improvement on the API but just know that the apis are going to change and and you'll have to be doing work work them plus you'll you'll be doing a lot of things yourself uh you know with your strategy that things that you'll get motivated and eager to try and so you won't really ever get the to set it and forget it State uh the other thing that I found was that you know along the same lines
here with maintenance is that you find that you're you're part fund manager and part developer so you know I think it's a good ide I pay attention to the news a lot more than I did uh what's going on in the crypto World specifically with the crypto that I'm trading happen to be trading at the time um I want to stay a breast of developments you know not only with you know market and what's happening with you know Partnerships that are forming with the banks but also the underlying technology um to get some kind of sense that there's something that might be happening down the road that I need to just be a little weary of and make a decision of whether I want to just like stop the bot for a little while and see how things shake out um I did that with the fork um or E classic I
I had seen you know they knew it was coming I saw information about it um for one GX wasn't going to support classic uh and and I really didn't know how much support there would be for uh new eth and how it would trade would there be a lot of activity and interest around it all these things so I would just encourage you you know I guess it's pretty good to push that envelope of set it and forget it and try and get it as maintainable as possible but don't let that get in the way of you making important decisions you know around when you need to actually stop byy when you think it might be good to just wait a little while see how things pan out so I want to talk a little bit um about testing and putting together your
test Suite um I'm not sure how other uh languages or Frameworks might handle this but at least in rails I'd read a blog post by thoughtbot and you know it said if you're building an application or program that's essentially the client of an API they give this tip about how you can build out a fake Exchange in your test suite and uh use Sinatra to do that and you basically just set up endpoints that match the endpoints on the exchange um if you're using a library maybe look at the source code and see the the endpoint that they're calling underneath that uh or you can look at the documentation all the apis have pretty darn good documentation um and then you configure your specs to say hey anytime the
application code tries to go to api. G . send it to this fake exchange that I built over here and um the responses that you serve up are read from Json files that you also have uh in your application and those Json files you can populate with real requests into either the sandbox that you find to use a Sandbox for that or making an actual placing or or getting or whatever you need to perform against the the real exchange and so the thing that became really easy with this is you know when you're writing out your your specs you now have all these these different little building blocks um you know from the from the Json files that you can create context and create cases maybe you need
to test what happens you know with these series of requests need to happen before that and it just made things a lot easier for me to be able to write tests and have these building blocks to put together the context and I'm a little bit more confident too because the you know the Json files are actually coming from actual responses from the API this one might be a little obvious but I have some uh static settings that I I change the values on um before I do I do trade cycles and as you're writing your test make sure that you're uh changing those every so often to make sure you're not testing just for that specific value particularly if it's something that's going to be sent on like a post that has to do with a price or quantity or something like
that test Network outage so um turn your Wi-Fi off wait for something to happen on the exchange with the orders that are pending then turn your Wi-Fi back on and see how the bot handles it if you're running it locally if it's deployed take a hammer to the server um yeah I was trying to be cute here but this actually happened to me I was I was like why are my test running so slow I don't remember test running this slow I don't even have that many and because I was throttling in the application code my my tests that were going to the fake exchange were actually being throttled as well so override uh throttling in
your test environment for them to run faster separation of concerns this is what it looked like for a long time just a bunch of spaghetti um like I said I've gone through iterations on this code base um and this is something I wanted to to tell you guys that I wish I had done sooner particularly in cases when things aren't going right and something's broken and you can't start up the bot or or start trading again until that's fixed uh when you've got so much code you know 50 line methods 400 500 line file and trying to debug that and get things to work uh can be pretty difficult and you know since I work
full-time when those kinds of situations would come up I would just say well I guess I'm not going to run the bot for a week or a week and a half um so separating things out early on can can help you get quick turn around when things aren't working right and this is kind of how it looks right now uh in terms of how I've separated things out um perhaps not surprisingly there's Trader there in the middle of the diagram and all Trader is responsible for doing is uh placing orders canceling orders and monitoring their status that's all it does if it needs to get any information uh well when it does need to get information about you know bid size or or price that it needs to to put put put in the order
or the quantity uh it goes to decide so decide handles all the math and now I don't think decide is really a good name but semantically it made sense like decide. bid price decide. sell price decide. buy. interval um Sentinel down there in the bottom right is gets called when when things could potentially go wrong so when Trader is monitoring the status and something executes uh it doesn't know if it's a partial fill or not it doesn't know if the order actually canel it tells Sentinel to go ahead and take care of that uh Sentinel also handles reconciling uh sellers uh in the database with what's going on in exchange reest structure was a little bit of an abstraction layer that I put in there because I ran into so much uh challenges when I switched my bot from
trading on um CX to GX I thought it was going to be a week or two but the exchange rules were so different that it actually took a long time and so thinking forward when I want to be on a different exchange I decided to go ahead and take a first pass and how I might be able to make things a little bit easier next time so request us your handles all the throttling it handles all the error handling it handles all the the Json parsing and request is just simply the client Library that's it so it signed your request it makes them into the exchange and it gets them back and uh performance metric is something that I implemented uh right before my last trade cycle uh or one of my last trade cycles that I started on October 21th of last year and performance metric is I
never really used to track stats I would just see what was happy with my account kind of have a mental note of where it was the last time I looked at it and that was enough for me but I've started tracking performance last year how's it in since you started tracking steps uh it's given me some good information uh it's giving me some ideas about how I do things um that aren't necessarily incorrect or not working but that I may want to do a little bit differently so it's it's been helpful so far would you recommend setting that up from the start as another kind of good first step to information or is it maybe if it's your thing I would say yeah do it but um I think it might have also been a distraction and a confusing point for me before I actually you know saw how
things were going and and then I came to point I was like I should track this stuff you know maybe get it up and running first and and trading before you do that but if it's your thing and you're good at it then and and you like it that's the most important thing yeah do it all right so I want to talk a little bit how's everybody doing is everybody doing okay break or all good my brain hurts does sorry question sure I I think one of the the good arguments against the random walk Fury for technical analysis is that when you have enough people watching certain indicators like okay this asset is rolling over from it 200 day and 50 and the stastics are head and oh my God the ma crossover everybody SE this
and it becomes a selfing prophecy right so can you speak a little bit to like the time frames you watch because of course those indicators depend largely on the actual frame so if you're swing trading maybe it's like you know Hour Bar maybe really there it's minutes how do you approach the time I don't use any technical analysis completely zero that was one of my criteria of putting it together which b a question I'm excited to see how how exactly com it's coming shortly it's coming shortly are the Cory ditch strategy of investment curious about
that strippers and coke so this is just the definition from the SEC of what a what a market maker is a market maker is a firm I put or individual in Brackets because I'm an individual uh that stands ready to buy and sell a particular stock at a regular and continuous basis at a publicly quoted price see you all those by walls no no I don't I don't have that much to leverage um so yeah so a market maker really the only criteria is that it always has an open buy at least one open buy and at least one open sell on the market at the same time um so you might say well what
the heck how does that make money well it makes money on the spread and it makes money on Market activity so so as it's sort of straddling um the spread as the market moves and sellers are executing buers are executing it's obviously going to always be selling for more than it's buying so it's got that spread there to work with um and in my case it's it's kind of a rinse and repeat volume type thing like I do that over and over again as much as I can for a little bit of profit uh each time so yeah this is just kind of an interesting uh feature of a market maker when it kind of moves in the opposite direction of what the market is doing so when the market is selling um the market maker is buying and when the market is
buying the market maker is selling some advantages on a make or taker model uh hardly pays any fees so that does go up during High activity but I would say um on normal activity I probably pay a fee only about 5% of the time and that's because as I put my order in before I do that the price moves and it actually hit the market as a market order instead of a limit order um during High activity I think that probably goes up to 15 maybe maximum 20% of the orders that's placing are paying at B so it's a fairly lowcost strategy you know Fe Fe that up uh you can Implement a broad range of
strategies with it if you wanted to bring in technical analysis Kent like you were talking about to say I'm going to monitor these indicators and when they hit something I'm going to stop my market maker for a little while until I get get a favorable indicator you could do something like that um it doesn't prohibit uh you know other strategies there's many things you could do that Sol still fall into the bucket and definition of a market maker um you know you can place multiple buys at the same time I only have one pending any given time theoretically it said that it adds stability to the market um maybe not with the volume that I do but for you know some of the bigger market makers uh since they're already they're always ready to buy and sell they're adding that sort of rigidity and
stability and dependability to the market uh last thing there it can show impressive gains in down markets so uh this is the part where I want to get in to telling you guys and describing exactly how I run a market maker strategy um bitbot was the original iteration and name that I gave to the repo I've tried to change it several times it's now called long shot but bitbot just always seems to be what it's called so so and uh if anybody is works with animation and PowerPoint hats off to you it's harder than building an automated
Trader but we're trying trying boy my goodness I don't want to talk about it so you sort of start off you know the Market's kind of doing what it's doing and this is initiating a trade cycle or a state where all the sellers have have uh executed and it's trying to establish a position as a market maker to get a buy and a sell open at the same time and so the first thing that it does is it comes in with a limit order uh at or near the top of the buy uh the buy side of the book and I call that order a scrum buy because it's the only uh buy order in my application that has bidding rebidding and cancelling logic because
it wants to stay up at the top and if the price Rises it has to cancel and bid again uh so it's kind of of scrumming in an attempt to make a buy and so at some point it ends up executing and the bot's going to do two things after that happens first thing it's going to do is it's going to come in and place a sell for those coins at some price um with a that has within it a predefined amount of profit that it wants to make so it knows how much it bought uh it knows how much it paid for it it's going to add profit to that and that's the sell price that's going to place it at the profit interval there uh is just going to be the different in the price between the sell and and the scrum Buy in this case and I'll talk briefly
about that a little bit later next slide I'll be talking about that actually uh and then it's going to come in it's going to place a buy so once the initial uh buy order executes places a cell for predefined amount of profit and it places another byy ordered some increment below the price that was just just bought at and the difference between those to the buy that just executed and the buy that just got the limit order just got placed is referred to as a buy it on buy down interval oops that's a lasater sorry those two together make up the straddle or the straddle spread uh and at this point uh the bot is now a market maker so the Market's going to continue
to move and let's say it goes down in this case well it's going to do the same thing that it just did last time it's going to place a sell immediately for a predetermined amount of of profit and then it's going to come in and it's going to place a buy the price of what it just paid and that again it's got it straddled back uh of the same magnitude so generally uh the price ends up going back up and that's where you make your money so you make a little bit of profit there and when that sell order executes technically you're still a market maker at this point you've got an open buy and you've got an open sell but what's happened to your straddle spread
is that it's grown so what what I do in this case when a seller executes is I cancel the buy that's pending and I come in and I buy again um at a price that gives me back my straddle so I can maintain that and so the idea of what's Happening Here is you're trying to keep as your buy orders and sellers are executing you're wanting to keep that straddle around the market as the price is moving up and down and just take advantage of the oscillations that are happening normally with price for your orders to execute and how are you coming up with your straddle your appetite for where you want it to be that's a very good question that I will be getting into in a moment I was going to go back but is it always a uh a fixed number or is it like
a percentage of the assets value I was say it's probably a tweakable value it's nominal yeah oh there it is yeah so um the straddle is your profit interval plus your buy down interval together and why I consider these values to be important in this system um is that the smaller that those two are therefore the smaller the straddle is um the more trades the bot is likely to flip because it can take advantage of those smaller micro movements of low activity uh whereas if the the straddle was larger you can have all these Market activity that's happening that isn't firing off any of your trades so if
you're not flipping trades you're not making money okay so who asked the question about how I might deter you did okay so um this is related to surviving the lean seasons and I will say that when I first started running this I would set my buy down interval manually so it was just a hard number I would buy down every two or three cents and I would try and you know sort of look it and try and determine what I thought it should be for for a given period of time and I would run it but I kept running out of money when I did that because the price would drop and you know the market maker is going to keep buying at least mine does and it's just spending money on the way down until the account balance is
zero and all your value is tied up in pending sell orders that it's left in the Wake as it's done that um so it it was really it was clear really early on that I had to develop some kind of strategy to be able to stretch my funds throughout um you know these these lean Seasons so to speak as they happen and uh what I came up with was I put together an algorithm where I could um say in crisis situation you know in in freef fall market doomsday type scenario uh how dramatic of a free fall in price do I want to cover and so I
would say maybe 30% and what I mean by freefall is that on the way down there isn't an intermittent uptick that would fire off a seller this is just straight down and so it gave me some sort of um you know way to think about how I would set that set that percentage coverage I still iterate on and I still think about I still I still feel a little weird about it because I feel like I'm I'm I'm asking myself to predict the market in some way by setting my coverage but since it's in that doomsday realm I feel a little bit better about it because that you know it makes sense to to say hey this is going to fall and there'll never be an uptick to where a a sell order actually executes so it says okay given you want to cover this amount of
the market uh Free Fall drop and given you have this amount of money in your account and given that you're trading this much quantity per buy and sell and given the market price is this here's how many orders you can place in that scenario and here's the Gap in between both of those that your buy down so it gets generated um from a configurable setting where you say I want to cover this per freef fall market price yours is 30 uh I usually run it at 33 but I still got mount gax in my brain like that's pretty that's a lot for freef fall that's a lot to cover now well if it's if it's a lower pric cryptocurrency not necessarily something like made safe that's probably not not good enough you
maybe well they've been dropping about they dropped about 20% and they swing back up and forth so can you short on G and if so can you program your so as of yesterday you can credit invest if you are in EDP or what do they call it EPC ECP yeah the margin trading just opened yesterday on uh GX but you have to be like part of a brokage firm you have to have $5 million minimum of $5 million oh here's here's the here's the weird thing though here's the weird thing so your margin is only good up to $10,000 yeah you got $5 million and you need an extra 30,000 how would a market maker
bought take advantage of a margin trade uh of a of a short a short sell because margin doesn't just have to be used for short you can just use it to increase your Your Capacity to so you would just trade on Leverage Bas yeah that's what I would do okay so I think we're kind of done with that and I Al oh I I wanted to say this you know coverage is not something that you necessarily are going to need for whatever strategy you choose this is not only specific uh well it's not even specific to a market maker if you got a lot of money you can you can just magically cover 80% and set it manually right um for me this was this had a lot to do with the fact that I
didn't have a whole lot of money to trade with to begin with and so I had to come up it was more urgent for me to come up with some kind of system where I could stretch those dollars generally you know well the price oscillation isn't that much in the mean but the range is pretty incredible so it's it's you know this is a five-minute chart I believe so it's just placing buys and sells and buys and sells and buys and sells and buys and sells every increment for this you know 230 to 735 hours um that was just that's pretty incredible or impressive to me that you know did you see this after the fact or were you watching it uh I saw it after the fact but um I did want to say you know in this instance it's it's using the same
dollars over and over again if that makes sense so it's it's it's Fiat balance is not really going down that much it doesn't need to recalculate it down interval I mean it's just it's just flipping trade every trade trade over tra trade so that's kind of the ideal market for it um so yeah I wanted to talk a little bit about the performance of the bot I'm going to look at two uh trading periods here one was uh started on October 21st of last year and I took liquidity on that on uh January 5th of this year uh the other one started on February 11th and I took liquidity on it yesterday uh so one of the good things about doing
your taxes everybody here say their taxes if you do them on bitcoin. tax I'll get the trading Cycles a minute I forgot this slide was in the middle but um you get cool charts from your your trading activity if you do your taxes on bitcoin. tax so there's kind of a story here um at this point I was still trading Bitcoin but I was starting to get squeezed by the price Rising so much that my account balance that I actually had to trade with wasn't going very far so you know I think I was traing the minimum uh quantity that you can trade 01 uh willing to make one penny on a flip trade doing everything I can to get that straddle spread closer and it's still creeping away from me in January February March and April um so I
realized you know hey if the problem is that this security is so expensive why don't you trade one that isn't and ether was available on GX and it was pretty easy it was like a matter it was a matter of adding a couple environmental variables maybe half an hour and I flipped the switch and I started trading eth and things went gang busters at that point um there's an overlap here of 30 days uh of June and July where the bot the little old bot with $3,000 accounted for 1% of volume on the exchange of ether and so it's really you know in July here it's it's almost up to if you add together the volume of the buys and the sells it's doing about $160,000 in
volume um with $3,000 in its account um yeah that really got my attention so uh it just so happened that I I was leaving my job in August and you know I had it took about three months off and I sort of went through a full rewrite um the thinking was you know if this was a a pull request but I want to subit to a cooworker so I made sure I got up to 100% spec coverage added code quality tools went through an exercise of separation of concerns and just made the code a lot more a lot more what I would expect to be doing during my day job and I I think yeah right here at the end I I had a little drop in activity
because of that because I wasn't running it as frequently but uh in October well I guess we can just get to the the metrics so this is kind of the first one that we'll look at uh so this trading cycle October 21st to January 5th at 76 days this was the price at start this was the price at end this low here it fell about 50% in value and it only briefly came Above This start price um in the very beginning of the trade cycle it PR as soon as soon as I started this trade cycle the market pretty much started tanking on a very slow slow curve uh so it was a pretty brutal test
to put through the rewrite that I just did and I'm pretty impressed with how it came out it ended up making 8.8% in a down market and so that was um that was good I I felt like the the market conditions that it was operating in were really tough and it and it did it did pretty good um volume maybe a little low there I did also notice over this trade cycle that um activity wasn't wasn't all that that high but the other thing that's happening is the bot is getting shy because with the 50% drop in price you know the buy down intervals been been spread pretty thin
um yeah I know that when I first mentioned one of my goals of thinking of this in terms of you know harvesting harvesting crops growing and harvesting crops is that I wasn't going to pay attention to portfolio value too much because that to me was a farmer caring about the sellable value of his land instead of how much yield he's going to get but uh to that gentleman's question back there about performance metrics because I started implementing this I did start to notice that you know uh there are times when the Harvest here that's that's the sum of all profits from flip trades and um The Profit here what I ended up doing is I saw that my portfolio value was was up about
9% and I said that's good enough for me I'm going to go ahead and uh take a loss on my pen sells and sell them at market price so if I didn't have performance metrics maybe I wouldn't have seen that that's a possibility so I've come around a little bit on watching portfolio value for some cases do you have your capital gains tax in your trade parameters you think about it like that at all no I don't I just keep trying to flip as many trades as I can and know I'm probably going to pay 28 to 35% off it oh yeah that's a good point though that that Harvest there is what you owe taxes on that's that's all of your taxable events right there aren't you supposed to stay in crypto and
this look at the cool charts you get he's being legit the rest of us are going to get arrested so um this is kind of interesting I actually my first iteration of portfolio of value I needed to make a correction here I had to write a a script to fix this I didn't realize the library is using if you make a request uh in line you get back a paginated results if you make the request as a block you don't I don't know why that is but that's what it is but it was an okay thing because it it was one of those those eras where you're actually doing better than you thought you were but if you notice how market price really kind of portfolio value tracks it you could just kind of move up from here to here with that same
curve in your mind's eye and that's what we're tracking there and I don't know if this effect is obvious but you say like you know you made almost 9% in a down Market but here's here's what's happening with all your flip trades and their profit from that is starting to contribute to your portfolio value and it's overcoming the decline that's happened in the market so as you start to harvest and and flip trades that's contributing to your portfolio value um even as the market pressure might be trying to decrease your portfolio value and eventually it comes over and it overcomes any decrease that you've seen and it happened at I think it was $11.80 88 here when I took liquidity and it started trading at 1204 so that's kind
of the dynamic of the market maker I think that's a I hope that's that's a good chart and informative to realize what the process is um so this is February 11th um PB start I made I think a couple hundred in between the end of that trade cycle we just looked at and this one but I'm pulling this one because I thought it was pertinent since there's been so much activity lately um so 37 days you know about half of what the last one was and look at the difference in the price start and the end and look at the volume so you know as the bot doesn't a market maker
doesn't really Force the hand of the market so it kind of relies on the market activity the more volatile and active the Market's going to be the more the bot's going to trade is that profit percentage over the trading period yes it is it is do you track bit ased metrics while you're trading I don't I don't I mean you know the Market's going to go up it's going to go down what else you need to know well well B when you're a market maker the greater bit ass spread the more money you're going to make yeah and that happens naturally here because it does especially when it's a when it's spread as small a lot of times you'll see when the and the bid ass does grow during High activity where a bio order
will execute and the bot will come in and place to sell for it's predefined amount of of profit and it's it's the lowest price on the market by like 20 or 25 cents so that order generally executes right away yeah question but aren't you competing with other Bots for best ask um no no I'm always trying to say outside of I'm always placing limit orders so I'm not changing my bid except on the first bid when I enter the market so I mean I it's all predefined it knows what it's buy down interval is it doesn't compete it doesn't cancel and rebid to try doing a oneup yeah I'm not doing any of that three per second three
requests per second for public five for private gotta so this is kind of what this chart looks like and sorry if I'm running long here folks I'm right it I got two minutes left two minutes um then we'll get to the question but uh this is kind of interesting here you know in the other slide we saw how portfolio value kind of really just tracks market price and it sort of does here but you know it's kind of interesting on that uptick it's not really doing that uh and you can attribute some of that to scale but if you think about it as the market price is going up the Bots sell orders are executing all of them so it's constantly trying to get back into the market and it has that effect of like trying to
chase chase up where it's not going to be flipping as many trayes as it would um and again down here the sum of all profit from flip trades uh these are things I'm working on next I'm going to skip this I'm going to automate profit taking I will talk about that um because I did see in performance metrics that you know portfolio value can be up in an acceptable amount in a down Market I think that's a no-brainer and it'd be ludicrous not for me to automate that Ponder coverage I always do that um other things you can do real quick you can you can fund your Trader with m coins I did this in 2015 so I had a miner who was depositing to a wallet the
wallet was API enabled from blockchain.info so I wrote a program in the middle of my Trader that would pull the wallet and every time it got to an amount that was tradable on the exchange it would tell the wallet to send it to my Trader my Trader would realize it came there and it would sell it at market price so you can just use you can actually use a minor to fund your your trading if you want to do that I'm kind of like man I did it cuz I was like oh this is going to be cool if I could get this to work and then it worked I was like that's okay uh or coins instead of Fiat this is actually I've got a couple more tests that I need to get to Green but this is pretty much already implemented and you
know we were talking about well you know you buy this many coins and you sell that many coins you know the same amount for a certain amount of profit well let's say you bought two ether and instead of trying to make 5 cents you decided that you wanted to you wanted to sell $ 1.99 ether for the same amount that you bought them at so instead of stashing profit you're sashing coin every time you do that and just trying to break even now what gets interesting about that is you haven't realized a taxable event where you've made a profit so the the little 01 that you're stashing every time that isn't taxable the buy and the sell you're selling at the same price you're netting zero so little tax-driven development see if you pay your taxes you start thinking and the way that I have it set
up is you can do both you can say try you know set the order to make two cents and also stash 001 ether uh open source Traders uh if you want to just run one that's open source you can do that Tribeca is all client side it has no persistence layer so I think it's where's Mike is that angular I don't know I'll go with angular um but yeah if you think about it you don't necessarily need a persistence layer because all your data is on the exchange so you could build build an application or clients interact with the exchange that's just calling for your statistics and your metrics while you run this on the front end TRC is kind of cool because you can run on three different exchanges uh zenbot uh uses a open AI framework called um I
think zenai actually or AI Zen something like that but anyways if you're interested in that kind of stuff that one's probably really heavy on technical analysis K the the zenbot um two really good documentaries the Wall Street code it's available it's free on most most the any of the documentary sites uh ghost exchange was free on um Amazon Prime if you have Amazon Prime really good documentary that's about what's going on uh you know with the big boys and everything that's happening there I have a question I could dive in what do you
think about cryptotrader looked at that I don't think I have okay you should consider conod okay it's an open market of bots that you can rent and you can rent them on a monthly basis um at ran a bot you can choose your uh exchange you can most of the bot it depends on who they're coded to you can choose your exchange there some baners that you can go in you can write your own and then sell them with open source not open source or rent them for not open source pretty cool okay I did pretty well with a mono Trader for a month nice what what was Monera trading at when you first started
trading you remember was it five yeah uh when I first it was around 311 okay and then uh came up to 12 by the end of my 30-day period okay and I did 24% on that that's great so was pretty good yeah I enjoyed it what was it called cryptotrader.tax that you can rent and you just deposit into them you have to have an account on the exchange but then it's a code to the apis what's the rent look like um so I it's usually about 50 a month for good ones there are free ones americ I did a free one for a week and made about 8% um but there's a whole slew over and uh I was just looking for whatever was
trading on Monero or Dash um on PO I already had and worked out pretty well what do it called again Crypt Trader cool thanks so uh those two links that you put up for the open source uh box do you have a recommendation for one and uh I'm not so I'm not de so are there instructions to program my criteria with those box uh tribec is pretty configurable yeah I know I know that Tribeca is um I can't really speak to to zenbot I came across it just recently maybe within the last two weeks um and didn't really dive too much into it but and so you created
your own mode right yeah yeah did you see any like improvements in the open source ones that you're going to put in yours or no I really hadn't haven't dug too much into them when I'm not working and I have free time um maybe I should be better about this but I I just think about my own bot like Arbitrage is like on my brain big time right now like that's coming I'm going to I'm going to build an arbit cuz I'm really curious about how they play to each other are you jumping through exchanges sorry no not currently so you're just jumping through currencies right like a triangular so for my myself without a background would you recommend just kind of going with Tribeca or should I actually learn how to make my own uh Tribeca so you mentioned about Arbitrage
I mean how do you yourself getting around the whole transaction time issue I mean that's completely yeah Corey Maybe you don't remember you cuded me into this I don't know if you knew we were having lunch one time so um it's a it's a single bot that has access to both apis so no not two Bots running on different exchanges with like a messing system um you you keep a balance of coins and Fiat on both so you're not you're not selling the identical same coin can't right yeah but if you're not making trades that make a profit on either change if your pairs if your trade pairs on both
exchanges are not making a profit then you're just losing profit on both sides you actually have to move money from One exchange to the other I like that challenge I'm liking how that's starting to sound this is why I want way that people do that so so the way that people do that say say that for example BTC has a price of $900 per Bitcoin and bit stamp has a price of $600 per Bitcoin right so you could trade you could sell your Bitcoin at at BTC for $900 and you could go and then you could buy you could send that dollars to bit stamp you could buy more right you could buy 1.5 right what he's saying is he wouldn't have two separate Bots just what we talking no I
understand this but the problem is that if you're not making trade pairs that are profitable on either exchange then you're losing money on both exchanges so the so what people do is if you're say you're sending money from from um you know you need to get your money out of BTC and you need to send it to bitstamp so you can buy the cheap Bitcoins right so you take an option that's why people use Bitcoin options to protect them against the loss of value they take a long option so if the price goes down they're actually making money gotcha hedging yeah you have to hedge you have to use Arbitrage and options together Co write that
h