Skip to content

Commit

Permalink
examples/py/phemex-positions.py close ccxt#7994
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 19, 2020
1 parent 06b0894 commit 54600e1
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions examples/py/phemex-positions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

import os
import sys
from pprint import pprint

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt # noqa: E402


print('CCXT Version:', ccxt.__version__)

exchange = ccxt.phemex({
'enableRateLimit': True, # https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
# '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()

# example 1
positions = exchange.fetch_positions(None, None, None, {'code':'BTC'})
pprint(positions)

print('------------------------------------------------------------')

# example 2
positions = exchange.fetch_positions(None, None, None, {'currency':'BTC'})
pprint(positions)

print('------------------------------------------------------------')

# example 3
balance = exchange.fetch_balance({'code':'BTC'})
pprint(balance['info']['data']['positions'])

print('------------------------------------------------------------')

# example 4
balance = exchange.fetch_balance({'currency':'BTC'})
pprint(balance['info']['data']['positions'])

print('------------------------------------------------------------')

# example 5
# https://github.com/ccxt/ccxt/wiki/Manual#implicit-api-methods
response = exchange.private_get_accounts_accountpositions({'currency': 'BTC'})
pprint(response['data']['positions'])

0 comments on commit 54600e1

Please sign in to comment.