예제 #1
0
def get_similar_companies(company: int,
                          attribute: str = "sector",
                          limit: Optional[int] = None) -> list:
    # attribute can either be "sector" or "industry"; the default is "sector"
    with driver.session() as session:
        return session.read_transaction(query_similar_companies, company,
                                        attribute, limit)
예제 #2
0
def remove_news_by_url(url: str):
    with driver.session() as session:
        session.write_transaction(delete_news_by_url, url)


# pull news from here: https://www.nasdaq.com/feed/rssoutbound?symbol={REPLACE_WITH_STOCK_SYMBOL} or https://feeds.finance.yahoo.com/rss/2.0/headline?s={REPLACE_WITH_STOCK_SYMBOL}&region=US&lang=en-US
# currently only pulling from nasdaq.com's rss feed
예제 #3
0
def insert_news(articles: list):
    with driver.session() as session:
        for article in articles:
            for company in article.mentioned_companies:
                session.write_transaction(create_news, article.url,
                                          article.title, company,
                                          article.timestamp)
예제 #4
0
def get_num_connections(company1: int,
                        company2: int,
                        date: Optional[dict] = None) -> int:
    # date is None by defult (no date limit when querying), but if specified it is assumed to be in the format
    # {"months": something, "days": something, "years": something} where each value in the
    # dict is a positive integer specifying how far back to look for relationships (subject to change)
    with driver.session() as session:
        return session.read_transaction(query_num_connections, company1,
                                        company2, date)
예제 #5
0
def get_connection_list(company: int,
                        limit: Optional[int] = None,
                        date: Optional[dict] = None) -> list:
    # date is None by defult (no date limit when querying), but if specified it is assumed to be in the format
    # {"months": something, "days": something, "years": something} where each value in the
    # dict is a positive integer specifying how far back to look for relationships (subject to change)
    with driver.session() as session:
        result = session.read_transaction(query_connection_list, company,
                                          limit, date)
        return [dict(zip(r.keys(), r.values())) for r in result]
예제 #6
0
def insert_listings(ticker_company_name_dict: dict):
    with driver.session() as session:
        for listing_id in ticker_company_name_dict.keys():
            session.write_transaction(
                create_listing, int(listing_id),
                ticker_company_name_dict[listing_id]["name"],
                ticker_company_name_dict[listing_id]["symbol"],
                ticker_company_name_dict[listing_id]["industry"],
                ticker_company_name_dict[listing_id]["sector"],
                ticker_company_name_dict[listing_id]["sector"],
                ticker_company_name_dict[listing_id]["market_cap"])
예제 #7
0
def remove_news_by_age(age: dict):
    # age is in the format {"months": something, "days": something, "years": something}, which specifies how far back to go from the current date
    # articles that are less than the specified age are untouched while those that are older than the specified age are deleted
    with driver.session() as session:
        session.write_transaction(delete_news_by_age, age)
예제 #8
0
def remove_listing(company: int):
    with driver.session() as session:
        session.write_transaction(delete_listing, company)
예제 #9
0
def update_listing_attribute(company: int, attribute: str, value):
    with driver.session() as session:
        session.write_transaction(update_listing, company, attribute, value)
예제 #10
0
def get_company_sector_industry(company: int) -> list:
    with driver.session() as session:
        return session.read_transaction(query_company_sector_industry, company)
예제 #11
0
def get_industry_sector_total_market_cap(attribute: str = "sector",
                                         limit: Optional[int] = None) -> list:
    # attribute can either be "sector" or "industry"; the default is "sector"
    with driver.session() as session:
        return session.read_transaction(query_industry_sector_total_market_cap,
                                        attribute, limit)