Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Kucoin

notebooks/kucoin.livemd

Kucoin

Portfolio

Pex.KucoinTrade.coins_list()

Gets trades

Pex.Data.list_trades()
|> Enum.filter(&(&1.stop_loss != nil and &1.platform == "kucoin"))
|> Enum.map(fn order ->
  {:ok, %{price: price}} = Pex.KucoinTrade.get_price(order.symbol)
  current_price = String.to_float(price)
  percent = Pex.Stat.percent_order(order, current_price)

  %{
    id: order.id,
    coin: order.symbol,
    sl: order.stop_loss,
    tp: order.take_profit,
    percent: Float.ceil(percent, 2),
    bought: order.price
  }
end)
|> Enum.sort(&(&1.coin > &2.coin))

Buy market

pair = COIN-COIN

{take_profit, _} = IO.gets("take_profit") |> Float.parse()
{distance, _} = IO.gets("distance") |> Float.parse()
pair = IO.gets("pair") |> String.trim("\n")

Pex.KucoinTrade.trade_buy(pair, take_profit, distance)