New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Timothy Clayton: My Adventures in Automated Crypto Trading | ETHDenver

Ethereum DenverMon, Oct 9, 2017, 12:00 AM

#BUIDL the future at https://ethdenver.com Timothy Clayton Slides - https://goo.gl/MHOMgX This presentation is primarily about software development and interacting with exchange APIs. The strategy is secondary to that and isn’t meant to be a shining example amongst all trading strategies. I was happy with how it performed and was surprised where it did well, but my main goal in presenting this was to save developers some pain if they wanted to build an automated trader of their own. This talk was part of a Ethereum Denver Meetup on 04.13.2017. Ethereum Denver Meetup is a monthly meetup group that features talks and workshops by top leading blockchain impactors, influencers, and experts. The community attending Ethereum Denver shows up to contribute to the global blockchain ecosystem, whether by #BUIDLing decentralized applications (dApps), contributing to or starting infrastructure level projects, writing documentation/tutorials/white-papers, designing UI/UX, or info-graphics, or to learn, connect, and get more involved. So bring your inner awesomeness and some friends. We’ll provide mentors, resources, and all of the educational content you can consume. Follow ETHDenver on Twitter: https://twitter.com/ethereumdenver Follow ETHDenver on Instagram: https://instagram.com/ethdenver Join the Bufficorn #BUIDL Brigade on Opensea: https://opensea.io/collection/bufficornbuidlbrigade Join the conversation on Discord: https://discord.gg/sporkdao Subscribe to our channel: https://www.youtube.com/ethdenver

Transcript

You know, I have a background in economics. That's not business, finance, or investment. So I arrive with a little knowledge, but not much in terms of what might be going on in the industry. I hope you know what I can share with you tonight in terms of that experience. Perhaps it will spark some creativity, some motivation, and could save you some pain if you decide to write about a trader.

Go ahead, start. I'm going to give you an overview of what I'm going to talk about. I want to take a quick look at the schools of thought on investing. There are only the three big ones. I'm not going to spend a lot of time on this, but I think it's an important context that could inform any ideas you might have about a trader.

I'm going to talk a little bit about what my goals and design criteria were when I started doing this. Well, since I've been trading for three and a half years , if you're currently on exchanges, whether manually or automatically, and you've just started and sometimes find them frustrating, I wanted to give you some information so you know that they've improved quite a bit. They are trending towards a simpler user experience, an API-type client experience. Then I briefly discuss some automated trading strategies. And this is where automated trading strategies.

And this is where , at this point in the talk, I want to get a little more technical for the developers who are here. It was a little difficult to think about how to organize this knowing that the audience will probably be half and half. But this is where I wanted to get a little more technical and provide some information that is broad and true for all exchanges and maybe give you some tips if you haven't come across these things before. And the last thing I want to talk about is a market maker bot. A market creation strategy is what I use.

And here I'm going to explain what it consists of. There are many different ways to implement it, but I wanted to show you specifically how I implement that strategy. And then we'll look at some performance metrics on how it's done. There are a couple of trading cycles I wanted to analyze and that we can talk about. One of them is the most recent, during the chaos that occurred in the last two weeks.

Okay, yes, let's start here with the schools of thought on investment. The first one is called a random walk and is a principle of that school of thought. It says, "A long-term buy-and-hold strategy is the best, and people shouldn't try to predict the markets. Attempts based on technical, fundamental, or any other kind of analysis are useless. So that's quite a strong statement and somewhat the opposite of what you think when you think about writing an automated trader.

You usually think about using some kind of technical analysis to predict where the market is going, so you can take a position and take advantage of that knowledge. Past movements or directions of a stock or the market in general cannot be used to predict its future. People understood that. That's good. Well, Bert Miel was the one who wrote that.

He wrote it in the early 1970s. It's a very respected academic theory, and yes, I like to share it because I don't think many people know about it, but there is a very respected theory that says you can't do technical analysis. Oh, and I should say that the way he proved it was by looking at these managed funds and showing that against the index, they weren't outperforming it. So he had a lot of supporting data to back it up." To back it up.

Fundamental analysis, which is really just looking at the intrinsic value of the company by analyzing its financial statements. So, you try to get a sense or an idea of ​​what the company is worth from quarterly reports, annual reports, balance sheets; and once you make some sort of intrinsic determination, 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 a position in a company. And this is where you might think of Warren Buffett. He's a great fundamental analyst.

Technical analysis. I think people are probably familiar with what this is, but basically it says that margin price movements aren't purely random, but rather they move in identifiable patterns that seem squashed, they move in identifiable patterns and trends that repeat over time. So, this is directly opposed to the random walk theory, which says that future value can, in fact, be found in those charts. And a quick way to remember fundamental versus technical analysis is the difference between looking at the Financial statements and charts. And I've heard it referred to as the difference between investing and trading, which is an important distinction when you think about traders, who are n't really considered in that investment sphere.

So the goals and criteria I had when I started down this path, little Burton was in my head. And part of it, you know, wasn't that I didn't believe technical analysis was possible. But I've heard, read, and seen what happens with the big players, and the big players are the big firms on Wall Street. And when you start using technical analysis, you get into this horsepower arms race. And it's not about being right, it's about being right first.

If you're not right first, you're trading with outdated information. So I wasn't interested in getting into that pool because I wasn't going to win. Well, even though the exchanges where cryptocurrencies are traded do limit workflow and you can only make a certain number of requests per second, if you do something outside of that request cycle where you need power and You can be faster than the other guy, but I definitely wasn't going to have the money to afford the power to do that kind of thing. Pretty good. Great.

The other thing I was coming up with here, and this is just the mindset I had, was that I was looking at this as a passive income generator, and, you know, the notion of farming was in my head. The money I was going to invest was going to be like buying the land, and then the bot was going to grow and harvest crops over time. So I wasn't going to worry as much about what was happening to the portfolio value or my RORI day to day. I was going to worry more about my bot actively trading and, more importantly, about it being able to survive the crashes, which I discovered pretty early on, around the Mount Cox time, if anyone remembers that or if you've been paying attention to crypto for two weeks and have seen Ether. I mean, there could be some pretty dramatic and tumultuous environments.

