Make timestamp to always be INT
This commit is contained in:
		@@ -173,9 +173,12 @@ def fetch_bitstamp():
 | 
			
		||||
        bitstamp_data = response.json()
 | 
			
		||||
        ohlc_data = bitstamp_data["data"]["ohlc"]
 | 
			
		||||
 | 
			
		||||
        # the bitstamp api gives timestamp with decimals to show less than second accuracy.
 | 
			
		||||
        bitstamp_timestamp = int(math.floor(float(ohlc_data[0]["timestamp"])))
 | 
			
		||||
 | 
			
		||||
        candle_stick_data = {
 | 
			
		||||
            "exchange": "bitstamp",
 | 
			
		||||
            "timestamp": int(ohlc_data[0]["timestamp"]),
 | 
			
		||||
            "timestamp": bitstamp_timestamp,
 | 
			
		||||
            "open": float(ohlc_data[0]["open"]),
 | 
			
		||||
            "high": float(ohlc_data[0]["high"]),
 | 
			
		||||
            "low": float(ohlc_data[0]["low"]),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										42
									
								
								btc_tracker/kraken_fetch_client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								btc_tracker/kraken_fetch_client.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
#!/usr/bin/python3
 | 
			
		||||
"""
 | 
			
		||||
client for kraken_fetch.py
 | 
			
		||||
"""
 | 
			
		||||
import requests
 | 
			
		||||
import ecdsa
 | 
			
		||||
import sqlite3
 | 
			
		||||
 | 
			
		||||
config_file = "./kraken_fetch_client.conf"
 | 
			
		||||
# Just for testing and early development
 | 
			
		||||
private_key = '039e1c137aa296d7af0cd55b468018ad1020949c2731e5141d032b8371490f48'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def read_config():
 | 
			
		||||
    """
 | 
			
		||||
    read $config_file and returns users private key
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    return private_key
 | 
			
		||||
 | 
			
		||||
def get_server_public_key(url):
 | 
			
		||||
    """
 | 
			
		||||
    fetches the servers public key
 | 
			
		||||
    """
 | 
			
		||||
    rurl = url+'/serverkey'
 | 
			
		||||
    response = requests.get(rurl)
 | 
			
		||||
    if response.status_code == 200: # if  the fetch was success...
 | 
			
		||||
        server_public_key = response.content
 | 
			
		||||
        return server_public_key
 | 
			
		||||
    # when the fetch was not successfull
 | 
			
		||||
    print(f"Error fetching data from the server.")
 | 
			
		||||
    return 'Error'
 | 
			
		||||
 | 
			
		||||
def fetch_data_from_the_server(url):
 | 
			
		||||
    """
 | 
			
		||||
    query the kraken_fetch server for new data
 | 
			
		||||
    """
 | 
			
		||||
    # we need to do some time calculations here...
 | 
			
		||||
 | 
			
		||||
    response = requests.get(url)
 | 
			
		||||
 | 
			
		||||
    return response
 | 
			
		||||
		Reference in New Issue
	
	Block a user