polymarket-cpp-client icon indicating copy to clipboard operation
polymarket-cpp-client copied to clipboard

order_type_to_string

Open DanceBot1234 opened this issue 5 months ago • 3 comments

clob_client.cpp::order_type_to_string

line 133 what is "IOC"? It doesn't work for me, and it's not it the docs: https://docs.polymarket.com/api-reference/trade/post-a-new-order#body-order-type

Am I missing something? It works when you change that to "FAK"...

DanceBot1234 avatar Jun 21 '26 20:06 DanceBot1234

Thanks for catching this. You are not missing anything.

IOC is the generic trading term for "Immediate Or Cancel", which is very close to Polymarket's FAK / "Fill And Kill" behavior. But the Polymarket API currently documents and accepts FAK as the wire value for orderType, not IOC. The client already exposed the enum as OrderType::FAK, so serializing it as "IOC" was a bug in this library.

I fixed the mapping so OrderType::FAK now serializes as "FAK", clarified the enum comment, and added a regression test for the order type serialization. The fix was merged in #23 and released as v1.3.0 here: https://github.com/SebastianBoehler/polymarket-cpp-client/releases/tag/v1.3.0

Your local workaround of changing "IOC" to "FAK" was exactly right.

SebastianBoehler avatar Jun 21 '26 21:06 SebastianBoehler

Thank you for your quick responses. I'm now testing out GTC orders, appears to work except once so far.

In order_test.cpp if you hard code best_ask = 0.023; (which happened to me once), you'll still fail with Order placement failed: price 0.0200000004600874 breaks minimum tick size rule 0.01

I've run it successfully about 10 times so far, and only had this fail once, so maybe it's because of the weird three decimal place best_ask price. On the other hand, if you hard code it to 0.026 that works...

I'm not sure if this qualifies as a new issue or not, let me know if you'd like me to move it to one or if we can ignore this since it shouldn't happen very frequently.

Thanks again.

DanceBot1234 avatar Jun 22 '26 14:06 DanceBot1234

Thanks, I treated this as a separate tick-size / market-metadata issue and merged a fix here: https://github.com/SebastianBoehler/polymarket-cpp-client/pull/24

The unsafe part was that order_test.cpp hard-coded tick_size = "0.01". That sample now fetches the selected token's live order book, minimum_tick_size, and neg_risk during market discovery, caches those values together, and passes the cached tick size into CreateMarketOrderParams when constructing the order. If the sample cannot fetch complete trading metadata for a candidate market, it skips that candidate instead of placing an order with a fixed tick-size assumption.

CI passed on the merged PR across the macOS/Ubuntu debug/release matrix.

There may still be a second precision edge in how market-order maker/taker amounts are encoded from decimal prices, but the example should now demonstrate the right pattern for fetching and reusing instrument metadata dynamically.

SebastianBoehler avatar Jun 22 '26 15:06 SebastianBoehler