Skip to content

Real time data using http request on python #8

Description

@dani-s-92

Hello,

I am trying to get a real time ticker for BTC/USD in python. I get historical data (cadles) like this:
hist_klines_url = f"https://api.phemex.com//exchange/public/md/kline?symbol={symbol}&to={to_time}&from={from_time}&resolution={resol}" with:
Symbol:
symbol = "BTCUSD"
import time
From Time:
from_time = datetime(2022, 2, 28, 0, 0)
from_time = int(time.mktime(from_time.timetuple()))
print(pd.to_datetime(from_time, unit='s'))
To Time:
to_time = datetime.now()
print(to_time)
print(to_time.year)
print(to_time.month)
print(to_time.day)
print(to_time.hour)
print(to_time.minute)
print(to_time.second)
to_time = datetime(to_time.year, to_time.month, to_time.day, to_time.hour, to_time.minute, to_time.second, 0)
to_time = int(time.mktime(to_time.timetuple()))
print(pd.to_datetime(to_time, unit='s'))
Resolution:
if zeitraum == "5m":
resol = 300

and this works fine but never gives me the actual candle. I have a delay of like 5 to 9 minutes.
Can someone tell me how to get the actual candle using a http request? I cannot find anythin in the documentation.

Thank you!

Best regards,
Daniel

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions