mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
- [Async Bitget Perpetual Futures Swaps](./examples/py/)
|
||||
|
||||
|
||||
```python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
from asyncio import run
|
||||
|
||||
|
||||
|
||||
import ccxt.async_support as ccxt
|
||||
|
||||
|
||||
async def main():
|
||||
exchange = ccxt.bitget({
|
||||
'apiKey': 'YOUR_API_KEY',
|
||||
'secret': 'YOUR_SECRET',
|
||||
'password': 'YOUR_API_PASSWORD',
|
||||
'options': {
|
||||
'defaultType': 'swap',
|
||||
}
|
||||
})
|
||||
|
||||
try:
|
||||
|
||||
markets = await exchange.load_markets()
|
||||
|
||||
# exchange.verbose = True # uncomment for debugging purposes if necessary
|
||||
|
||||
# fetching balance
|
||||
balance = await exchange.fetch_balance()
|
||||
print(balance['total'])
|
||||
|
||||
# placing a limit order
|
||||
symbol = 'ETH/USDT:USDT'
|
||||
type = 'limit'
|
||||
side = 'buy'
|
||||
amount = 1 # how many contracts to buy or sell, integer number of contracts
|
||||
price = 3000
|
||||
order = await exchange.create_order(symbol, type, side, amount, price)
|
||||
print(order)
|
||||
|
||||
# placing a market order
|
||||
symbol = 'ETH/USDT:USDT'
|
||||
type = 'market'
|
||||
side = 'sell'
|
||||
amount = 1 # how many contracts to buy or sell, integer number of contracts
|
||||
order = await exchange.create_order(symbol, type, side, amount)
|
||||
print(order)
|
||||
|
||||
except Exception as e:
|
||||
print(type(e).__name__, str(e))
|
||||
|
||||
await exchange.close()
|
||||
|
||||
|
||||
run(main())
|
||||
```
|
||||
Reference in New Issue
Block a user