Giter VIP home page Giter VIP logo

hands-on-elixir-and-otp-cryptocurrency-trading-bot's Introduction

This repository is the home of Hands-on Elixir & OTP: Cryptocurrency trading bot book.

Want to learn Elixir & OTP by creating a real-world project?

The book cover

With "Hands-on Elixir & OTP: Cryptocurrency trading bot", you will gain hands-on experience by writing an exciting software project from scratch. We will explore all the key abstractions and essential principles through iterative implementation improvements.

We will start by creating a new umbrella application, subscribing to WebSocket streams, implementing a basic trading flow, and focusing on improving it by expanding on the topics like supervision trees, resiliency, refactoring using macros, utilising the Registry, testing and others.

This book is 90% complete - chapters 1-20 are finished, and I'll add more content soon. It's also a loosely written representation of the Hands-on Elixir & OTP: Cryptocurrency trading bot video course released on YouTube.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International CC BY-NC-SA 4.0.

Limit of Liability/Disclaimer of Warranty

THIS BOOK IS NOT FINANCIAL ADVICE

THE SOFTWARE/BOOK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE/BOOK OR THE USE OR OTHER DEALINGS IN THE SOFTWARE/BOOK.

Contributing, Errata and Source code {-}

The book is written using R Markdown(it's a very similar syntax to the GitHub markdown but supports many more features including code execution, etc.) and converted to final form (for example PDF) using the bookdown app. This means that editing a chapter is as simple as editing the markdown source of that chapter.

There are two repositories related to this book(both hosted on Github):

In regards to contributions - I would love to follow the standard process of forking, making changes, opening PR(please look is there a branch for the next version and point to it instead of main), merging, and releasing a new version of the book.

This books has also the GitHub Discussions enabled for both the book's repo as well as source code's repo, please feel welcome to start any discussions related to book there.

hands-on-elixir-and-otp-cryptocurrency-trading-bot's People

Contributors

andrewphillipo avatar cinderella-man avatar edborsa avatar juanpabloaj avatar nandofarias avatar noargs avatar zhulinpinyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hands-on-elixir-and-otp-cryptocurrency-trading-bot's Issues

Code mismatch at 6.4

Hi, I noticed 2 mismatch with map returned by fetch_symbol_settings/1:

  1. The key :symbol added in chapter 5 now is disappeared

  2. In chapter intro we can read

    should never be smaller than double the fee(at the moment of writting transaction fee is 0.1%) that you are paying per transaction

    The value assigned is 0.0001 but I expect 2 times 0.1% and so 0.002. I probably misunderstood how you assigned this value. Can you clarify me this point?

Thank you!

Typo at the end of 2.3.2 (i think)

Reading through your book. Really enjoying it so far. I came across this piece of code at the end of 2.3.2

defp calculate_sell_price(buy_price, profit_interval, tick_size) do
    fee = D.new("1.001")
    original_price = D.mult(D.new(buy_price), fee)

    net_target_price =
      D.mult(
        original_price,
        D.add("1.0", profit_interval)
      )

    gross_target_price = D.mult(net_target_price, fee)

    D.to_float(
      D.mult(
        D.div_int(gross_target_price, tick_size),
        tick_size
      )
    )
  end

However the commentary that is provided immediate after is a little confusing. For instance there is this quote,

We started by calculating the gross_buy_price which is a sum of buy price together with the fee that we paid on top of it.

I do not see gross_buy_price, but perhaps that was intended to be original_price, however the original_price variable is not calculate with a sum like the above quote states it is D.mult(D.new(buy_price), fee). There is another quote that is similar,

As we will be charged a fee for selling, we need to add the fee again on top of this target sell price(gross_target_price).

Again, that is referring to the line gross_target_price = D.mult(net_target_price, fee) which is also a multiplication and not a sum.

Possible typo in Chapter 5 supervision tree images?

In chapter 5, where we see an diagram representing the supervision tree, it seems like there is an error in https://github.com/Cinderella-Man/hands-on-elixir-and-otp-cryptocurrency-trading-bot/tree/main/images/chapter_05_03_full.png,https://github.com/Cinderella-Man/hands-on-elixir-and-otp-cryptocurrency-trading-bot/tree/main/images/chapter_05_04_full.png and https://github.com/Cinderella-Man/hands-on-elixir-and-otp-cryptocurrency-trading-bot/tree/main/images/chapter_05_05_full.png,
where the bottom most Naive.Leader should actually read Naive.Trader. Otherwise, I might be understanding this wrong.

Related images:

chapter_05_03_leader_added
chapter_05_04_symbol_sup
chapter_05_05_full

Binance url for US based users

Seems like you need to specify "us" if you're in the US of A:

wss://stream.binance.us:9443/ws/

If you can point that out in the docs, I'll submit a PR.

Unable to start Streamer app with Phoenix.PubSub

I've been following along the book as a practice method until I found myself blocked with the following issue:
Environment:
Elixir 1.11.4 Erlang/OTP 23

Relevant code snippet

# apps/streamer/lib/streamer/application.ex
def start(_type, _args) do
    children = [
      {
        Phoenix.PubSub,
        name: Streamer.PubSub, adapter_name: Phoenix.PubSub.PG2
      }
    ]

    opts = [strategy: :one_for_one, name: Streamer.Supervisor]
    Supervisor.start_link(children, opts)
  end

Expected:
iex -S mix starts the application correctly.

Actual result:
iex -S mix produces error:
** (Mix) Could not start application streamer: Streamer.Application.start(:normal, []) returned an error: shutdown: failed to start child: Phoenix.PubSub.Supervisor ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2 ** (EXIT) exited in: :gen_server.call(Phoenix.PubSub, {:join_local, Streamer.PubSub.Adapter, #PID<0.251.0>}, :infinity) ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

Besides changing the Elixir/OTP versions, I see no way of debugging this. Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.