So, one of the things that got into my head pretty early on was that I needed some kind of strategy to keep it alive The thing is, programmatically in trading. So, small fees have always been small, even on exchanges that have a flat fee. But one of the things that's been introduced—oh, I wouldn't say it's too recent, in the last couple of years—I think Poniex switched to a make-or-take model last year. But what ends up happening there is that if you put an order on the exchange and it doesn't immediately match an order , and it just sits there, if and when it's executed, you're considered a market maker because you're putting liquidity on the book and you don't pay any commission. So that's a free trade for you.

If you put an order and it's executed and immediately matches an order on the other side of the book, then you're considered to be taking liquidity away, and that's when you pay the commission. And it's still very small. It's not 25%. It's a quarter of 1% that you pay on the total value of the trade you're making. This was a very important thing for me.

You know, I think after Mount Gauss, maybe every month or two you'd hear that Another exchange had been hacked, and all the coins were gone. And if you did n't know, there's no government institution that handles, or is probably even interested in, recovering your coins in that case. So, when they're gone, they're gone. And when GDAX—well, at that time it was Coinbase, they've since changed to GDAX—they're insured. And that should also say Litecoin now.

They trade Litecoin. Cool. So yeah, that's a big deal. So, if they get hacked, you know, I don't know what the process is like for getting your coins back, if it's a hassle. But in any case, that kind of insurance builds trust, builds volume, builds trading, and that's good for an automated trader, in my opinion an automated trader, in my opinion .

I have mixed feelings about this, but it was a big deal. GDAX is partly backed by the New York Stock Exchange. So it was big enough for the Wall Street Journal to take notice. In January 2015, it was the first time a traditional financial institution had taken direct stakes in a Bitcoin company. The deposits and Withdrawals are a big deal for me.

Back in 2013, I was sending money orders to a P.O. box in Atlanta, Georgia P.O. box in Atlanta, Georgia , to an exchange called CampX, which at the time was the only US-based exchange .

It would take two or three weeks for the money to process and arrive in my account. And, of course, the first time I sent money, I sent $10 because I send money to a P.O. box in Atlanta, Georgia. I don't know what it's like now.

Things are very different now. Yes, GDAX now even allows withdrawals via PayPal. So, probably one of the biggest improvements I've seen is the support you can get from banks and payment processors. Okay, quickly, I want to talk a little bit about some automated trading strategies . I won't cover all of them, but I want to cover at least the first two.

Oh, and I forgot to mention that I'm going to put this presentation in the Meetup group when I'm finished. So, even though I'm just going to list these things, if you're interested in automated trading and maybe you're missing some concepts or ideas on how you could apply that strategy... Well, Investopedia has a pretty good page that gives you all these different trading strategies and what they are. But trend following is going to be a technical analysis trader, and they're going to be looking at a technical indicator. So, one of the most important ones is, you know, whether the 50-day moving average is crossing above or below the 200-day moving average.

And that tells you something about the direction the market is going to take. So, you implement your positions based on that forecast, that information. And you probably also have some stop-loss strategy there in case you're wrong, or the percentage of times you're wrong. The great thing about technical indicators is that you can avoid heavy data processing because you're not adding a ton of information and trying to do predictive analysis on what it means. All you 're doing is just looking at these, you know, one or two or a handful of indicators, and when they reach the value that I think is important, that's when your bot would take action.

So, it's kind of a way of, you know, a way Simple to do technical analysis and predictive analysis. Arbitrage, uh, probably a lot of people are quite familiar with that. Securities that are traded on different exchanges generally don't always trade at the same price at the same time. So, in an arbitrage situation, uh, you would be connected through the API to two exchanges and you would buy on the one that's cheaper and immediately sell on the one that's more expensive. Uh, kind of a basic strategy.

Uh, trading range and mean reversion. Uh, I'm not sure if I want to get too involved. Well, I think I have some ... Yes, I have some time. I'm browsing.

God, I should slow down. Uh, mean reversion is a great idea. It's the idea that you know the price swings you know the price swings , uh, you know a security swings around this mean, and with the trading range, you can statistically establish these limits around that mean, and when the price goes in and out of them, that means something. So you decide your entry and exit points based on this kind of range that you determine statistically. around an average.

The next four I would have to look up, and I wasn't familiar with them before I started researching for this presentation, but yes, the link at the end of the article about the market maker—I'll explain that later. The market maker is a real oddball. It's a very interesting type of strategy. For some reason, when I personify it in my head, I always think of it as the second basement of a team. Like you, it has a lot of responsibilities, but you do n't realize them as long as it does n't make mistakes.

It's just a weirdo. Okay, now I'm going to start talking about the technical aspects little by little. So... the technical aspects little by little. So...

I wanted to put this image up here, you know, as a sort of disclaimer. You know, trading is a lot of fun, automated trading is a lot of fun, cryptocurrencies are a lot of fun, but your money is going to be at risk. So be strategic and smart in how you do it. Start with a small amount of money. I started with $800.

For me at the time, that was a lot of money, but I could afford it. Don't use your rent and think you're going to be able to get it out of the exchange for the same amount or more when it comes time to pay the rent. I just want to talk a little bit about web portals. When you decide which exchange you're going to trade on, the next slide shows a pretty drastic difference. But it makes a difference.

When I traded on Camp, this was all you had to do, and there was no difference if you logged in. I couldn't see where your positions were on the ledger. This page would update every four or five seconds, and that was pretty much all the information you had about what was going on in the market. Well, yeah, you had to look at your records to see, you know, what prices you had positions at, how much you had. And for some reason , too—I think it's GE, I think it's Gemini—whenever I log into Gemini, I can never see what's going on with the market on that exchange.

I don't know what it is, but it seems really hard to figure out what's going on. Whereas this is kind of what you would expect from an exchange, especially as a trader. I think I need to point out a couple of things here. Well, yeah. Well, these These are all my positions here.

That's the amount. And it tells me where my positions are and what price they're at. It has my open orders down here. Trade history. I wish I could close that.

I never really pay attention to that. Well, you know pay attention to that. Well, you know , you have your candlestick charts. You have the ability to change the time series. You can change the chart type.

It has your balance in USD. So , it's quite information-rich , it's quite information-rich . It's well-organized, and it's easy to log in from anywhere, you know, when you're on mobile, and go ahead and see exactly where your trade might be. where your trade might be. How do we understand that candlestick chart?

