mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 01:08:07 +00:00
commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
- [Phemex Leverage Orders](./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.phemex({
|
||||
'apiKey': 'YOUR_API_KEY', # testnet keys if using the testnet sandbox
|
||||
'secret': 'YOUR_SECRET', # testnet keys if using the testnet sandbox
|
||||
'options': {
|
||||
'defaultType': 'swap',
|
||||
},
|
||||
})
|
||||
|
||||
# exchange.set_sandbox_mode(True) # uncomment to use the testnet sandbox
|
||||
|
||||
markets = exchange.load_markets()
|
||||
|
||||
amount = 5
|
||||
symbol = 'BTC/USD:USD'
|
||||
|
||||
# Change leverage to the desired value
|
||||
leverageResponse = exchange.set_leverage(5, symbol)
|
||||
|
||||
# Opening a pending contract (limit) order
|
||||
order = exchange.create_order(symbol, 'market', 'buy', amount)
|
||||
print(order)
|
||||
|
||||
# Canceling pending contract
|
||||
closingOrder = exchange.create_order(symbol, 'market', 'sell', amount)
|
||||
pprint(closingOrder)
|
||||
|
||||
# Reset leverage to 1
|
||||
leverageResponse = exchange.set_leverage(1, symbol)
|
||||
print(leverageResponse)
|
||||
```
|
||||
Reference in New Issue
Block a user