Cinderella-Man / hands-on-elixir-and-otp-cryptocurrency-trading-bot

Source code to generate the "Hands-on Elixir & OTP: Cryptocurrency trading bot" book
https://elixircryptobot.com
263 stars 34 forks source link

Chapters 18, 19 and 20 #23

Closed Cinderella-Man closed 2 years ago

Cinderella-Man commented 2 years ago

A result of months of work (primarily personal growth and questioning my own understanding of things like "functional programming"):

* Chapter 18 - Functional Elixir

In this chapter, we will venture into the functional world by looking at how could we improve our code to push side effects to the edge. We will revise the `Naive.Trader` code to abstract away our strategy code into a new module called `Naive.Strategy`. From this place, we will reorganise the code to maximise the amount of easily testable pure functions. Finally, we will explore hypothetical implementations that will allow us to inject data into function or even manage effects to aid testability. We will compare those to solutions built into Elixir like the `with` statement.

* Chapter 19 - Idiomatic OTP

In the last chapter, we were looking into how we could reorganise *the code* to maximise the amount of pure code. In this chapter, we will look into different ways of implementing the OHLC(open-high-low-close) aggregator, considering similar optimisation but expanding to limit the number of processes to aid testability and maintainability.

* Chapter 20 - Idiomatic trading strategy

We will use the knowledge gained in the last chapter to revise our Naive trading strategy so we will minimise the number of processes required to trade. We will move the functionalities provided by the `Naive.Leader` and the `Naive.SymbolSupervisor` into our strategy, taking care to put as much of it as possible into the pure part. In the end, our `Naive.Trader` will be able to manage multiple positions(trade cycles), and the vast majority of code previously scattered across multiple modules/processes will become easily testable pure functions inside our `Naive.Strategy`.

Additionally, some changes around the book, including fixing links, adding aliases for easier reading etc.