This is a bit of an odd one, but it's a good question. So, your high, low question. So, your high, low , open, and close are the four pieces of information you're looking at. The ones that actually have a wick, like this one here, that was the high. This was the low, and that was the close, and then that was the open.

The thick part is the open and the close. The thin lines are the high and the low. Yes. And if it's red, it closed lower from where it opened. Yes.

The red It's down, green is up. And when does the exchange define the open and close? That's a good question. It depends on the size of the candle. It depends on your...

Yes, your time series would determine how the candle is tracked. So, they're likely to be updated on every transaction. So, was it a good day or a bad day for you? What day was it? You're looking at 3 hours of trading.

10:24 massacred. I'm trading ether. That was a good day. Well, other things that are good to consider and think about, really just to know when you start getting into automated trading, is the idea that every API I looked at is going to limit the number of requests you can make over a period of time. So, you're going to have to have some kind of limiting logic within your program to make sure you're not exceeding that limit.

GDAX, you know, three requests per second for public endpoints. That would be something like getting a quote, getting the order book depth. Those are public. Uh, 5 seconds for private ones. They would be like, you know, posting an order, canceling an order, getting an order.

Uh, but one thing they do that's really good is that they allow bursts. So, if things get a little high for any reason, they'll give you a period of time before they start returning 429 status codes. Uh, and not all of them are the same. Bitstamp is, you know, don't make more than 600 requests every 10 minutes, and we'll block your IP address. So, maybe you look at the different exchanges, see how they handle these different things.

I'm going to go over tick size. This is good to know. Uh, it's going to be the smallest price movement or increment on the exchange. So, if we go back to this chart here and you can see how these increments are, that's probably pretty small, but almost everyone has a position at one cent everyone has a position at one cent . So, one cent is the tick size on the GDAX, and that's regardless of whether you're trading, well, this is USD to cryptocurrency.

So, USD to Bitcoin For Litecoin, the tick size will be one cent. And really the only reason—and maybe this is a little obvious—why you'd want to know that is any calculation you're doing to figure out a buy or sell price. You want to make sure it ends up being in whole cent amounts because if you were to throw an order for, you know, $ 42.125, that would be an invalid request. Minimum order quantity for buy and sell.

So, that's the smallest amount you can sell or buy. It's 01 on GEX. And again, a good reason to know that. Obviously, you want to make sure you're sending a valid order. But there's another reason as well.

Exchanges aren't enforced on the minimum order size when it comes to filling orders. So, the way I'll try to explain this is: let's say you're second on the buy side in the order book, and a market order comes in for a sell, and the first order in front of you fills all but 0001 of that market order. They'll take that fraction that It's smaller than the minimum order size ; they'll take it from your lot that you need to buy, for which you have your buy order. So, if you're doing something blindly where you just buy and turn around and sell on the exchange without even thinking or checking, you should know that you'll need some logic to verify and make sure that your orders actually meet the minimum order size. What do you do?

What do you do with your partially filled orders? Do you wait for them to fill? Well, when I log into my system a little later, I usually do, but if a sell order is executed , what I end up doing is canceling the order regardless of whether it's partially filled or not. If it doesn't meet the exchange's minimum order size, I hold onto it until later. And so you collect all these partial executions, and eventually, you have a process that runs when it reaches the minimum order size, where you can send it to the exchange.

Then, you kill your cells if they don't if they're partially filled. No. I always leave it to myself. You do 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 Oh, no, no, no.

This is automated . So, yeah, I'm not doing any of this manually. This is all automated. The AO there is quite interesting. I haven't seen any other than CampX.

CampX was quite good. They're not respected at all, but they're pretty good. So, they had an all-or-nothing order type that said if this order wasn't going to be filled in full, don't touch it. And that's a little different from the fill orders you see on exchanges because a fill order is more concerned with the immediacy of that order. So, a fill or delete order will occur, and if it's not filled, it's immediately canceled.

If it's partially filled, it immediately cancels the balance. If it fills immediately cancels the balance. If it fills , it fills. But with an all-or-nothing order, it will stay on that exchange. So, you don't have to worry about partial fills.

There's an all-or-nothing order type. Auto-trading prevention. Something else that's important to know. You cannot buy your own cell, nor can you sell your own purchase. That's how it is.

I never understood it. You know, it's like I own the cell. Why can't I do it? But that's how it is on most exchanges. Almost everyone, except Camp, was not like that.

I'll explain why in a moment. But on GDAX, the default for that exchange is that if you're placing an order and it has an auto-trade event, they cancel the most recent one auto-trade event, they cancel the most recent one , but you can configure it according to your request. There is an STP parameter that you can tell to cancel the most recent one, cancel both, or cancel the most recent one. So you should know that it's something you might have to work with. The market maker never encounters this.

It's happened to me a couple of times because I placed orders manually on the exchange. And then my trader was trading and wasn't registered in their database and hit one of my own orders that I placed manually. But CampX allowed supply and demand to coincide. So you could see that the order books really were the same price at Camp. There was a buy and a sell order for the same price and they weren't being executed, and you knew it was someone who had both the buy and the sell order.

An interesting way to manage it. Well interesting way to manage it. Well , the isolated exchange environments, honestly, the two I've seen are pretty quiet. There isn't much activity in them. Therefore, I think they are really good at confirming that you are making the right type of request and that you are getting the expected answers.

But in terms of quickly testing your strategy , there's simply not much activity on them. What is an isolated exchange environment? It's like a game environment that exactly matches, or should exactly match, the rules that exist in the exchange, and you can give orders in the exchange, and you can give orders , cancel them, or carry them out. They usually give you fake money, like 10,000 or 10,000 coins for trading 10,000 or 10,000 coins for trading . But it still requires a user or an automated system to move and do things.

And, generally, there is no activity in isolated environments. Well, it's a kind of development environment for developers. So yes, expect to develop and fine-tune your bot on the live exchange. So again, be smart about the amount of money you give your bot initially money you give your bot initially . And if you're very rich, don't worry about that.

I guess. But, you know, for me it was a kind of worry and I had to think about how I was going to use my funds and continue learning and making mistakes at the same time without paying too high a price. Exchange idiosyncrasies. So this is just one kind of category I want to talk about because you'll probably come across things like this. These are things you really can't find in the documentation.

