Here is what I use to generate a simple market order. I get an “unauthorized” error, no errors about the payload syntax. Pipe the output to a script and run the script. I pass three variables: the coin symbol (XLM-USD), the quantity to buy (44) and the client order ID (T5-test).
from coinbase import jwt_generator
import sys
symbol = sys.argv[1]
entryQ = sys.argv[2]
clientOID = sys.argv[3]
print(f":: symbol: {symbol} entryq: {entryQ} clientOID: {clientOID} ")
print()
data00 = ‘–data-raw ‘+"’"+’{“client_order_id”:“‘+clientOID+’”,“product_id”:“‘+symbol+’”,“side”:“BUY”,“order_configuration”:{“market_market_ioc”:{“quote_size”:“‘+entryQ+’”}}}‘+"’"
#print(f"raw data: {data00}")
#new trade key 2024-02-27
api_key = “something”
api_secret = “something secret”
request_method = “POST”
request_path = “/api/v3/brokerage/orders”
def main():
jwt_uri = jwt_generator.format_jwt_uri(request_method, request_path)
jwt_token = jwt_generator.build_rest_jwt(jwt_uri, api_key, api_secret)
print(f"set JWT={jwt_token}")
print(f’curl -X POST -H “Authorization: Bearer %JWT%” -H “Content-Type: application/json” https://api.coinbase.com/api/v3/brokerage/orders {data00} -o TestOrder.json’)
if name == “main”:
main()
In Windows 10 Pro here is the ouput from the Python
:: symbol: XLM-USD entryq: 44 clientOID: T5-test
set JWT=the generated JWT (too long for here)
curl -X POST -H “Authorization: Bearer %JWT%” -H “Content-Type: application/json” https://api.coinbase.com/api/v3/brokerage/orders --data-raw ‘{“client_order_id”:“T5-test”,“product_id”:“XLM-USD”,“side”:“BUY”,“order_configuration”:{“market_market_ioc”:{“quote_size”:“44”}}}’ -o TestOrder.json
and TestOrder.json is just
Unauthorized
I have generated multiple keys, tried many things, but can’t get an order to work. Getting open positions and open orders work with this same method, but have no payload.