Skip to main content
etiquetas editadas
Enlace
user22539
user22539
`importimport os
import sys
import time
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})`
` [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},
 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},

'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},`

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys uso. Uso el for element in trades para seleccionar el value dentro del key amount, pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values.

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

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})`
` [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},

'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},`

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys uso el for element in trades para seleccionar el value dentro del key amount pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values

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

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})
 [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},
 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys. Uso el for element in trades para seleccionar el value dentro del key amount, pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values.

cuerpo editado
Origen Enlace

Hola podeos ayudarme con esto.

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

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})`

La variable trades me arroja una lista que contiene dict

` [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},

'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},`

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys uso el for element in trades para seleccionar el value' dentro del key valueamount` dentro del key amount pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values

Hola podeos ayudarme con esto.

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

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})`

La variable trades me arroja una lista que contiene dict

` [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},

'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},`

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys uso el for element in trades para seleccionar el value' dentro del key amount` pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values

Hola podeos ayudarme con esto.

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

import ccxt  # noqa: E402

exchange = ccxt.bitmex({'enableRateLimit' : True})

since = exchange.parse8601('2019-06-11T00:00:00')

symbol = 'BTC/USD'
trades = exchange.fetch_trades(symbol, since )

for element in trades :
        print(element['amount'])

exchange.proxies : (
      {  'http': 'http://10.10.1.10:3128',
        'https': 'https://10.10.1.10:1080',})`

La variable trades me arroja una lista que contiene dict

` [{'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 1009, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'grossValue': 12587275, 'homeNotional': 0.12587275, 'foreignNotional': 1009},

'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': 'aa4a0402-edf4-fa60-916c-ad6795d6a90c', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 1009.0, 'fee': None}, {'info': {'timestamp': '2019-06-11T00:00:04.370Z', 'symbol': 'XBTUSD', 'side': 'Sell', 'size': 377, 'price': 8016, 'tickDirection': 'ZeroMinusTick', 'trdMatchID': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'grossValue': 4703075, 'homeNotional': 0.04703075, 'foreignNotional': 377}, 'timestamp': 1560211204370, 'datetime': '2019-06-11T00:00:04.370Z', 'symbol': 'BTC/USD', 'id': '61eacd7b-3fff-391e-0f3e-37bbcbc49bca', 'order': None, 'type': None, 'takerOrMaker': None, 'side': 'sell', 'price': 8016.0, 'cost': None, 'amount': 377.0, 'fee': None},`

Dentro de los diccionarios se repite un key lo que quiero es sumar todos los values de de los keys uso el for element in trades para seleccionar el value dentro del key amount pero como este se repite dentro de los diccionarios no hallo la forma de sumar los values

Origen Enlace
Loading