defmodule Ticker do
def get_trades do
case HTTPoison.get("https://api.wavesplatform.com/v0/pairs") do
{:ok, _} ->
results = HTTPoison.get!("https://api.wavesplatform.com/v0/pairs")
%{data: items} = Poison.decode!(results.body, keys: :atoms)
market_snapshot = Enum.map(items, fn item ->
%{
asset: item.amountAsset,
priced_in: item.priceAsset,
last: get_in(item, [:data, :lastPrice]),
volume: get_in(item, [:data, :volumeWaves])
}
end)
filtered_results_batch =
Enum.filter(market_snapshot, fn map -> map.volume >= 500 end)
|> Enum.filter(fn map -> map.asset != "8t8DMJFQu5GEhvAetiA8aHa3yPjxLj54sBnZsjnJ5dsw" end)
|> Enum.filter(fn map -> map.priced_in != "8t8DMJFQu5GEhvAetiA8aHa3yPjxLj54sBnZsjnJ5dsw" end)
|> Enum.group_by(fn map -> map.asset end)
IO.inspect(filtered_results_batch, limit: :infinity)
{:error, %Elixir.HTTPoison.Error{reason: reason}} ->
IO.inspect reason
end
end
end
iex(29)> Ticker.get_trades
%{
"34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" => [
%{
asset: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
last: 1.025684,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 267100.295139302
}
],
"3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2" => [
%{
asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2",
last: 0.21109993,
priced_in: "WAVES",
volume: 2163.280406054
}
],
"45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd" => [
%{
asset: "45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd",
last: 2.0e-7,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 2033.90714377482
}
],
"474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu" => [
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last: 185.30975552,
priced_in: "WAVES",
volume: 163469.163388528
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last: 0.02587195,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 71510.1292679334
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last: 271.280446,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 32730.9843988683
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last: 364,
priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
volume: 1205.6915071463
}
],
"4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8" => [
%{
asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
last: 0.05000309,
priced_in: "WAVES",
volume: 18617.6308480401
},
%{
asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
last: 7.65e-6,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 1143.28730054849
}
],
"4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC" => [
%{
asset: "4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC",
last: 1495.8897,
priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
volume: 3589.60637614465
}
],
"51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze" => [
%{
asset: "51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze",
last: 0.0004,
priced_in: "WAVES",
volume: 3380.33814675556
}
],
"5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3" => [
%{
asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
last: 0.00919398,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 25750.2735980453
},
%{
asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
last: 0.35377056,
priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
volume: 4533.59302949823
},
%{
asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
last: 65.4,
priced_in: "WAVES",
volume: 1239.37264031842
}
],
"5b3UGNZXX5srkHUQWnEWEiaVtnNWmg5aLo5uZMdjWupH" => [
%{
asset: "5b3UGNZXX5srkHUQWnEWEiaVtnNWmg5aLo5uZMdjWupH",
last: 146.69,
priced_in: "WAVES",
volume: 191358.551550345
}
],
"5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz" => [
%{
asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
last: 4.614e-5,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 5534.59587525975
},
%{
asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
last: 0.33011187,
priced_in: "WAVES",
volume: 710.616569376824
}
],
"62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH" => [
%{
asset: "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH",
last: 0.0347934,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 3426.55873790615
}
],
"6UfBupFwFnWTrnFDWiR73LQjPxRY38CgZ6Bu4m4SySQY" => [
%{
asset: "6UfBupFwFnWTrnFDWiR73LQjPxRY38CgZ6Bu4m4SySQY",
last: 5.03,
priced_in: "WAVES",
volume: 214114.7735372
}
],
"7FzrHF1pueRFrPEupz6oiVGTUZqe8epvC7ggWUx8n1bd" => [
%{
asset: "7FzrHF1pueRFrPEupz6oiVGTUZqe8epvC7ggWUx8n1bd",
last: 0.039,
priced_in: "WAVES",
volume: 1835.65668815896
}
],
"8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" => [
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last: 10551.16,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 61621.9607737891
},
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last: 14100,
priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
volume: 1308.46213932105
}
],
"8Yw4QmskrQauQeNjgh2fTQ4swmkNm85GTQzdHEf6QdUU" => [
%{
asset: "8Yw4QmskrQauQeNjgh2fTQ4swmkNm85GTQzdHEf6QdUU",
last: 0.00200523,
priced_in: "WAVES",
volume: 1621.98025276234
}
],
"8ofu3VpEaVCFjRqLLqzTMNs5URKUUQMrPp3k6oFmiCc6" => [
%{
asset: "8ofu3VpEaVCFjRqLLqzTMNs5URKUUQMrPp3k6oFmiCc6",
last: 0.0058002,
priced_in: "WAVES",
volume: 1295.83829520094
}
],
"B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H" => [
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 92.11504108,
priced_in: "WAVES",
volume: 5361.01458017704
},
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 0.0128115,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 4794.52522187697
},
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 0.49482287,
priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
volume: 1006.27215088303
}
],
"BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa" => [
%{
asset: "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa",
last: 50.45737882,
priced_in: "WAVES",
volume: 1058.98678090957
}
],
"DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J" => [
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last: 5500,
priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
volume: 7908.66204241657
},
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last: 0.04751001,
priced_in: "WAVES",
volume: 3074.6876554946
}
],
"EEazYfNWspbhD1viq9S7zUWJ74owa27MhKUk9eRi1oU1" => [
%{
asset: "EEazYfNWspbhD1viq9S7zUWJ74owa27MhKUk9eRi1oU1",
last: 58974300,
priced_in: "AbunLGErT5ctzVN8MVjb4Ad9YgjpubB8Hqb17VxzfAck",
volume: 290883.535905132
}
],
"EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK" => [
%{
asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
last: 0.432,
priced_in: "WAVES",
volume: 5392.7609398927
},
%{
asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
last: 6.25e-5,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 4758.57423400068
}
],
"HXtwvrpL8qiYCGC2D6WdiWgqQ5qSyQRQWmo9zDJk32ki" => [
%{
asset: "HXtwvrpL8qiYCGC2D6WdiWgqQ5qSyQRQWmo9zDJk32ki",
last: 0.0042,
priced_in: "WAVES",
volume: 2445.94802956423
}
],
"HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" => [
%{
asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
last: 56.32997843,
priced_in: "WAVES",
volume: 39124.7838806494
},
%{
asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
last: 0.00784081,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 15753.1313272784
},
%{
asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
last: 0.30279496,
priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
volume: 1881.19395882513
}
],
"WAVES" => [
%{
asset: "WAVES",
last: 1.4664,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 302029.32218876
},
%{
asset: "WAVES",
last: 1.3945e-4,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 240635.33906828
},
%{
asset: "WAVES",
last: 1.95,
priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
volume: 5007.98941368
},
%{
asset: "WAVES",
last: 1.8,
priced_in: "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU",
volume: 1464.14990126
},
%{
asset: "WAVES",
last: 1.4994,
priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
volume: 1183.9389929
}
],
"knZe9t5sZRqe9khJjWQXKnScaN4WEyY4zM1mCmvvuUB" => [
%{
asset: "knZe9t5sZRqe9khJjWQXKnScaN4WEyY4zM1mCmvvuUB",
last: 1.24e-6,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 1055.66692417624
}
],
"zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy" => [
%{
asset: "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy",
last: 0.0458593,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 510.917174296981
}
]
}
However, if |> Enum.group_by(fn map -> map.asset end)
is changed to |> Enum.frequencies(fn map -> map.asset end)
this error comes up:
iex(29)> Ticker.get_trades
** (UndefinedFunctionError) function Enum.frequencies/2 is undefined or private
(elixir) Enum.frequencies([%{asset: "WAVES", last: 1.4639, priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p", volume: 301788.04693071}, %{asset: "EEazYfNWspbhD1viq9S7zUWJ74owa27MhKUk9eRi1oU1", last: 58974300, priced_in: "AbunLGErT5ctzVN8MVjb4Ad9YgjpubB8Hqb17VxzfAck", volume: 290883.535905132}, %{asset: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ", last: 1.026741, priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p", volume: 266690.967427575}, %{asset: "WAVES", last: 1.4e-4, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 237505.27971324}, %{asset: "6UfBupFwFnWTrnFDWiR73LQjPxRY38CgZ6Bu4m4SySQY", last: 5.03, priced_in: "WAVES", volume: 214114.7735372}, %{asset: "5b3UGNZXX5srkHUQWnEWEiaVtnNWmg5aLo5uZMdjWupH", last: 146.69, priced_in: "WAVES", volume: 191358.551550345}, %{asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", last: 186.24510404, priced_in: "WAVES", volume: 162593.559948022}, %{asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", last: 0.02604249, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 71961.8942898352}, %{asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", last: 10534.91, priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p", volume: 61601.1451172342}, %{asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk", last: 56.68628581, priced_in: "WAVES", volume: 38808.2575538546}, %{asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", last: 270.732162, priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p", volume: 32921.9543475553}, %{asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3", last: 0.00922331, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 25941.3375320987}, %{asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8", last: 0.05299779, priced_in: "WAVES", volume: 18616.9953312599}, %{asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk", last: 0.00789012, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 15851.8565485579}, %{asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J", last: 5550, priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi", volume: 7908.66204241657}, %{asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK", last: 0.468, priced_in: "WAVES", volume: 5925.56761879269}, %{asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK", last: 6.5e-5, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 5395.26865961303}, %{asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H", last: 92.11504108, priced_in: "WAVES", volume: 5361.01458017705}, %{asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz", last: 4.64e-5, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 5263.70887105495}, %{asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H", last: 0.0128115, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 4765.78251366565}, %{asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3", last: 0.35377056, priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", volume: 4533.59302949823}, %{asset: "WAVES", last: 1.95, priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck", volume: 4257.43776532}, %{asset: "4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC", last: 1495.8897, priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi", volume: 3589.60637614465}, %{asset: "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH", last: 0.0347934, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 3425.85437138884}, %{asset: "51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze", last: 0.0004, priced_in: "WAVES", volume: 3329.86282208509}, %{asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J", last: 0.04751001, priced_in: "WAVES", volume: 3074.6876554946}, %{asset: "45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd", last: 2.1e-7, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 2202.69464471302}, %{asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2", last: 0.34536699, priced_in: "WAVES", volume: 2162.0242059398}, %{asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk", last: 0.30322033, priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", volume: 1911.28486340267}, %{asset: "7FzrHF1pueRFrPEupz6oiVGTUZqe8epvC7ggWUx8n1bd", last: 0.039, priced_in: "WAVES", volume: 1835.72240013919}, %{asset: "HXtwvrpL8qiYCGC2D6WdiWgqQ5qSyQRQWmo9zDJk32ki", last: 0.0042, priced_in: "WAVES", volume: 1802.29743544415}, %{asset: "8Yw4QmskrQauQeNjgh2fTQ4swmkNm85GTQzdHEf6QdUU", last: 0.00197234, priced_in: "WAVES", volume: 1617.02063672233}, %{asset: "WAVES", last: 1.8, priced_in: "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU", volume: 1464.14990126}, %{asset: "8ofu3VpEaVCFjRqLLqzTMNs5URKUUQMrPp3k6oFmiCc6", last: 0.02, priced_in: "WAVES", volume: 1295.83833206095}, %{asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3", last: 65.4, priced_in: "WAVES", volume: 1239.37264031842}, %{asset: "WAVES", last: 1.43, priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ", volume: 1231.92519011}, %{asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8", last: 7.64e-6, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 1136.8851927755}, %{asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", last: 14100, priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck", volume: 1077.11528209199}, %{asset: "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa", last: 51.33540473, priced_in: "WAVES", volume: 1065.87733156505}, %{asset: "knZe9t5sZRqe9khJjWQXKnScaN4WEyY4zM1mCmvvuUB", last: 1.24e-6, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 1055.44992032728}, %{asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H", last: 0.49482287, priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", volume: 1006.27215088303}, %{asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz", last: 0.33011187, priced_in: "WAVES", volume: 710.616569376824}, %{asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", last: 364, priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck", volume: 697.46494979047}, %{asset: "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy", last: 0.0458593, priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", volume: 510.812149699938}], #Function<4.51598045/1 in Ticker.get_trades/0>)
(arbit) lib/Ticker.ex:42: Ticker.get_trades/0
What I want to do is identify and remove those lists with only one element. For instance:
"34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" => [
%{
asset: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
last: 1.025684,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 267100.295139302
}
],
"3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2" => [
%{
asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2",
last: 0.21109993,
priced_in: "WAVES",
volume: 2163.280406054
}
],
"45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd" => [
%{
asset: "45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd",
last: 2.0e-7,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 2033.90714377482
}
]
would be removed leaving only elements such as:
"8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" => [
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last: 10551.16,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 61621.9607737891
},
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last: 14100,
priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
volume: 1308.46213932105
}
],
"B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H" => [
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 92.11504108,
priced_in: "WAVES",
volume: 5361.01458017704
},
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 0.0128115,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 4794.52522187697
},
%{
asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
last: 0.49482287,
priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
volume: 1006.27215088303
}
]
The first step, I imagined, was to use Enum.frequencies_by()
to identify those elements with just one element and then use |> Map.drop
to remove them.
Where am I going wrong?
Thanks for all your help