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

Invalid signature for order #75

Closed
melaurent opened this issue Oct 4, 2021 · 5 comments
Closed

Invalid signature for order #75

melaurent opened this issue Oct 4, 2021 · 5 comments

Comments

@melaurent
Copy link

I am getting the following error while placing an order

placed_order = client.private.create_order(
  position_id=1, # required for creating the order signature
  market=MARKET_BTC_USD,
  side=ORDER_SIDE_BUY,
  order_type=ORDER_TYPE_LIMIT,
  post_only=False,
  size='0.01',
  price='35000',
  limit_fee='0.1',
  expiration_epoch_seconds=int(time.time() + 60 * 60),
  time_in_force=TIME_IN_FORCE_GTT,
)

DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'Invalid signature for order'}]})

@eugenepentland
Copy link

eugenepentland commented Oct 9, 2021

What did you do to resolve this issue? I haven't been able to place an order because I ran into the same problem.

Edit: I was able to resolve the issue, the position_id has to be grabbed from your account, as shown in the orders.py example.

account_response = client.private.get_account()
position_id = account_response['account']['positionId']

place_order = client.private.create_order(
position_id=position_id,
market=MARKET_ETH_USD,
side=ORDER_SIDE_SELL,
order_type=ORDER_TYPE_LIMIT,
post_only=False,
size='1',
price='4000',
limit_fee='0.01',
expiration_epoch_seconds=int(time.time() + 60 * 60),
time_in_force=TIME_IN_FORCE_GTT,
)

@crazyoptimist
Copy link

crazyoptimist commented Dec 1, 2021

It doesn't work now, Response object is now changed since you figured it out the last time I guess.

account_response = client.private.get_account()
print(account_response.data['account'])

It has a key id, there is no such key positionId

Anyone can help with this?

@crazyoptimist
Copy link

Figured it out and commented in #96

@smypmsa
Copy link

smypmsa commented Feb 13, 2022

It works

account_response = client.private.get_account()
print(account_response.data['account']['positionId'])

@gabrielfior
Copy link

Also does not work from my side:

account = self.get_account()
position_id = account.data['account']['positionId']

create_order_result = self.client.private.create_order(
            position_id=position_id,
            market=constants.MARKET_BTC_USD,
            side=constants.ORDER_SIDE_BUY,
            order_type=constants.ORDER_TYPE_MARKET,
            post_only=False,
            size=str(size),
            limit_fee='0.1',
            price=str(int(index_price)),
            time_in_force='FOK',
            expiration=epoch_seconds_to_iso(time.time() + 120)
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants