def __init__(self): (self.connection, self.cursor) = config.get_db_cnx() self.connection.autocommit = True self.last_ts = self.load_last_timestamp() self.url = "https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-historical-data" self.params = { "frequency": "1d", "filter": "history", # "period1":f"{self.last_ts}", "period1": 1483228800, # 20170101 "period2": f"{int(time.time())}" # add symbol } self.headers = headers = { 'x-rapidapi-host': "apidojo-yahoo-finance-v1.p.rapidapi.com", 'x-rapidapi-key': "f1fc109cfbmsha883dd0c943ac04p16e921jsn03bc4efbc66d" } self.agg = 10
def __init__(self): (self.connection, self.cursor) = config.get_db_cnx() self.connection.autocommit = True self.last_timestamp = self.load_last_timestamp() self.coin_id = self.load_coin_id()
def __init__(self, timestamp=None): (self.connection, self.cursor) = config.get_db_cnx() if timestamp is None: self.timestamp = 1567987946 else: self.timestamp = timestamp
def __init__(self, timestamp=None): (self.connection, self.cursor) = config.get_db_cnx() if timestamp is None: self.timestamp = signal_utils.load_latest_timestamp() - timedelta(days=4) else: self.timestamp = timestamp
def __init__(self, signals): (self.connection, self.cursor) = config.get_db_cnx() self.signals = signals self.researcher = Researcher()
def __init__(self, timestamp=None): (self.connection, self.cursor) = config.get_db_cnx() self.connection.autocommit = True self.coin_dict = self.load_coin_dict() self.timestamp = timestamp
def __init__(self): (self.connection, self.cursor) = config.get_db_cnx()
import requests import sys sys.path.append("C:/Users/matth/Desktop/crypto") import json import config url = 'https://pkgstore.datahub.io/core/s-and-p-500-companies/constituents_json/data/64dd3e9582b936b0352fdd826ecd3c95/constituents_json.json' response = requests.request("GET", url) stocks = json.loads(response.text) (cxn, cursor) = config.get_db_cnx() for stock in stocks: query = 'INSERT INTO stocks (symbol, name, sector) values (%s, %s, %s)' values = (stock['Symbol'], stock['Name'], stock['Sector']) cursor.execute(query, values) cxn.commit()
import requests import sys sys.path.append("C:/Users/matth/Desktop/crypto") import config (connection, cursor) = config.get_db_cnx() coin_list = requests.get("https://min-api.cryptocompare.com/data/all/coinlist").json() query = "insert ignore into coins (name, symbol) values " for _id, info in coin_list["Data"].items(): query += "(\"{}\",\"{}\"),".format(info["CoinName"], info["Symbol"]) cursor.execute(query[:-1]) connection.commit()
def __init__(self, timestamp=None): (self.connection, self.cursor) = config.get_db_cnx() self.connection.autocommit = True self.stocks = signal_utils.get_stocks() self.timestamp = timestamp
def __init__(self): (self.connection, self.cursor) = config.get_db_cnx() self.connection.autocommit = True self.last_timestamp = self.load_last_timestamp() self.skip_new = eval(sys.argv[1])