You will only become aware of them once you start actively operating and begin to notice the behavior of the API you are interacting with. At GDAX, when you request a cancellation, it doesn't always mean your order is cancelled. Even if you go back to 200, even if they say, "Yes, that's fine," it's more like a request to cancel the order, and they say, "Okay, we'll get on it." And you have to go back and see if it was actually completed or not. But overall, I mean, honestly, GDAX is pretty impressive with the amount of volume it handles.

And I'm sure other APIs also have their own small certifications. So their own small certifications. So , one of my secret dreams when I saw this was that I was going to write some code, run it, and then cash checks. I would never have to touch it again. And that's not really true.

I suppose deep down I knew it, but you know, the API sometimes changes its answers. The API changes in ways that break your code. And sometimes it's a good thing, you know, the changes they make. Well, it's happened twice since I started trading on GX, where I started trading, I think, in May of last year. And, well, you know, they didn't have a mass cancellation endpoint, so they took their single cancellation order endpoint and made it so that you could get, well, multiple responses, multiple cancellations, executed, executed on cancellation, executed at the same time.

Well, before you would get a correct status, well, you know, a JSON hash, and, well, when they change it to a bulk endpoint, now they return an array of IDs of the orders that were canceled. Well, some might say there's some improvement in the API, but you should know that APIs are going to change and you'll have to work with them. In addition, you'll do many things yourself, well, with your strategy, things that will motivate you and make you want to try, so you'll never reach the stage of setting it up and forgetting about it. Well, the other thing I discovered was that, in the same vein as with maintenance, you realize that you are part fund manager and part developer. So I think it's a good idea.

I pay much more attention to the news than to what is happening in the world of cryptocurrencies, specifically the cryptocurrencies I trade, which I happen to be trading at that moment. I want to stay on top of developments, not only with the market and what's happening with the partnerships being formed with banks, but also with the underlying technology. To get an idea of ​​whether anything might happen in the future that I should take into account and make a decision about whether I want to stop the bot for a while and see how things develop. I did that with the fork, where Classic was. They had seen it, they knew it was going to happen.

I saw information about it. Well, on one hand, GDAX wasn't going to support the classic bot. And I really didn't know how much support there would be for the new ETH and how it would be marketed, if there would be a lot of activity and interest around it, all those things. So I encourage you, you know, I guess it's pretty good to go beyond that limit of setting it up and forgetting about it and try to make it as maintainable as possible. But don't let that stop you from making important decisions, you know, about when you need to stop the bot, when you think it might be good to wait a bit and see how things develop.

Okay, I want to talk a little bit about testing and creating your test suite. Well, I'm not sure how other languages ​​or frameworks might handle this, but at least in Rails, I read a ThoughtBot blog post , and you know, it said that if you 're building an application or program that's essentially the client of an API, they give this advice on how you can create a fake swap in your test suite. And he uses Sinatra to do it. And basically you just need to configure endpoints that match the exchange's endpoints. If you're using a library, you might look at the source code and see the endpoint they're calling below.

Or you can look at the documentation. All the APIs have pretty good documentation. And then you configure your specifications to say, hey, every time the application code tries to go to api.gax.com, send it to this fake exchange I created here.

And the responses you serve are read from JSON files that you also have in your application. And you can fill those JSON files with real requests in the sandbox you find to use the sandbox for that, or to perform a real placement, or get, or whatever you need to do in the real exchange. And then what became really easy with this is that when you write your specs now you have all these different little building blocks, you know, from the JSON files you can create context and create cases. Perhaps you need to test what happens, you know, with this series of requests that need to happen before that. And it simply made things much easier for me to be able to write tests and have these building blocks assembled in context.

And I also have a bit more confidence, because the JSON files actually come from real API responses. This may be a little obvious, but I have some static configurations where I change the values ​​before doing trade cycles. And while you're writing your test, be sure to change them from time to time to ensure you 're not just testing that specific value. Especially if it's something that's going to be sent, like a post that has to do with a price or a quantity or something like that. Test for a network outage.

Therefore, turn off the wifi, wait for something to happen on the exchange with the pending orders, then turn the wifi back on and see how the bot handles it. If you're running it locally, if it 's deployed, give the server a good whack. Yes, I was trying to be nice, but this happened to me. I thought: Why are my tests going so slowly? I don't remember the tests being so slow.

I don't even have that many. And because I was limiting the application code, my tests going to the fake exchange were also being limited. Then, remove the limitation in your test environment to make them run faster. Separation of concerns. This is how it looked for a long time.

Just a bunch of spaghetti. As I said, I've done iterations on this codebase. And this is something I wanted to tell you that I wish I had done sooner, especially in cases where things aren't going well and something is broken and you can't start the bot or begin trading again until it's fixed. When you have that much code, you know, 50-line methods, 400 or 500-line files, trying to debug it and get things working can be quite difficult. And you know, since I work full-time And you know, since I work full-time , when those kinds of situations came up , I would just say, "Well , I would just say, "Well , I guess I'm not going to use the bot for a week or a week and a half ."

So separating things from the beginning can help you get a quick answer when things aren't working well. And this is what it looks like right now . In terms of how I've separated things, it's perhaps not surprising that there's a trader in the middle of the diagram. And all the trader does is place orders, cancel orders, and monitor their status. That's all it does.

If you need to get information, well, when you need to get information about, you know, the size of the offer or the price you need to put in the order or the quantity, you're going to decide. So he decides to take care of all the calculations. And now I don't think that "decide" is really a good name, but semantically it made sense. How to decide the offer price, decide the selling price, decide that purchase range. Sentinel, down there on the right, receives a call when things could go wrong.

So when the operator is monitoring the status and something runs, he doesn't know if it's a partial fill or not, he doesn't know if the order was actually canceled, he tells Sentinel to go ahead and take care of it. Sentinel also handles reconciling the sellers in the database with what's happening on the exchange. The request user was a small layer of abstraction that I put there because I encountered many challenges when I switched my bot from trading on Campx to GDAX. I thought it was going to be a week or two, but the rules of the exchange were so different that it actually took a long time. So thinking ahead to the future when I want to be on a different exchange program, I decided to go ahead and make a first attempt to see how I could make things a little easier next time.

