Comments (11)
OK ,thanks a lot
from dydx-v3-python.
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.
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.
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.
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 ?
from dydx-v3-python.
from dydx-v3-python.
You didn't enable trading (sign the transaction in the metamask) I guess?
Deposit some funds and try again.
from dydx-v3-python.
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.
The error is from the Ethereum mainnet or Ropsten network?
from dydx-v3-python.
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:
- 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, )
- 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.
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)
- order submission gets an error: Invalid signature for order. HOT 5
- OHLC on DYDX does not match "current price".
- "STOP_MARKET" order ?.
- ImportError: cannot import name 'getargspec' from 'inspect' HOT 3
- {"msg":"Unauthorized"} + limitFee scale of 6 HOT 1
- HTTP 401 on https://api.stage.dydx.exchange/v3/fills?xxxx=yyyy
- Cancel order failing with authorization issues
- Error using the example order.py HOT 1
- Onboarding on Sepolia failes HOT 6
- WebSocket : OrderBook : Data sent is pre-maching-engine data, yielding "invalid" order books
- Python-only onboarding fails at source_client.eth.transfer_token with ERC20: transfer amount exceeds balance
- On opening some trades: 'NoneType' object is not subscriptable HOT 1
- Error: Incorrect padding
- There is not enough liquidity to fill this market order, please try a smaller order amount.
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- DydxApiError: DydxApiError(status_code=400, response={'errors': [{'msg': 'Order expiration cannot be less than 1 minute(s) in the future'}]})
- '[Errno 111] Connection refused' when trying to 'get_markets()'
- Can't Close Positions when Margin Utilization Gets Too High
- Request to add a limit on how often the websocket interface can fetch public data
- Websockets dependency conflict
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dydx-v3-python.