TypeError: может объединять только str (не "list") в str - PullRequest
0 голосов
/ 30 ноября 2018

когда я пытаюсь выполнить следующую строку кода

 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

, когда я печатаю, чтобы увидеть доступные вложенные слова, я получаю следующее

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?Это python37

1 Ответ

0 голосов
/ 01 декабря 2018

Правильный способ сделать это:

positions = self.exchange3.privateGetPosition()
print(positions[0]['currentQty'])

Подробнее об этом:

...