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

Resources related to the "Hands-on Elixir & OTP: Cryptocurrency trading bot" book
https://elixircryptobot.com
75 stars 24 forks source link

Clean DBs, can't create a new trader... #3

Closed kitplummer closed 3 years ago

kitplummer commented 3 years ago

Through the book to Chapter 15 and all has worked, until now. I can't save "orders" to the data_warehouse db. So, I started with cleaning the DBs out, recreating, remigrating (and reseeding the events from the XRP history file). Now I get

iex(1)> Naive.start_trading("xrpusdt")
11:50:54.299 [info]  Starting Elixir.Naive.SymbolSupervisor worker for XRPUSDT
** (FunctionClauseError) no function clause matching in Ecto.Changeset.change/2    

    The following arguments were given to Ecto.Changeset.change/2:

        # 1
        nil

        # 2
        %{status: "on"}

    Attempted function clauses (showing 4 out of 4):

        def change({data, types}, changes) when is_map(data)
        def change(%Ecto.Changeset{types: nil}, _changes)
        def change(%Ecto.Changeset{changes: changes, types: types} = changeset, new_changes) when is_map(new_changes) or is_list(new_changes)
        def change(%{__struct__: struct} = data, changes) when is_map(changes) or is_list(changes)

    (ecto 3.5.8) lib/ecto/changeset.ex:376: Ecto.Changeset.change/2
    (core 0.1.0) lib/core/service_supervisor.ex:110: Core.ServiceSupervisor.update_status/4
    (core 0.1.0) lib/core/service_supervisor.ex:77: Core.ServiceSupervisor.start_worker/5

Obviously there is nothing in the DB, so no status to update. But for some reason I thought there was a step to get all the symbols from Binance, and load that out. But can't find it for the life of me. Anyway, that wouldn't solve the problem because XRP isn't there anymore.

Any ideas on how to optimally handle this from the ServiceSupervisor? Since we're abstracted out to the scheme, maybe to an upsert?

kitplummer commented 3 years ago

Ah, I remembered - mix run priv/seed_settings.exs - but now running into an issue there where it isn't getting the config details for the database. :D