Bitcoin Forum
September 27, 2024, 10:31:54 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Timestamp to time?  (Read 386 times)
cbreum (OP)
Member
**
Offline Offline

Activity: 118
Merit: 12

Passionate software developer and crypto guy.


View Profile WWW
April 17, 2016, 07:07:51 AM
 #1

If you look at a rest request on C-CEX for bitcoin prices

https://c-cex.com/t/btc-usd.json you get

{"ticker":{"high":438,"low":432.999999,"avg":435.4999995,"lastbuy":433.2,"lastsell":438,"buy":433.2001,"sell":435.0000002,"lastprice":433.2,"buysupport":2690.15560102,"updated":1461225600}}

-----------------------------------------------------------------------------------------------

If you do the same on Bitstamp

https://www.bitstamp.net/api/ticker/

You get:

{"high": "432.87", "last": "430.01", "timestamp": "1460823147", "bid": "430.02", "vwap": "429.08", "volume": "2780.11282927", "low": "426.61", "ask": "430.06", "open": 429.29}

-------------------------------------------------------------------------------------------

Now the "timestamp" and the "updated" json fields represent the time of the last trade.

On Bitstamp if you want to convert that timestamp to a human readable local time you do like this:
// Unix timestamp is seconds past epoch
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dt = dt.AddSeconds(Timestamp).ToLocalTime();

So basically it's the total seconds since January 1'th 1970.

On C-CEX as you can see the updated value is higher. If I use the same procedure as above I get April 21 10.00 AM.....Is there anybody who can explain how C-CEX returns their timestamp (updated)?

Co-founder Echangere: https://echangere.com/
boxhock
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile WWW
April 17, 2016, 11:50:47 AM
 #2

I don't know if anyone else has any better answer to this, but it honestly seems like c-cex have messed up the time configuration on their API.

Looking at their API documentation, it seems they use a new time format for every API call, which is not good at all.

As for a fix for this, if you know their API is offset by X days you could just subtract that from the timestamp c-cex returns. It's really not an optimal solution, but their API seems really bad.

USD and Bitcoin Advertising network
████ Adverti.io ████
Real-Time statistics ★ Dedicated Support ★ BTC payout
cbreum (OP)
Member
**
Offline Offline

Activity: 118
Merit: 12

Passionate software developer and crypto guy.


View Profile WWW
April 17, 2016, 11:58:54 AM
 #3

I don't know if anyone else has any better answer to this, but it honestly seems like c-cex have messed up the time configuration on their API.

Looking at their API documentation, it seems they use a new time format for every API call, which is not good at all.

As for a fix for this, if you know their API is offset by X days you could just subtract that from the timestamp c-cex returns. It's really not an optimal solution, but their API seems really bad.

Yeah...I have also thought of that, but honestly it's a temporary workaround not a real solution. But thanks for your input anyway. I wrote C-CEX support about the problem. The issue still persist even after new trades have been made. In short the timestamp is not updated.


Co-founder Echangere: https://echangere.com/
cbreum (OP)
Member
**
Offline Offline

Activity: 118
Merit: 12

Passionate software developer and crypto guy.


View Profile WWW
April 17, 2016, 12:18:54 PM
 #4

Just got an email from C-CEX support. It was a bug in their system. Now the timestamp is working like Bitstamp.


Co-founder Echangere: https://echangere.com/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!