当我尝试以下代码行时
print(self.exchange3.privateGetPosition([{'currentQty'}]))
我得到以下错误
File "c:/Users/User2/sample_market_maker/SAMPLE/botv2.py", line 130, in place_orders
print(self.exchange3.privateGetPosition([{"currentQty"}]))
File "C:\Users\User2\.virtualenvs\sample_market_maker-9Hdi4SL0\lib\site-packages\ccxt\base\exchange.py", line 364, in request
return self.fetch2(path, api, method, params, headers, body)
File "C:\Users\User2\.virtualenvs\sample_market_maker-9Hdi4SL0\lib\site-packages\ccxt\base\exchange.py", line 360, in fetch2
request = self.sign(path, api, method, params, headers, body)
File "C:\Users\User2\.virtualenvs\sample_market_maker-9Hdi4SL0\lib\site-packages\ccxt\bitmex.py", line 577, in sign
query += '?' + self.urlencode(params)
TypeError: can only concatenate str (not "list") to str
当我打印以查看可用的嵌套dict时,得到以下信息
print(self.exchange3.privateGetPosition())
[{'account': 108879, 'symbol': 'XBTUSD', 'currency': 'XBt', 'underlying':
'XBT', 'quoteCurrency': 'USD', 'commission': 0.00075, 'initMarginReq': 0.04,
'maintMarginReq': 0.005, 'riskLimit': 20000000000, 'leverage': 25,
'crossMargin': False, 'deleveragePercentile': None, 'rebalancedPnl': 0,
'prevRealisedPnl': -18679, 'prevUnrealisedPnl': 0, 'prevClosePrice':
4348.84, 'openingTimestamp': '2018-11-29T20:00:00.000Z', 'openingQty': 0,
'openingCost': 0, 'openingComm': 0, 'openOrderBuyQty': 0,
'openOrderBuyCost': 0, 'openOrderBuyPremium': 0, 'openOrderSellQty': 0,
'openOrderSellCost': 0, 'openOrderSellPremium': 0, 'execBuyQty':
0, 'execBuyCost': 0, 'execSellQty': 0, 'execSellCost': 0, 'execQty': 0,
'execCost': 0, 'execComm': 0, 'currentTimestamp': '2018-11-
29T20:00:00.369Z', 'currentQty': 0, 'currentCost': 0, 'currentComm': 0,
'realisedCost': 0, 'unrealisedCost': 0, 'grossOpenCost': 0,
'grossOpenPremium': 0, 'grossExecCost': 0, 'isOpen': False, 'markPrice':
None, 'markValue': 0, 'riskValue': 0, 'homeNotional': 0, 'foreignNotional':
0, 'posState': '', 'posCost': 0, 'posCost2': 0, 'posCross': 0, 'posInit': 0,
'posComm': 0, 'posLoss': 0, 'posMargin': 0, 'posMaint': 0, 'posAllowance':
0, 'taxableMargin': 0, 'initMargin': 0, 'maintMargin': 0, 'sessionMargin':
0, 'targetExcessMargin': 0, 'varMargin': 0, 'realisedGrossPnl': 0,
'realisedTax': 0, 'realisedPnl': 0, 'unrealisedGrossPnl': 0, 'longBankrupt':
0, 'shortBankrupt': 0, 'taxBase': 0, 'indicativeTaxRate': 0,
'indicativeTax': 0, 'unrealisedTax': 0, 'unrealisedPnl': 0,
'unrealisedPnlPcnt': 0, 'unrealisedRoePcnt': 0, 'simpleQty': None,
'simpleCost': None, 'simpleValue': None, 'simplePnl': None, 'simplePnlPcnt':
None, 'avgCostPrice': None, 'avgEntryPrice': None,
'breakEvenPrice': None, 'marginCallPrice': None, 'liquidationPrice': None,
'bankruptPrice': None, 'timestamp': '2018-11-29T20:00:00.369Z', 'lastPrice':
None, 'lastValue': 0}]
有人知道我做错了什么,我在尝试获取currentQty值吗?
这是蟒蛇37
最佳答案
正确的方法是:
positions = self.exchange3.privateGetPosition()
print(positions[0]['currentQty'])
更多信息:
https://github.com/ccxt/ccxt/wiki/Manual#implicit-api-methods
https://www.bitmex.com/api/explorer/#!/Position/Position_get