dydxprotocol / v4-clients

Other
77 stars 57 forks source link

UNCLEAR ON PLACING MARKET ORDER IN V2 PY #200

Closed shaunsurfing closed 4 months ago

shaunsurfing commented 4 months ago

place = await node.place_order( wallet, market.order( order_id, side = Order.Side.SIDE_BUY if side == "BUY" else Order.Side.SIDE_SELL, size = size, price = price, time_in_force = Order.TIME_IN_FORCE_UNSPECIFIED, reduce_only = reduce_only, good_til_block = good_til_block ), )

What is the code to place a MARKET (not limit order). This is in depreciated V1 .py but unable to find in V2?

linear[bot] commented 4 months ago

GH-53 UNCLEAR ON PLACING MARKET ORDER IN V2 PY

shaunsurfing commented 4 months ago

Not sure what Linear is, but unable to read the BOT reply:

image

samtin0x commented 4 months ago

Hi @shaunsurfing,

I'm reviewing this now and will get back to you soon.

samtin0x commented 4 months ago

Hey, we're currently implementing chain helpers to make placing market orders more intuitive, similar to the deprecated Python and the current TypeScript version that has OrderType.

You can follow its progress in PR #201

samtin0x commented 4 months ago

Hi @shaunsurfing, I've updated the SDK so place order accepts order_type as a parameter. There's an example in examples/market_order_example.py and new documentation will be published soon.

Here's the current approach:

new_order = market.order(
        order_id=order_id,
        order_type=OrderType.MARKET,
        side=Order.Side.SIDE_SELL,
        size=size,
        price=0,  # Set to 0 for market orders
        time_in_force=Order.TimeInForce.TIME_IN_FORCE_UNSPECIFIED,
        reduce_only=False,
        good_til_block=current_block + 10,
    )

    transaction = await node.place_order(
        wallet=wallet,
        order=new_order,
    )

I'm closing this issue but let me know if you face any other issues

shaunsurfing commented 3 months ago

Thank you @samtin0x - the orders are going through.