Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

607
Views
¿Cómo obtener el precio de una criptomoneda en un momento dado en el pasado?

¿Hay alguna forma en que pueda usar ccxt para extraer el precio de una criptomoneda en un momento dado en el pasado?

Ejemplo: obtenga el precio de BTC en binance en el momento 2018-01-24 11:20:01

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede usar el método fetch_ohlcv en la clase binance en CCXT

def fetch_ohlcv(self, symbol, timeframe='1m', since=None, limit=None, params={}):


Necesitará la fecha como una marca de tiempo en milisegundos, y solo puede obtenerla con precisión al minuto, así que quite los segundos o obtendrá el precio por el minuto siguiente.

 timestamp = int(datetime.datetime.strptime("2018-01-24 11:20:00", "%Y-%m-%d %H:%M:%S").timestamp() * 1000)

Solo puede obtener el precio de BTC en comparación con otra moneda, usaremos USDT (coincide estrechamente con USD) como nuestra moneda de comparación, por lo que buscaremos el precio de BTC en el mercado BTC/USDT

Cuando usemos el método, estableceremos desde su marca de tiempo, pero estableceremos el límite como uno para que solo obtengamos un precio.

 import ccxt from pprint import pprint print('CCXT Version:', ccxt.__version__) exchange = ccxt.binance() timestamp = int(datetime.datetime.strptime("2018-01-24 11:20:00+00:00", "%Y-%m-%d %H:%M:%S%z").timestamp() * 1000) response = exchange.fetch_ohlcv('BTC/USDT', '1m', timestamp, 1) pprint(response)

Que devolverá valores de velas para una vela

 [ 1516792860000, // timestamp 11110, // value at beginning of minute, so the value at exactly "2018-01-24 11:20:01" 11110.29, // highest value between "2018-01-24 11:20:01" and "2018-01-24 11:20:02" 11050.91, // lowest value between "2018-01-24 11:20:01" and "2018-01-24 11:20:02" 11052.27, // value just before "2018-01-24 11:20:02" 39.882601 // The volume traded during this minute ]
over 4 years ago · Santiago Trujillo Report

0

Puede hacerlo con el método fetchOHLCV unificado de CCXT:

  • https://docs.ccxt.com/en/latest/manual.html#ohlcv-candlestick-charts
  • https://docs.ccxt.com/en/latest/manual.html#ohlcv-estructura

Recomendamos encarecidamente leer todo el Manual CCXT de arriba a abajo, realmente le ahorrará tiempo:

  • https://docs.ccxt.com/
  • https://github.com/ccxt/ccxt/wiki
  • https://github.com/ccxt/ccxt/wiki/Manual

Además, echa un vistazo a los ejemplos aquí:

  • https://github.com/ccxt/ccxt/tree/master/ejemplos
  • https://github.com/ccxt/ccxt/tree/master/examples#ver-también
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!