mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-10 16:58:08 +00:00
34 lines
696 B
Markdown
34 lines
696 B
Markdown
- [Binance Poll Positions](./examples/py/)
|
|
|
|
|
|
```python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
import ccxt # noqa: E402
|
|
|
|
|
|
print('CCXT Version:', ccxt.__version__)
|
|
|
|
|
|
exchange = ccxt.binanceusdm({
|
|
'apiKey': 'YOUR_API_KEY',
|
|
'secret': 'YOUR_SECRET',
|
|
})
|
|
markets = exchange.load_markets()
|
|
|
|
# exchange.verbose = True # uncomment for debugging purposes if necessary
|
|
|
|
while True:
|
|
try:
|
|
positions = exchange.fetch_positions ()
|
|
print(exchange.iso8601(exchange.milliseconds()), len(positions), 'positions')
|
|
print([ [position['symbol'], position['contracts']] for position in positions ])
|
|
except Exception as e:
|
|
print(type(e).__name__, str(e))
|
|
|
|
|
|
``` |