Therefore, Request Usher handles all limitations. Manage all error handling. It handles all JSON parsing, and Request is simply the client library. That's all. Sign your applications.

He sends them to the exchange and retrieves them. And Performance Metric is something I implemented right before my last trading cycle, or one of my last trading cycles, which I started on October 21st of last year. Performance Metric is something I never used to use to track statistics use to track statistics . I simply saw what was okay with my account, I had a mental note of where it was the last time I looked at it and that was enough for me. But I started tracking performance from last year.

How has it improved since then? Since you started tracing the steps, it has given me good information. It's given me some ideas about how I do things that aren't necessarily wrong or don't work, but that maybe I want to do a little differently. Well, it's been useful so far. Would you recommend setting it up from the beginning as another kind of first step to get information, or maybe if it's your thing, I'd say yes, go for it if it's your thing, I'd say yes, go for it ?

But I think it could also have been a distraction and a point of confusion for me before I really saw how things were going, and then I got to the point where I thought I should track this, maybe get it up and running first and operate before doing that. But if it's your thing and you're good at it, then and you like it, that's the most important thing. You have to do it. Very good. Okay, I want to talk a little bit.

How is everyone? Is everyone okay? All good. My head hurts. Really?

Excuse me, question. I think one of the good arguments against the random walk period for technical analysis is that when enough people are watching certain indicators, like "okay, this asset is going from 200 days to 50 and the Stoics are heading up" and "oh Stoics are heading up" and "oh my god, the MAC made a bearish crossover", everyone sees it. Yes. And it becomes a self-fulfilling prophecy, right? So, can you talk a little bit about the timeframes you observe?

Because, of course, those indicators depend on the sideways timeframe. So if you're doing swing trading, maybe it's like, you know, hour, hour, maybe if you're really there, it's minutes. How do you approach your time? I don't use any technical analysis, absolutely none. That was my criterion for developing it.

That raises a question, and I'm excited to see exactly how you 're doing. It will arrive soon. It's falling short. I use Corey Ditch's investment strategy . I'm curious about that.

Strippers and cocaine. Well, this is just the SEC's definition of what a market maker is. A market maker is a company (which I put in brackets) or a person (because I am a person) who is willing to buy and sell a particular stock regularly and continuously at a publicly quoted price. Wait, so all those purchase walls? No, no, I don't have that much leverage.

It's like...yes, he's a market maker . In reality, the only criterion is that you always have an open buy, at least one open buy and at least one other open and sold position in the market at the same time. Well, you might say, well, what the heck? How does that make money?

Well, it makes money in the spread and it makes money in market activity. So, since it 's sort of straddling the spread, as the market moves and sellers execute, buyers execute, it will obviously always sell for more than it buys. So, he has that margin to work with. And in my case, it's something like rinsing and repeating the volume. I do that over and over again as much as I can to get a little benefit each time.

So yes, this is just an interesting characteristic of a market maker when it moves in the opposite direction to what the market is doing. So, when the market is selling, the market maker is buying, and when the market is buying, the market maker is selling. Some advantages of a make-or-taker model are that it barely pays commissions. So that increases during high activity. But I would say that, in normal business, I probably only pay a commission about 5% of the time.

And that's because, since I place my order before it happens, the price moves and it actually reaches the market as a market order instead of a limit order. During high activity, I think it probably goes up to 15 high activity, I think it probably goes up to 15 , maybe a maximum of 20% of the orders placed pay a commission. Therefore, it is a low-cost strategy. You know that commissions accumulate. You can implement a wide range of strategies with it.

If you wanted to apply technical analysis, Kent, as you said, to say, "I'm going to monitor these indicators and when they reach something, I'm going to stop my market maker for a while until I get a favorable indicator." You could do something like this. It does not prohibit other strategies. There are many things you could do that still fall under the group and definition of a market maker. You could make multiple purchases at the same time.

I only have one penny at any given time. In theory, it is said to add stability to the market. Perhaps not with the volume I have, but for some of the biggest market makers. Because they are always ready to buy and sell, they add that kind of rigidity, stability, and reliability to the market. Well, the last thing to know is that it can show impressive gains in bear markets.

Okay, this is the part where I want to start telling you and describing exactly how I carry out a market creation strategy. Well, Bitbot was the original version and the name I gave to the repository. I've tried to change it several times. It's now called Longshot, but it seems like it's always been called Bitbot. Well, if anyone works with animations and PowerPoint, congratulations.

It's more difficult than creating an automated operator. But we're trying. Oh my God, I don't want to talk about it. Well, you start, you know, the market is doing what it's doing, and this is to initiate a trading cycle or a state in which all sellers have executed, and you are trying to establish a position as a market maker to open a buy and a sell at the same time. And then the first thing he does is enter with a limit order at or near the top of the buy, the buy side of the book.

And I call that order a scrum buy because it's the only buy order in my application that has bid, rebid, and cancellation logic because it wants to stay up and if the price goes up it has to cancel and bid again. So it's kind of a scrum in an attempt to make a purchase. And then at some point it ends up being executed. And the bot is going to do two things after that happens. The first thing he's going to do is go in and place a sale for those coins at a certain price.

um that has within it a predefined amount of profit that it wants to obtain. So he knows how much he bought. He knows how much he paid for it. He's going to add profit to that, and that's the selling price he's going to set it at. The profit margin there will simply be the difference in price between the sale and the scrum in this case.

I'll talk about that briefly later. I'll talk about that on the next slide . And then he'll go in and make a purchase. Then, once the initial purchase order is executed, it makes a sale for a predefined profit amount and makes another purchase order at an increment below the price at which it was just purchased. And the difference between those two purchased.

And the difference between those two , the purchase that was just executed and the purchase that just obtained the limit order that was just made, is known as the downside buy interval . Wow, that's a laser. I'm sorry . Wow, that's a laser. I'm sorry .

Those two together form the straddle or the straddle spread. And at this point the straddle spread. And at this point , the bot is now a market maker , the bot is now a market maker . So, the market will continue to move. And let's say it goes down in this case.

