This commit is contained in:
discountry
2025-10-03 15:28:16 +08:00
parent d5c4b04746
commit fcb83bd16b
925 changed files with 165721 additions and 4 deletions
@@ -0,0 +1,58 @@
- [Binance Market Order Quote Usdt](./examples/py/)
```python
# -*- coding: utf-8 -*-
import os
import sys
from pprint import pprint
import ccxt # noqa: E402
print('CCXT Version:', ccxt.__version__)
exchange = ccxt.binance({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
})
markets = exchange.load_markets()
# exchange.verbose = True # uncomment for debugging purposes if necessary
symbol = 'ETH/USDT'
try:
print('--------------------------------------------------------------')
# option 1  specify price * amount
amount = 1
price = 4000
# cost = amount * price
# this line will use the amount * price to calculate the total cost-to-spend (4000)
order = exchange.create_order(symbol, 'market', 'buy', amount, price)
pprint(order)
print('--------------------------------------------------------------')
# option 2  specify
# this line does the same, but you override the cost via extra params
params = {
'quoteOrderQty': 4000, # binance-specific
}
amount = None
price = None
order = exchange.create_order(symbol, 'market', 'buy', amount, price, params)
pprint(order)
except Exception as e:
print(type(e).__name__, str(e))
```