Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production bug - stop loss related - race condition #39

Open
Cinderella-Man opened this issue Oct 1, 2019 · 0 comments
Open

Production bug - stop loss related - race condition #39

Cinderella-Man opened this issue Oct 1, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@Cinderella-Man
Copy link
Owner

After initial investigation I believe it's related to stop loss being triggered on order that was filled.

Stack trace:

iex(9)> 19:49:20.503 module=gen_server [error] GenServer #PID<0.2731.0> terminating
** (FunctionClauseError) no function clause matching in Hefty.Algos.Naive.Trader.store_order/2
    (hefty) lib/hefty/algos/naive/trader.ex:721: Hefty.Algos.Naive.Trader.store_order(%{
			"clientOrderId" => "pdqIWjicGMqKKK6V7w0l1A",
			"cummulativeQuoteQty" => "28.35532800",
			"executedQty" => "111.60000000",
			"fills" => [
				%{
					"commission" => "0.00117660",
					"commissionAsset" => "BNB",
					"price" => "0.25408000",
					"qty" => "111.60000000",
					"tradeId" => 36226832
				}
			],
			"orderId" => 251895741,
			"orderListId" => -1,
			"origQty" => "111.60000000",
			"price" => "0.00000000",
			"side" => "SELL",
			"status" => "FILLED",
			"symbol" => "XRPUSDT",
			"timeInForce" => "GTC",
			"transactTime" => 1569350960304,
			"type" => "MARKET"
		},
		246037688
	)
    (hefty) lib/hefty/algos/naive/trader.ex:616: Hefty.Algos.Naive.Trader.handle_stop_loss/4
    (hefty) lib/hefty/algos/naive/trader.ex:470: Hefty.Algos.Naive.Trader.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Broadcast{event: "trade_event", payload: %Hefty.Repo.Binance.TradeEvent{__meta__: #Ecto.Schema.Metadata<:loaded, "trade_events">, buyer_market_maker: true, buyer_order_id: 251895588, event_time: 1569350959202, event_type: "trade", id: "f4193777-a972-4888-8b9e-43683f8f1ab7", inserted_at: ~N[2019-09-24 18:49:19], price: "0.25413000", quantity: "4985.80000000", seller_order_id: 251839179, symbol: "XRPUSDT", trade_id: 36226791, trade_time: 1569350959190, updated_at: ~N[2019-09-24 18:49:19]}, topic: "stream-XRPUSDT"}

Also, it's worth considering that possibly binance.ex should be extended by new fields like: fills, orderListId or cummulativeQuoteQty

@Cinderella-Man Cinderella-Man added the bug Something isn't working label Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant