Giter Site home page Giter Site logo

Comments (6)

traderblakeq avatar traderblakeq commented on July 28, 2024 3

... Would be fantastic, if this were implemented in a simply way into the dydx-v3 python wrapper, any plans of doing that ?

something like:

response = client.private.close_position(order_id=order_id)

from dydx-v3-python.

Bennch avatar Bennch commented on July 28, 2024 1

I'm searching for a solution too. Something like market sell, to sell imminently.
To sell with limit orders does not work so often...

from dydx-v3-python.

Bennch avatar Bennch commented on July 28, 2024 1

That is what i was trying all the time. But if the orderbook is low, the order will not be filled. I real MARKET order shout not need a price variable.

from dydx-v3-python.

hbeijeman avatar hbeijeman commented on July 28, 2024

@Bennch , @gabrielfior , this is possible.

You need to fetch your open positions via a call to private_client.private.get_account()
The open positions will have a market and a size (amount).

Then simply for that market / size create a sell order, for example,

    r = private_client.private.create_order(
        position_id=position_id,
        market=MARKET_ETH_USD,
        side=ORDER_SIDE_SELL,
        order_type=ORDER_TYPE_MARKET,
        post_only=False,
        size='0.01',
        price='2020.0',
        limit_fee='0.015',
        expiration_epoch_seconds=1652619576,
        time_in_force=TIME_IN_FORCE_FOK
        )

from dydx-v3-python.

hbeijeman avatar hbeijeman commented on July 28, 2024

That is what i was trying all the time. But if the orderbook is low, the order will not be filled. I real MARKET order shout not need a price variable.

Yeah, I found that confusing as well. I traced the UI and I noticed that the price is +100 above or below the index price. And checking the result the order was executed for the actual index price. So I'm guessing the backend is doing BEST(price, index).

So far, my orders do get executed and never stuck.

from dydx-v3-python.

roigecode avatar roigecode commented on July 28, 2024

Another possible way to do it as sugested by @hbeijeman could be tracking your current open positions with

all_positions = client.private.get_positions( market=MARKET_ETH_USD, status=POSITION_STATUS_OPEN, )

filter then by any desired conditions (such as entryPrice) then just getting the side (either LONG or SHORT) and creating an opposite order.

from dydx-v3-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.