Well, he'll do the same thing he did last time. He will make a sale immediately for a predetermined profit amount. And then he's going to come in and make a purchase for less than the price he just paid. And that, again, Straddle has again in the same magnitude. So, generally, the price ends up going up again, and that's where you make money.

So you get a little bit of a benefit there. And when that sell order is executed, technically you're still a market maker at this point. You have an open purchase and you have an open sale. But what has happened with your straddle differential is that it has grown. So what I do in this case when a seller executes is cancel the pending purchase and go in and buy again at a price that gives me back my straddle so I can keep it.

So the idea behind what's happening here is that you're trying to keep your buy orders and the sellers' orders running; you want to maintain that straddle around the market as the price goes up and down and simply take advantage of the swings that normally occur with the price to get your orders executed. And how are you shaping your straddle, your appetite, where do you want it to be? That's a very good question, which I'll answer in a moment. I was going to go back, but is it always a fixed number or is it like a percentage of the asset value? I was going to say that it's probably a tweetable value.

It is nominal. Yes. Ah, there it is. Yes. So, the straddle is your profit range plus your downside buying range combined.

And why I consider these values important in this system is that the smaller those two are, the smaller the straddle will be and the more trades the bot is likely to perform because it can take advantage of those smaller, low-activity micro-movements . Whereas if the straddle were larger, there might be all this market activity happening that doesn't trigger any of your trades. Therefore, if you don't perform any transactions, you're not making any money. Okay. So who asked how I'm determining it?

You did it. Okay. This is related to surviving lean times. And I will say that when I started doing this, I manually set my buy interval down. So it was just a fixed number.

He bought every two or three cents. And I would try, you know, to look and try to determine what I thought it should be for a certain period of time and then I would execute it. But I kept running out of money when I did that because the price kept going down, and, you know, the market maker will keep buying—at least what I do—and will just spend money on the way down until the account balance is zero and all your value is tied up in pending sell orders that will be left behind while it does that. So, from the beginning, it was clear that I had to develop some kind of strategy to be able to stretch my funds during these lean times, so to speak, as they occur. And what I came up with was to create an algorithm that could say, in a crisis situation, you know, in a free-fall market scenario, how drastic is the free fall in price that I want to cover?

So I'd say maybe 30%. And what I mean by free fall is that on the way down there is no intermittent rebound that triggers a sell order. This is simply a direct fall. And then it gave me a sort of, you know, way of thinking about how I would sell that percentage coverage set . I keep iterating and keep thinking about it, I still feel a little weird about it because I feel like I'm asking myself to predict the market in some way by setting up my hedge.

But since it's in that doomsday realm, I feel a little better about it because, you know, it makes sense to say, " Hey, this is going to fall and there will never be a rebound to the point where a sell order actually gets executed." Then he says, "Well, given that you want to hedge this amount against the freefall of the market, and given that you have this amount of money in your account, and given that you are trading this amount by buying and selling, and given that the market price is this, this is the number of orders you can place in that scenario, and this is the gap between the two, which is your buy-down interval." So, it's generated from a configurable setting where you say, " I want to hedge this free-fall market price." Yours is 30. I normally run it at 33, but I still have Mount Gau in my brain.

That's quite a lot , it's a lot for free fall , it's a lot for free fall . There's a lot to cover right now. Well, if it 's a lower-priced cryptocurrency, not necessarily. Something like Maidsafe probably isn't good enough. Maybe...

Well, they've been falling about 20% and fluctuating up and down. So, can you short sell on the GDAX? And if so , can you program your blocks yourself? As of yesterday, you can be an accredited investor. Are you an EDP, or what do they call it?

EPC Are you an EDP, or what do they call it? EPC . ECP. Yes. That margin trading opened yesterday on GDAX, but you have to be part of a brokerage firm.

You need to have 5 billion dollars. A minimum of 5 million dollars. Oh, here's the strange thing. Here 's the strange part. So, your margin is only good up to $10,000.

Yes. Now, if you have $5 million and need an additional $30,000, would a market maker bot take advantage of a margin trade, a short sale? Yes, because the margin doesn't only have to be used for short selling. You can use it to increase your capacity. So, you would only operate with leverage.

Yes, that's what I would do. Okay. I think we're done with that. And I wanted to say this. You know, hedging is n't something you'll necessarily need for any strategy you choose.

This is not only specific, well, it's not even specific to a market maker. If you have a lot of money, you can magically cover 80% and set it up manually, right 80% and set it up manually, right ? For me, this had a lot to do with the fact that I didn't have much money to operate with at the beginning. And then, I had to think that it was more urgent for me to devise some kind of system with which I could stretch those dollars. Generally speaking, well, the price fluctuation isn't that big on average, but the range is pretty incredible.

So, it's, you know, this is a five-minute chart, I think. So, it's just placing buys and sells and buys and sells and buys and sells and buys and sells and buys and sells in each increment during this, you know, from 2:30 to 7:35 hours. That was pretty incredible or impressive to me, you know? Did you see this after the fact or were you watching it? I saw it after the fact, but I meant, you know, in this case, he's using the same dollars over and over again , if that makes sense.

So, your trust balance is n't really going down that much. You don't need to recalculate it by descending interval. I mean , it's simply swapping trades over and over again swapping trades over and over again . Therefore, that is the ideal market for it. Well, yes, I wanted to talk a little bit about the bot's performance.

I'm going to analyze two trading periods here. One started on October 21st of last year and I took liquidity for it on January 5th of this year. The other one started on February 11th and I took out cash for it yesterday. Well, one of the good things about doing your taxes is that everyone here does their taxes. If you do them with Bitcoin, I'll talk about train cycles in a minute.

I forgot this slide was in the middle, but you get great charts of your trading activity if you do your taxes with Bitcoin. Well, there's a sort of story here. At that time, I was still trading Bitcoin, but the price was starting to put so much pressure on me that the balance in my account that I could actually trade with wasn't going very far. So , you know, I think I was trading with the minimum amount you can trade, like 0.1.

Willing to make a penny on a currency trade, doing everything possible to close that spread, and it's still slipping away from me in January, February, March, and April. Then I realized that if the problem is that this value is so expensive, why not trade with one that is n't? And Ether was available on GDAX. And it was quite easy. It was like a matter of adding a couple of environmental variables, like half an hour, and I flipped the switch and started trading ETH and things went great at that point.

