Create a cryptocurrency trading bot in Elixir

5th video in the series about building cryptocurrency trading bot in Elixir - this time starting and running multiple traders at once

We will introduce a rebuy_interval which will allow us to start new traders as prices fluctuate. Before doing that we will work on a few things:

  • buy price (by introducing buy_down interval)
  • quantity (as it was hardcoded up to this moment)
  • race condition related to multiple transactions per order
  • rebuy interval mentioned above
  • visibility (introducing unique ids for traders [for logging])
4 Likes

Really enjoying your channel. Hope you never stop doing it :slight_smile:

Wondering, how you would implement a feature where traders could create and launch strategies through UI. You know how tradingview has a DSL for custom strategies?

1 Like

Really enjoying your channel. Hope you never stop doing it :slight_smile:

Comments like are really giving me power to work through those episodes - thank you. I don’t know how long I will be able to continue with them - I can’t be unemployed forever and it’s almost full-time job to get them out every week or two(or I simply still suck at creating them so it takes longer for me :wink: ).

Wondering, how you would implement a feature where traders could create and launch strategies through UI. You know how tradingview has a DSL for custom strategies?

That is a REALLY cool idea. Sounds like this could a follow-up course to this one - and it would surely be a huge learning experience for me as well - that’s definitely going right now on my “to do” list :slight_smile:

Frontend would be a big part of this as well so probably worth to extend to some GUI first and only then when it’s more visual I could afford to push it to visual DSL :slight_smile:

I need to brainstorm on this :wink: thank you for the idea :+1:

3 Likes

Just managed to push 6th video out :champagne:

This one focuses on storing trade events inside PostgreSQL DB. It will lay a foundation for storing different stuff inside the database for purposes of analytics, charting, backtesting etc.

I hope you will enjoy this one as it took 4 tries to record whole code as I had bugs upon bugs… :slight_smile:

5 Likes

7th video is now out!

We will create a new application called BinanceMock. It will have the same functionality as the Binance module so we will be able to use them interchangeably. In the future episode(s) the BinanceMock will become a foundation to allow us to perform backtesting. Besides creating the the application itself, we will also modify the leader and the trader to reference the config to figure out which client to use instead of the previously hardcoded Binance module.

4 Likes

Hello :wave:

It took me way too long but I finally managed to finish the next episode :champagne:

In the 8th episode, we will modify the naive traders to broadcast the Binance orders
structs to a new PubSub topic. We will add a handler function to
the DataWarehouse.Subscribers.Worker module to be able to
store the Binance Orders into the database. To be able to store
them inside DB we will also add a migration script and Ecto schema.

Enjoy :heart:

5 Likes

Wohoo! This course is gold!

You should think about publishing an eBook or something :wink:

3 Likes

:heart: Wow, those words mean the world to me :slight_smile: honestly! It’s so hard to find time and energy to record those videos, especially recently many unexpected things happened, but I really love to make those exactly because of comments like yours - thank you!

You should think about publishing an eBook or something

Don’t temp me :wink: I’m still learning what and how to do stuff but I was considering a “follow up” course or even putting those videos in written form for people that prefer to read books :slight_smile: I’m not sure would that work out but either way don’t have time for that now - need to do those videos going! :wink:

4 Likes

It’s really good. I’m following every video of yours and I’m learning a lot. Thanks for doing this.

1 Like

Thank you very much for making this series. I’ve been following along with great interest. It’s clear a lot of work went into making these. It’s really helped me get a better grasp of OTP as a whole and how it’s used to set up supervision trees. Most examples don’t cover the design and implementation in detail so you can get a fully working solution. This is great.

One question though: How hard would it be to decouple the traders from Binance? So that you could create a new streamer for something like Kraken, but use the same trader code to do the work?

Or would it be best to just add a new trader for each trading platform?

1 Like

Thank you very much, indeed, it takes a lot of time but it’s worth it :slight_smile: makes me happy and leaves this world a little bit better as it spreads the Elixir :wink:

How hard would it be to decouple the traders from Binance? So that you could create a new streamer for something like Kraken, but use the same trader code to do the work?
Or would it be best to just add a new trader for each trading platform?

The idea behind dividing the communication using PubSub was intended to show that parts of apps between PubSub are like blocks that you can freely swap to suit your needs - as far as I understand you are talking about 2 different topics and I’m not sure each one so I will respond to both:

  • different source of data like Kraken to be the only source - that’s fine just convert the data coming from Kraken to standardized struct that rest of the system accepts (in case of hedgehog it’s the Streamer.Binance.TradeEvent)
  • you want to stream data from multiple exchanges in parallel and here depends on the purpose you can take 2 approaches:
    • stream each exchange data to a different topic and subscribe to both(or more) if you want to do arbitrage for example
    • stream data to the same topic with an additional field called source or something similar - this could be useful for example to produce “average” prices, not that good for the current naive strategy as it would have plenty of meaningless messages broadcasted to it (it would pattern match on the “binance” source and ignore the rest)

I hope that helps - this is not a financial advise :wink:

1 Like

What are the crypto-currency plathorms that don’t require KYC at all, neither other kinds documentes, or at least not too much of it, which one could use for such kinds of projects? Mostly for testing waters.

That is, where one could sign up and begin running such custom trading applications right away, without any scrutiny from the side of a plathorm.

Later on, perhaps, I’d be willing to provide a plathorm some documents, when I start to operate on a bigger scale.

Hello @romik,

As far as I remember, Binance allows depositing funds using bank transfer and debit card without any details.

Hello :wave:

9th episode is out and finally, we can objectively test how bad(or good!) our trading strategy is. It a vital step and showscases how designing the system from blocks allows to swap them whenever it’s necesary.

Enjoy :heart:

3 Likes

Keep it up man! I’m really enjoying the series and can’t wait for the next one.

2 Likes

Thank you very much :+1: I have a few ideas for a few more videos but I would love some ideas/comments :wink:
At this moment the long term aspiration is that code written in those episodes will become an API and the second course most probably dedicated to create a LiveView based frontend for it will follow up.

Suggestion on what to put into this course would be really appreciated :slight_smile:

1 Like

Sounds cool, an API and Liveview frontend are good next steps.

I have had a similar project in mind but for stocks, and have started open-sourcing parts of it. At the moment I’m working on a Robinhood API client, which seems like something that could potentially integrate into your series.

I don’t know a ton about crypto trading, but decentralized exchanges seem pretty sweet. Not sure if those are much different from Binance in usage, but that’s another idea.

As for Liveview, there’s this absolutely insane video wall that Citadel uses img and I’m going to make a much smaller version of it for my own investment portfolio, it may be good inspiration for what your building as well. Liveview is great for this sort of stuff.

1 Like

Just out of curiosity, what sort of data/indicators do you expect/use in your stock trading strategies? I’m asking as the same indicators could be generated for cryptocurrencies and that would again be very close to being converted to stocks.

Holy crap, this is insanely good learning material. I’m impressed with the stamina you’ve shown in putting out so many videos. I know from experience how hard it is to keep a steady stream of videos like that. Thanks!

1 Like

Thank you very much. Honestly, it’s hard, but it gives such a boost of positivity and a sense of “doing something bigger than me” that’s it’s definitely worth it :slight_smile: btw. I’m not that much consistent - I’m not on the clock, sometimes it takes me 1 week for a video but sometimes 3 :wink: life gets in the way but somehow I manage.

PS. Don’t forget to like and subscribe :stuck_out_tongue: <just teasing!> Enjoy :heart: