d-e-s-o/apca

unknown variant ``, expected one of `simple`, `bracket`, `oco`, `oto`

Closed this issue · 3 comments

I've seen the following failure a couple of times in CI now (example):

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Endpoint(Conversion(Json(Error("unknown variant ``, expected one of `simple`, `bracket`, `oco`, `oto`", line: 1, column: 21996))))', src/api/v2/orders.rs:191:52
---- api::v2::orders::tests::list_orders stdout ----

This may be related to the order class change 569616c. I have not yet been able to reproduce locally, but haven't tried hard either. My suspicion is that leg orders don't have the order class property populated correctly, but I haven't verified that.

@husafan, have you seen this problem during your testing?

Unfortunately, I have. But I haven't seen it lately, and so I assumed it was a transient issue with the API.

If I had to guess, I would say it's being caused by #28, since POST'ing an Order has a "simple" default type. I imagine the response order sometimes does not have an order_type to parse? Feel free to assign to me and I will address shortly.

I have confirmed that placing a buy order with no specified order_class returns an order with order_class: "", which fails to parse.

I have fixed the bug, added a test and sent a pull request.

I have confirmed that placing a buy order with no specified order_class returns an order with order_class: "", which fails to parse.

Whoa, great find! Thanks for investigating. I am not sure this is intentional behavior, though. We may want to consider opening an issue against Alpaca.