Well, there's a 30-day overlap here in June and July, where the bot, the small, old bot with $3,000, accounted for 1% of the volume on the ether exchange. And so, in July, it almost reaches, if you add up the volume of purchases and sales, it's making around $160,000 in volume. With $3000 in his account. Yes, that really caught my attention. Then, it just so happened that I was leaving my job in August and, you know, I took about three months off and went through a sort of complete rewrite.

The idea was, you know, if this were a pull request, would I want to send it to a coworker? Well, I made sure to get 100% specification coverage, added code quality tools , did a separation of concerns exercise, and just made the code much closer to what I expected to do during my day-to-day work. And I think so , right here at the end, I did have a small drop in activity because of that because I wasn't running it as frequently. But in October, well, I guess we can move on to metrics. So this is the first one we'll see.

This negotiation cycle runs from October 21st to January 5th, a period of 76 days. This was the initial price. This was the final price. This low here, fell about 50% low here, fell about 50% in value and only briefly surpassed this initial price. At the beginning of the negotiation cycle.

Almost as soon as I started this trading cycle, the market began to sink in a very slow curve. So it was quite a brutal test to subject the rewrite I just did to. And I'm quite impressed with the result. It ended up gaining 8.8% in a declining market.

And that was good. I felt that the market conditions he was operating in were really difficult, and he did quite well. The volume was perhaps a little low there. I also noticed during this trading cycle that activity was not as high. But the other thing that's happening is that the bot is getting shy because with a 50% drop in price, you know, the buying interval has stretched out quite a bit.

Yes, I know that when I first mentioned one of my goals in thinking about this in terms of harvest, crop harvest, cultivation and crop harvest, it was that I was n't going to pay too much attention to portfolio value because attention to portfolio value because , for me, I was a farmer who cares about the sellable value of his land rather than how much yield he's going to get. But, uh, in response to that gentleman's question about performance metrics: since I started implementing this, I began to notice that, you know, uh, there are times when the harvest here, which is the sum of all the profits from the investment trades, and, uh, the profit here, what I ended up doing is seeing that the value of my portfolio had gone up about 9 portfolio had gone up about 9 % and I said, "That's enough for me; I'm going to go ahead and, uh, take a loss on my pending sales and sell them at market price." So, if I didn't have performance metrics, maybe I wouldn't have seen that as a possibility. So, I've changed the way I monitor portfolio value a little bit for some cases. Do you have your capital gains tax and your trading parameters?

Do you think about it that way at all? No, I don't. I just keep trying to invest as many trades as I can and I know I'm probably going to pay between 28 and 35% on it. Oh, yes. That's a good point.

That harvest is what you have to pay tax on. Those are all your taxable events. Aren't you supposed to stay in crypto and not talk about this? Look at the cool charts you're getting. It's being legit.

The rest of us are going to get arrested. So, uh, you know, this is an interesting thing. Actually, in my first iteration of Portfolio Value, I had to make a correction here. I had to write a script to fix this. I did n't realize that the library used that if you make an online request, you get a paginated result.

If you make the request as a block, you do n't. I don't know why, but it is what it is. But it was okay because it was one of those bugs where you're actually doing better than you thought. But if you notice how the market price actually follows it, Portfolio Value. You can just move up from here to here with that same curve in your mind.

And that's what we're tracking there. And I don't know if this effect is obvious, but you say something like you made almost 9% in a bear market. But this is what's It's happening with all your investment trades, and their profits are starting to contribute to the value of your portfolio and are outpacing the drop that has occurred in the market. So , as you start reaping the rewards and making investment trades, that is contributing to the value of your portfolio, even when market pressure might be trying to decrease the value of your portfolio. And eventually, it recovers and overcomes any decline you've seen.

And it happened when I think it was $1188 here when I took liquidity, and it started trading at $1204. So that's the dynamic with a market maker. I think it's a good and informative chart to realize what the process is. Okay, it's February 11th. PB starts.

I think I made a couple of hundred between the end of the trading cycle we just looked at and this one. But I chose this one because I thought it was relevant, as there's been a lot of activity lately. Well, 37 days activity lately. Well, 37 days , you know, roughly half of what the last one was. And look at the difference between the opening price and the closing price.

And look at the Volume. Since the bot isn't a market maker, it does n't actually force the market's hand, so it relies on market activity. The more volatile and active the market, the more the bot will trade. Is that the profit percentage during the trading period? Yes, it is.

It is. Do you track bid-ass metrics while you're trading? I do n't. I don't. I mean, you know, the market is going to go up, it's going to go down.

What else do you need to know? Well, the bid-ass spread when you're a market maker—the bigger the bid-ass spread, the more money you'll make. Yes. And that happens naturally here because that's just how it is, especially when the spread is small. Many times you'll see when the bid-ass increases, and during high activity, a buy order is executed, and the bot comes in and places the sell order for its predefined profit amount, and it's the lowest price in the market by about 20 or 25 cents.

So that order is usually executed immediately. Yes. Good question. But aren't you competing with other bots to make Big bids? No, no.

I always try to say that, aside from... I'm always placing limit orders, so I don't change my bid except for the first bid when I enter the market. So, I mean, it 's all predefined. It knows what the buy interval is. It doesn't compete.

It doesn't cancel or rebid to try to make a higher bid. Yeah, I'm not doing any of that. Three per second. Three requests per second for public, five for private. Got it public, five for private.

Got it . Okay, that's what this chart looks like. And I'm sorry if I'm rambling, folks. I have two minutes left. Two minutes.

Then we'll move on to questions. But, uh, this is something interesting here. You know, on the other slide, we saw how the portfolio value really just follows the market price, and here it does, but you know, it's something interesting about that spike. It's not really doing that. And you can attribute some of that to scaling, but if you think about it, as the market price goes up, the bots' sell orders are all executed.

So, it's constantly trying Going back to the market has that chasing effect, where you're not going to be making as many trades as you would. And again down here, the sum of all the profits from the investment trades. These are things I'm working on next. I'm going to skip this. I'm going to automate profit-taking.

I'll talk about that. Because I saw in the performance metrics that the portfolio value can increase by a reasonable amount in a bear market. I think it's a no-brainer, and it would be ridiculous not to automate it would be ridiculous not to automate it . Think about hedging. I always do.

