Giter Site home page Giter Site logo

Comments (11)

sxk000 avatar sxk000 commented on September 2, 2024 1

OK ,thanks a lot

from dydx-v3-python.

crazyoptimist avatar crazyoptimist commented on September 2, 2024

Figured it out.
position_id field was wrong, which we can get from this request:

account = client.private.get_account(
  ethereum_address='0x0123...',
)

It's in the docs but not quite clear yet.
The point is that you will get different responses with and without the param ethereum_address, positionId can be retrieved only when the param is given.
woohoo! now it works!

from dydx-v3-python.

sxk000 avatar sxk000 commented on September 2, 2024

Figured it out. position_id field was wrong, which we can get from this request:

account = client.private.get_account(
  ethereum_address='0x0123...',
)

It's in the docs but not quite clear yet. The point is that you will get different responses with and without the param ethereum_address, positionId can be retrieved only when the param is given. woohoo! now it works!

when i run this api ,and got a error:

account = client.private.get_account(ethereum_address='0x0123...')

\dydx3\helpers\requests.py", line 33, in request
raise DydxApiError(response)
dydx3.errors.DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'API key not found'}]})

then i run aip :

api_key_response = client.eth_private.create_api_key()

got error:

'Field with relationship to another table must match other table'

is it right?

what i can do next?

from dydx-v3-python.

crazyoptimist avatar crazyoptimist commented on September 2, 2024

#62 (comment)

To explain in more detail:
Login to the dashboard(configure it to remember you for the next logins), and open the browser console, look for Local Storage in the "Application" tab, then you will be able to find out "Stark Key Pair" and "API Credentials".
Use those info for initializing the client, it should work. See here for the implementation example.
Hope it helps!

from dydx-v3-python.

sxk000 avatar sxk000 commented on September 2, 2024

#62 (comment)

To explain in more detail: Login to the dashboard(configure it to remember you for the next logins), and open the browser console, look for Local Storage in the "Application" tab, then you will be able to find out "Stark Key Pair" and "API Credentials". Use those info for initializing the client, it should work. See here for the implementation example. Hope it helps!

thanks ,i check it out , and get stark key , but there is no API credectials . My account has no money , is the reason that cause no API credectials ?

image

from dydx-v3-python.

crazyoptimist avatar crazyoptimist commented on September 2, 2024

console

from dydx-v3-python.

crazyoptimist avatar crazyoptimist commented on September 2, 2024

You didn't enable trading (sign the transaction in the metamask) I guess?
Deposit some funds and try again.

from dydx-v3-python.

Etherdrake avatar Etherdrake commented on September 2, 2024

For me this is happening while I am 100% sure my .env is correct. I have created my keys using the retrieve keys method etc.

Placing orders simply won't work using the following code:

`import datetime
import websockets, json, time
import pandas as pd
import os
import dydx3
import requests
import dotenv
from dotenv import load_dotenv
from sortedcontainers import SortedDict
from decimal import Decimal
from web3 import Web3

dYdX dependencies

from dydx3 import Client
from dydx3.constants import *

load_dotenv()

dydx_mainnet = 'https://api.dydx.exchange'
dydx_staging = 'https://api.stage.dydx.exchange'

web3 = Web3(Web3.HTTPProvider(API_HOST_ROPSTEN))

ropsten_usdc = '0x8707a5bf4c2842d46b31a405ba41b858c0f876c4'

PRIVATE_KEY = os.getenv('PRIVATE_KEY')
API_KEY = os.getenv('API_KEY')
API_SECRET = os.getenv('API_SECRET')
API_PASSPHRASE = os.getenv('API_PASSPHRASE')
STARK_PRIVATE_KEY = os.getenv('STARK_PRIVATE_KEY')
ETH_ADDRESS = os.getenv('ETH_ADDRESS')
STARK_PUBLIC_KEY = os.getenv('STARK_PUBLIC_KEY')
STARK_PUBLIC_KEY_Y_COORDINATE = os.getenv('STARK_PUBLIC_KEY_Y_COORDINATE')

client = Client(
host=API_HOST_ROPSTEN,
api_key_credentials={'key': API_KEY,
'secret': API_SECRET,
'passphrase': API_PASSPHRASE},
stark_private_key=STARK_PRIVATE_KEY,
default_ethereum_address=ETH_ADDRESS,
)

Get the position ID.

account_response = client.private.get_account(ethereum_address=ETH_ADDRESS)

position_id = account_response.data['account']['positionId']

Post a BTC_USD order.

order_params = {
'position_id': position_id,
'market': MARKET_BTC_USD,
'side': ORDER_SIDE_BUY,
'order_type': ORDER_TYPE_LIMIT,
'post_only': True,
'size': '0.01',
'price': '44417',
'limit_fee': '0.015',
'expiration_epoch_seconds': time.time() + 120,

}

order_response = client.private.create_order(**order_params)
order_id = order_response.data['order']['id']`

@crazyoptimist would be amazing if you could help me a bit here. Basically been staring at this and the docs for four hours now. Also really cool you shared your sniper program online.

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

from dydx-v3-python.

crazyoptimist avatar crazyoptimist commented on September 2, 2024

The error is from the Ethereum mainnet or Ropsten network?

from dydx-v3-python.

Etherdrake avatar Etherdrake commented on September 2, 2024

The error is from the Ethereum mainnet or Ropsten network?

I get this error from Ropsten. I basically first want to do some testing there before playing around with real money. The account I am using has already placed trades through the web application.

EDIT:

I finally fixed this. Some things to take note off if you have a similar issue and are reading this:

  1. When using Ropsten the client initialization is diffferent.

Initialize the client like this when using Ropsten:

client = Client( host=API_HOST_ROPSTEN, stark_private_key=STARK_PRIVATE_KEY, eth_private_key=ETH_PRIVATE_KEY, network_id=NETWORK_ID_ROPSTEN, )

  1. Your STARK keys should be in base16, convert them with hex(int("0x"+ key, base=16)

My mistake was also passing the API keys and my Ethereum address to the client initialization.

from dydx-v3-python.

nikotsakiris avatar nikotsakiris commented on September 2, 2024

If you guys are using a ROPSTEN account the problem is that when you authorize the client the network_id default value is 1 which is for the mainnet option. So on your client initialization just specify: network_id = 3, and the problem should be solved :)

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.