Other things you can do very quickly: You can fund your trader with mined coins. I did this back in 2015. I had a minor who was depositing into a wallet. The wallet was API-enabled for blockchain.info.

So, I wrote a program in the middle of my trader that mined the wallet, and whenever it reached an amount that was tradable on the exchange, it would tell the wallet to send it to my trader. My trader would realize it had reached that amount and... I was selling at the market price. So, you can use a smaller amount to fund your operations if you want to do that. I thought, man, I did it because I thought, oh thought, man, I did it because I thought, oh , this is going to be great if I can make it work .

And then it worked, and I thought, okay. Hard coins instead of fiat. Actually, I have a couple more tests I need to greenlight, but this is pretty much implemented now. And you know, we were talking about, well, you know were talking about, well, you know , you buy this amount of coins and you sell this amount of 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 you wanted to sell 1.

99 Ether for the same amount you bought them for. So, instead of accumulating profit, you're spending coins every time you do it and just trying to break even . Now, the interesting thing about this is that you haven't realized a taxable event where you've made a profit. So, the little 0.01 that you're accumulating every time isn't Subject to taxes.

The buy and sell you're selling at the same price are generating zero. So, little tax-driven development . Check if you're paying your taxes and start thinking about it. And the way I have it set up is that you can do both. You can say, try setting the order to earn 2 cents and also accumulate 0.

001 ether. Open source traders —if you just want to run one that's open source, you can do that. Tribeca is completely client-side. It doesn't have a persistence layer. Well, I think it's...

persistence layer. Well, I think it's... Where's Mike? Is it Angular? I do n't know.

I'd say Angular. 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 an application or a client to interact with the exchange that just pulls your stats and metrics while you run this on the front end. Tribeca is great because you can run it on three different exchanges. Zenbot uses an open AI framework called Zenai or AI Zen, something like that.

But anyway AI Zen, something like that. But anyway , if you're interested in that... Kind of stuff, this one probably focuses a lot on technical analysis. Ken, Zenbot. Two really good documentaries.

The Wall Street Code is available. It's free on most documentary sites. Ghost Exchange was free on Amazon Prime if you have Amazon Prime. Very good documentary that deals with what's going on, you know, with the big players and everything that's happening there. I had a question, if I could elaborate.

What do you think of cryptotrader.org? Have you looked at it? I do n't think so. Okay.

Yes. You should consider coding. Okay. It's an open marketplace of bots that you can rent, and you can rent them monthly. I ran a bot.

You can choose your exchange. You can use most of the bots. It depends on who they're coded for. You can choose your exchange. There are parameters you can input.

You can write your own and then sell them open source or not, or rent them as open source. It's pretty cool. Okay. I did pretty well with a Monero trader for a month. Good.

What price was Monero trading at when you started? Trading? Remember it was at five? Yes. When I started, it was at about 311.

Okay. And then, uh, it went down to 12 at the end of my 30-day period. Okay. And I made 24% with that. That's great.

So it's pretty good. Yes, I enjoyed it. What was it called again? Cryptotrader.org.

It has a bot marketplace that you can rent and just deposit into them. You have to have an account on the exchange, but then it's code for the APIs. but then it's code for the APIs. How is the rental? Well, it 's usually about 50 a month for the good ones.

There are some free ones. I did a free one for a week and made about 8%. But there are loads of them, and I was just looking for anything that traded Monero or Dash on Poly because I already had an account, and it went pretty well for me. What was it called again? Cryptotrader.

org. Great. Thanks. So, those two links you posted for open-source bots, do for open-source bots, do you have any recommendations for either? And I'm not Developer.

Are there instructions for programming my criteria with those bots? Tribeca is quite configurable. Yes, I know. I know Tribeca is... I can't really speak to Zenbot.

I discovered it recently, maybe in the last couple of weeks. And I haven't really delved too deeply into it, but... And you created your own, right? No. Yes.

Yes. Did you see any improvements in the open-source ones that you're going to include in yours or...? No, I haven't really delved too deeply into them. When I'm not working and have free time, maybe I should get better at this, but I'm just thinking about my own bot. Like arbitrage is on my mind right now.

Like that's going to happen. I'm going to create an arbitrage because I 'm really curious to know how they interact with each other. Are you jumping from one exchange to another? Sorry. No, not right now.

So you 're just jumping from one coin to another, right? Like a triangle. Yes. So, for me, with no experience, would So, for me, with no experience, would you recommend using Tribeca or should I learn how to create my own system? Tribeca.

You mentioned arbitrage. I mean, how do you see yourself solving the whole transaction time problem? I mean, that's completely... Yeah. Corey, maybe you don't remember.

You gave me a hint. I don't know if you knew this. We were having lunch once. So We were having lunch once. So , uh, yeah, it's a single bot that has access to both APIs.

So, no, it's not two bots running on different exchanges with a messaging system. You maintain a balance of coins and fiat currency on both. So, you're not selling the same identical coins. You can't set that up, right? Yeah.

But if you're not making profit-making trades on either exchange, if your trading pairs on both exchanges aren't generating profits, then you're just missing out on profits on both sides. You actually have to move money from one exchange to the other. I like that challenge. I like how it's starting to sound. That's why I want this to do that.

Okay. So, the way people do that, let's say, for example, BTCE is priced at $900 for Bitcoin and Bitstamp have a price of $600 per Bitcoin, right? So, you could trade, you could sell your Bitcoin for $900 BTC, and then you could buy, you could send those dollars to Bitstamp. You could buy more, Bitstamp. You could buy more, right?

You could buy 1.5, right? What you're saying is that you wouldn't have two separate bots. No, I understand. But the problem is, if you 're not making profitable trading pairs on either exchange, then you're losing money on both.

So, what people do is, for example, if you're sending money from...you know, you need to take your money out of BTCE and send it to Bitstamp so you can buy cheap bitcoins, so you can buy cheap bitcoins, right? So you take an option. That's why people use Bitcoin options to protect themselves against losing value. They take a long option.

So, if the price goes down, they're actually making money. Got it. Yes. You have to hedge. You have to use arbitrage and options together use arbitrage and options together .

Cole, let me write that down. What are you?

Automatic transcript — names and jargon may be misspelled.