Skip to content

Latest commit

 

History

History
3593 lines (2003 loc) · 52.7 KB

DOCS.md

File metadata and controls

3593 lines (2003 loc) · 52.7 KB

Back to README.md

DOCUMENTATION TABLE OF CONTENTS

This is the documentation for the project Stock_Analyzer.

INSTRUCTIONS.md

0. HOW TO USE THIS TEMPLATE

1. HOW TO INSTALL ANACONDA

2. HOW TO CREATE CONDA ENVIRONMENT

3. HOW TO CONNECT INTERPRETER TO JETBRAINS GATEWAY

4. HOW TO INSTALL REQUIREMENTS

5. HOW TO INSTALL SERVICE

6. HOW TO INSTALL SELENIUM AND CHROME

A. HOW TO REMOVE CONDA ENVIRONMENT

B. HOW TO UNINSTALL SERVICE

Documentation Notebooks

API

Documentation For main.py

def main():


def set_storage_path(database_path: str, make_dir=False):

Note

    This function is used to set the path to the database. The database is a

Param

    database_path: str
        Path to the database
    make_dir: bool
        If True, create the directory if it does not exist

Return

    None

Example

    from toolbox import ticker_price_analysis
    ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)

def diff(df: pd.DataFrame):

Note

    This function is used to get the difference between the price of each datetime

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of prices

Return

    diff_df: pd.DataFrame
        Dataframe with datetime index and columns of differences in prices

Example

    from toolbox import ticker_price_analysis
    import pandas as pd
    df = pd.DataFrame({'price': [1, 2, 3, 4, 5]}, index=pd.date_range('2020-01-01', periods=5, freq='1min'))
    velocity_df = ticker_price_analysis.diff(df)
    print(velocity_df)

def get_pct_change(df: pd.DataFrame):

Note

    This function is used to get the percent change between the price of each datetime

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of prices

Return

    pct_change_df: pd.DataFrame
        Dataframe with datetime index and columns of percent change in prices

Example

    from toolbox import ticker_price_analysis
    import pandas as pd
    df = pd.DataFrame({'price': [1, 2, 3, 4, 5]}, index=pd.date_range('2020-01-01', periods=5, freq='1min'))
    pct_change_trend = ticker_price_analysis.get_pct_change(df)
    print(pct_change_trend)

def get_velocity(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the velocity of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol

    start_date: datetime.datetime
        Start date of the data

    end_date: datetime.datetime
        End date of the data

    cooldown: bool
        If True, wait 1 second between each request to the API

    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    velocity_df: pd.DataFrame
        Dataframe with datetime index and columns of velocity

Example

    from toolbox import ticker_price_analysis
    velocity_df = ticker_price_analysis.get_velocity('AAPL')
    print(velocity_df)

def get_acceleration(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the acceleration of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol

    start_date: datetime.datetime
        Start date of the data

    end_date: datetime.datetime
        End date of the data

    cooldown: bool
        If True, wait 1 second between each request to the API

    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    acceleration_df: pd.DataFrame
        Dataframe with datetime index and columns of acceleration

Example

    from toolbox import ticker_price_analysis
    acceleration_df = ticker_price_analysis.get_acceleration('AAPL')
    print(acceleration_df)

def get_jerk(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the jerk of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol

    start_date: datetime.datetime
        Start date of the data

    end_date: datetime.datetime
        End date of the data

    cooldown: bool
        If True, wait 1 second between each request to the API

    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    jerk_df: pd.DataFrame
        Dataframe with datetime index and columns of jerk

Example

    from toolbox import ticker_price_analysis
    jerk_df = ticker_price_analysis.get_jerk('AAPL')
    print(jerk_df)

def get_pct_change_velocity(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the percent change velocity of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol

    start_date: datetime.datetime
        Start date of the data

    end_date: datetime.datetime
        End date of the data

    cooldown: bool
        If True, wait 1 second between each request to the API

    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    pct_change_velocity_df: pd.DataFrame
        Dataframe with datetime index and columns of percent change velocity

Example

    from toolbox import ticker_price_analysis
    pct_change_velocity_df = ticker_price_analysis.get_pct_change_velocity('AAPL')
    print(pct_change_velocity_df)

def get_pct_change_acceleration(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the percent change acceleration of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol
    start_date: datetime.datetime
        Start date of the data
    end_date: datetime.datetime
        End date of the data
    cooldown: bool
        If True, wait 1 second between each request to the API
    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    pct_change_acceleration_df: pd.DataFrame
        Dataframe with datetime index and columns of percent change acceleration

Example

    from toolbox import ticker_price_analysis
    pct_change_acceleration_df = ticker_price_analysis.get_pct_change_acceleration('AAPL')
    print(pct_change_acceleration_df)

def get_pct_change_jerk(ticker: str, start_date=None, end_date=None, cooldown=True, database_only=False, interval="1d"):

Note

    This function is used to get the percent change jerk of the ticker

Param

ters
    ----------
    ticker: str
        Ticker symbol
    start_date: datetime.datetime
        Start date of the data
    end_date: datetime.datetime
        End date of the data
    cooldown: bool
        If True, wait 1 second between each request to the API
    database_only: bool
        If True, only use the database, do not make any requests to the API

Return

    pct_change_jerk_df: pd.DataFrame
        Dataframe with datetime index and columns of percent change jerk

Example

    from toolbox import ticker_price_analysis
    pct_change_jerk_df = ticker_price_analysis.get_pct_change_jerk('AAPL')
    print(pct_change_jerk_df)

def interpolate(trend, resample='D', create_dates_column=False):

Note

    This function is used to interpolate the dataframe. It will interpolate the dataframe based upon the resample.
    This function is an alias for toolbox.ticker_prices.interpolate

Param

ters
    ----------
    trend: pd.DataFrame
        Dataframe to interpolate
    resample: str
        Resample the dataframe to this frequency
        'H' = Hourly
        'D' = Daily

Return

    trend: pd.DataFrame
        Interpolated dataframe

Example

    from toolbox import ticker_prices
    df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
    df = ticker_prices.interpolate(df)
    print(df)

def average(df: pd.DataFrame):

Note

    This function is used to get the average of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change

Return

    average_df: pd.DataFrame
        Dataframe with datetime index and columns of average

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    average_df = ticker_price_analysis.average(df)
    print(average_df)

def standard_deviation(df: pd.DataFrame, sample=True):

Note

    This function is used to get the standard deviation of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change
    sample: bool
        If True, use sample standard deviation, else use population standard deviation

Return

    standard_deviation_df: pd.DataFrame
        Dataframe with datetime index and columns of standard deviation

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    standard_deviation_df = ticker_price_analysis.standard_deviation(df)
    print(standard_deviation_df)

def max(df: pd.DataFrame):

Note

    This function is used to get the max of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change

Return

    max_df: pd.DataFrame
        Dataframe with datetime index and columns of max

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    max_df = ticker_price_analysis.max(df)
    print(max_df)

def min(df: pd.DataFrame):

Note

    This function is used to get the min of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change

Return

    min_df: pd.DataFrame
        Dataframe with datetime index and columns of min

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    min_df = ticker_price_analysis.min(df)
    print(min_df)

def skew(df: pd.DataFrame):

Note

    This function is used to get the skew of the dataframe.
    For each skew variable:
    skew = 0: normally distributed
    skew < 0: more weight in the right tail of the distribution
    skew > 0: more weight in the left tail of the distribution

    For instance, a skew of -0.35 means that there is more weight in the right tail of the distribution.

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change

Return

    skew_df: pd.DataFrame
        Dataframe with datetime index and columns of skew.

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    skew_df = ticker_price_analysis.skew(df)
    print(skew_df)

def rolling_mean(df: pd.DataFrame, window:int = 12):

Note

    This function is used to get the rolling mean of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change
    window: int
        The number of periods to use for calculating the statistic

Return

    rolling_mean_df: pd.DataFrame
        Dataframe with datetime index and columns of rolling mean

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    rolling_mean_df = ticker_price_analysis.rolling_mean(df)
    print(rolling_mean_df)

def rolling_std(df: pd.DataFrame, window:int = 12):

Note

    This function is used to get the rolling standard deviation of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change
    window: int
        The number of periods to use for calculating the statistic

Return

    rolling_std_df: pd.DataFrame
        Dataframe with datetime index and columns of rolling standard deviation

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    rolling_std_df = ticker_price_analysis.rolling_std(df)
    print(rolling_std_df)

def df_log(df: pd.DataFrame):

Note

    This function is used to get the log of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change

Return

    df_log: pd.DataFrame
        Dataframe with datetime index and columns of log

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    df_log = ticker_price_analysis.df_log(df)
    print(df_log)

def get_stationary_trend(df: pd.DataFrame, window: int = 12):

Note

    This function is used to get the stationary trend of the dataframe

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe with datetime index and columns of percent change
    window: int
        The number of periods to use for calculating the statistic

Return

    stationary_trend_df: pd.DataFrame
        Dataframe with datetime index and columns of stationary trend

Example

    from toolbox import ticker_price_analysis
    df = ticker_prices.get_ticker_historical_trend('AAPL')
    stationary_trend_df = ticker_price_analysis.get_stationary_trend(df)
    print(stationary_trend_df)


def test_headless(website: str, screenshot_path, screen_width: int = 1920, screen_height: int = 1080):

Note

    The screenshot will be saved as a .png file
    This function is built just to test the headless option of selenium.

Param

ters
    ----------
    website: str
        The website to take a screenshot of
    screenshot_path: str
        The path to save the screenshot to
    screen_width: int
        The width of the screen to take the screenshot of
    screen_height: int
        The height of the screen to take the screenshot of

Return

    None

Example

    from toolbox import web_scraping_utility
    import os
    current_dir = os.getcwd()

    screenshot_path = os.path.join(current_dir, 'test')
    web_scraping_utility.test_headless('https://www.youtube.com', screenshot_path)


Documentation For toolbox/ticker_retreival.py

def set_storage_path(database_path: str, make_dir=False):

Note

    This function is used to set the path to the database. The database is a

Param

    database_path: str
        Path to the database
    make_dir: bool
        If True, create the directory if it does not exist

Return

    None

Example

    from toolbox import ticker_retreival
    ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')

def get_tickers(days_reset_frequency=7, request_fresh=False):

Note

    This function is used to get the list of tickers. The tickers are saved in the database. If the tickers are older

Param

    days_reset_frequency: int
        Number of days before the tickers are reset, to avoid making too many API calls

    request_fresh: bool
        If True, then the tickers are requested fresh from the API, regardless of the last update time

Return

    tickers: list
        List of tickers

Example

    from toolbox import ticker_retreival
    ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
    tickers = ticker_retreival.get_tickers()

Reference

    https://levelup.gitconnected.com/how-to-get-all-stock-symbols-a73925c16a1b

def get_rejected_tickers(days_reset_frequency=7, request_fresh=False):

Note

    This function is used to get the list of rejected tickers.
    W = When Issued, or can be arrested for fraud
    R = Rights Issue
    P =First Preferred Issue”. Preferred stocks are a separate entity.
    Q = Bankruptcy

Param

    days_reset_frequency: int
        Number of days before the tickers are reset, to avoid making too many API calls

    request_fresh: bool
        If True, then the tickers are requested fresh from the API, regardless of the last update time

Return

    rejected_tickers: list
        List of rejected tickers

Example

    from toolbox import ticker_retreival
    ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
    rejected_tickers = ticker_retreival.get_rejected_tickers()

Reference

    https://levelup.gitconnected.com/how-to-get-all-stock-symbols-a73925c16a1b

def get_ticker_information(symbol: str, days_reset_frequency=14, request_fresh=False, cooldown_counter=0):

Note

    This function is used to get the information for a given ticker. The information is saved in the database. If the

Param

    symbol: str
        Ticker symbol

    days_reset_frequency: int
        Number of days before the tickers are reset, to avoid making too many API calls

    request_fresh: bool
        If True, then the tickers are requested fresh from the API, regardless of the last update time

Return

    stock_info: dict
        Dictionary of stock information

Example

    from toolbox import ticker_retreival
    ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
    stock_info = ticker_retreival.get_ticker_information('MSFT')
    name = stock_info['shortName']
    website = stock_info['website']
    description = stock_info['longBusinessSummary']

def get_all_ticker_information(days_reset_frequency=1, request_fresh=False):

Note

    This function is used to get the information for all tickers. The information is saved in the database. If the

Param

    days_reset_frequency: int
        Number of days before the tickers are reset, to avoid making too many API calls

    request_fresh: bool
        If True, then the tickers are requested fresh from the API, regardless of the last update time

Return

    all_info: dict
        Dictionary of stock information for all tickers

Example

    from toolbox import ticker_retreival
    ticker_retreival.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')
    all_info = ticker_retreival.get_all_ticker_information()
    print(all_info['MSFT']['shortName'])


Documentation For toolbox/ticker_prices.py

def set_storage_path(database_path: str, make_dir=False):

Note

    This function is used to set the path to the database. The database is a

Param

    database_path: str
        Path to the database
    make_dir: bool
        If True, create the directory if it does not exist

Return

    None

Example

    from toolbox import ticker_prices
    ticker_prices.set_storage_path('C:/Users/username/PycharmProjects/stock_analysis/database')

def clean_up_dataframe(df: pd.DataFrame):

Note

    This function is used to clean up the dataframe. It will remove duplicate rows based upon the "Date" column.
    This is automatically called by the get_ticker_historical_trend function.

Param

ters
    ----------
    df: pd.DataFrame
        Dataframe to clean up

Return

    df: pd.DataFrame
        Cleaned up dataframe

Example

    from toolbox import ticker_prices
    df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
    df = ticker_prices.clean_up_dataframe(df)
    print(df)

def interpolate(trend, resample='D', create_dates_column=False):

Note

    This function is used to interpolate the dataframe. It will interpolate the dataframe based upon the resample

Param

ters
    ----------
    trend: pd.DataFrame
        Dataframe to interpolate
    resample: str
        Resample the dataframe to this frequency
        'H' = Hourly
        'D' = Daily

Return

    trend: pd.DataFrame
        Interpolated dataframe

Example

    from toolbox import ticker_prices
    df = ticker_prices.get_ticker_historical_trend('AAPL', start_date=datetime.datetime(2020, 1, 1), end_date=datetime.datetime(2020, 1, 2))
    df = ticker_prices.interpolate(df)
    print(df)

def get_trend_request(ticker, start, end, cooldown_counter=0, interval="1h", cooldown=True):

def get_trend(ticker, start_date, end_date, cooldown=True):

def get_ticker_historical_trend(ticker: str, start_date: datetime.datetime = None, end_date: datetime.datetime = None, cooldown = True, database_only=False, interval: str = "1d") -> pd.DataFrame:

Note

    This function is used to get the historical trend of a ticker. The historical trend is stored in the database. If the
    historical trend is not in the database, it will be downloaded from Yahoo Finance and stored in the database.

Param

    ticker: str
        Ticker symbol
    start_date: datetime.datetime
        Start date
    end_date: datetime.datetime
        End date
    cooldown: bool
        If True, wait 3 seconds between requests
    database_only: bool
        If True, only get the historical trend from the database.
        Setting it to True will not download the historical trend from Yahoo Finance,
        but it is faster to retrieve the historical trend from the database.
    interval: str
        Interval of the historical trend. If None, it will be set to "1d" if the time delta is greater than 2 years,
        otherwise it will be set to "1h"

Return

    pd.DataFrame
        Historical trend of the ticker

Example

    from toolbox import ticker_prices
    import datetime
    date = '09/10/2019'
    datetime_object = datetime.datetime.strptime(date, '%m/%d/%Y')
    today = datetime.datetime.today()
    print(ticker_prices.get_ticker_historical_trend('MSFT', datetime_object, today))


Documentation For toolbox/ticker_plotter.py

def set_storage_path(database_path: str, make_dir=False):

Note

    This function is used to set the path to the database. The database is a

Param

    database_path: str
        Path to the database
    make_dir: bool
        If True, create the directory if it does not exist

Return

    None

Example

    from toolbox import ticker_price_analysis
    ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)

def get_figure(trend: pd.DataFrame, columns: list, title: str, yaxis_name: str = "Price ($)", key_name: str = "Type"):

Note

    This function is used to plot the trend of the data. The trend is a dataframe where the index is the date and the
    columns are the different types of data. The columns are the different types of data.

Param

ters
    ----------
    trend: pd.DataFrame
        Dataframe containing the trend

    columns: list
        List of columns to plot

    title: str
        Title of the plot

    yaxis_name: str
        Name of the y-axis

    key_name: str
        Name of the key

Return

    fig: plotly.graph_objects.Figure
        Plotly figure

Example

    from toolbox import ticker_price_analysis
    from toolbox import ticker_prices
    ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)
    ticker_prices.set_storage_path('~/Desktop/database')

    trend = ticker_prices.get_ticker_historical_trend('AAPL')
    fig = ticker_price_analysis.get_figure(trend, ['Close', 'Open'], 'AAPL')
    fig.show()
    fig.write_image(f"AAPL_trend.png")

def get_candlestick_figure(trend: pd.DataFrame, title: str, yaxis_name: str = "Price ($)"):

Note

    This function is used to plot the trend of the data. The trend is a dataframe where the index is the date and the
    columns are the different types of data. The columns are the different types of data.

Param

ters
    ----------
    trend: pd.DataFrame
        Dataframe containing the trend

    title: str
        Title of the plot

    yaxis_name: str
        Name of the y-axis

Return

    fig: plotly.graph_objects.Figure
        Plotly figure

Example

    from toolbox import ticker_price_analysis
    from toolbox import ticker_prices
    ticker_price_analysis.set_storage_path('~/Desktop/database', make_dir=True)
    ticker_prices.set_storage_path('~/Desktop/database')

    trend = ticker_prices.get_ticker_historical_trend('AAPL')
    fig = ticker_price_analysis.get_candlestick_figure(trend, 'AAPL')
    fig.show()
    fig.write_image(f"AAPL_candlestick.png")


Documentation For toolbox/queue_local.py

class Queue:

Note

    A queue is a data structure that follows the First In First Out (FIFO) principle.
    This means that the first item added to the queue will be the first item removed from the queue.
    A queue can be implemented using a list or a linked list.

Param

    queue_list: list
        The list to initialize the queue with
    max_size: int
        The maximum size of the queue

Example

    queue = Queue([1, 2, 3, 4, 5], 10)

    a = queue.dequeue()
    print(a)

Reference

    https://en.wikipedia.org/wiki/Queue_(abstract_data_type)

def init(self, queue_list: list = None, max_size: int = None):

Note

        If the queue_list is not None, then the queue will be initialized with the list
        If the max_size is not None, then the queue will be initialized with the max_size

Param

        queue_list: list
            The list to initialize the queue with
        max_size: int
            The maximum size of the queue

Return

        None

Example

        queue = Queue([1, 2, 3, 4, 5], 10)

        a = queue.dequeue()
        print(a)

def enqueue(self, item):

Note

        Adds the item to the end of the queue

Param

        item: any
            The item to add to the queue

Return

        None

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)
        print(queue)

def dequeue(self):

Note

        Removes the first item from the queue

Param

        None

Return

        item: any
            The item that was removed from the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        a = queue.dequeue()
        print(a)

def size(self) -> int:

Note

        Returns the size of the queue

Param

        None

Return

        size: int
            The size of the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        print(queue.size())

def is_empty(self) -> bool:

Note

        Returns True if the queue is empty, False otherwise

Param

        None

Return

        is_empty: bool
            True if the queue is empty, False otherwise

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)

        print(queue.is_empty())

def peek(self):

Note

        Returns the first item in the queue without removing it

Param

        None

Return

        item: any
            The first item in the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        a = queue.peek()
        print(a)

def get_list(self):

Note

        Returns the list of items in the queue

Param

        None

Return

        list: list
            The list of items in the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        a = queue.get_list()
        print(a)

def len(self):

Note

        Returns the size of the queue

Param

        None

Return

        size: int
            The size of the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)

        print(len(queue))

def copy(self):

Note

        Returns a copy of the queue

Param

        None

Return

        new_queue: Queue
            A copy of the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        new_queue = queue.copy()
        print(new_queue)

def copy(self):

Note

        Returns a copy of the queue

Param

        None

Return

        new_queue: Queue
            A copy of the queue

Example

        queue = Queue(max_size=10)

        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        new_queue = queue.copy()
        print(new_queue)

def eq(self, other):

Note

        Returns True if the queues are equal, False otherwise

Param

        other: Queue
            The other queue to compare to

Return

        is_equal: bool
            True if the queues are equal, False otherwise

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)
        other = Queue([1, 2, 3, 4, 5], max_size=10)

        print(queue == other)

def ne(self, other):

Note

        Returns True if the queues are not equal, False otherwise

Param

        other: Queue
            The other queue to compare to

Return

        is_not_equal: bool
            True if the queues are not equal, False otherwise

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)
        other = Queue([1, 2, 3, 4, 5], max_size=10)

        print(queue != other)

def getitem(self, index):

Note

        Returns the item at the given index

Param

        index: int
            The index of the item to get

Return

        item: any
            The item at the given index

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        print(queue[2])

def setitem(self, index, value):

Note

        Sets the item at the given index to the given value

Param

        index: int
            The index of the item to set
        value: any
            The value to set the item to

Return

        None

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        queue[2] = 10
        print(queue)

def delitem(self, index):

Note

        Deletes the item at the given index

Param

        index: int
            The index of the item to delete

Return

        None

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        del queue[2]
        print(queue)

def iter(self):

Note

        Returns an iterator for the queue

Param

        None

Return

        iter: iter
            An iterator for the queue

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        for item in queue:
            print(item)

def reversed(self):

Note

        Returns an iterator for the queue in reverse order

Param

        None

Return

        reversed: iter
            An iterator for the queue in reverse order

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        for item in reversed(queue):
            print(item)

def contains(self, item):

Note

        Returns True if the item is in the queue, False otherwise

Param

        item: any
            The item to check for

Return

        is_in: bool
            True if the item is in the queue, False otherwise

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        print(1 in queue)

def add(self, other):

Note

        Returns a new queue with the items from both queues

Param

        other: Queue
            The other queue to add to this queue

Return

        new_queue: Queue
            A new queue with the items from both queues

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)
        other = Queue([6, 7, 8, 9, 10], max_size=10)

        new_queue = queue + other
        print(new_queue)

def iadd(self, other):

Note

        Returns this queue with the items from both queues

Param

        other: Queue
            The other queue to add to this queue

Return

        self: Queue
            This queue with the items from both queues

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)
        other = Queue([6, 7, 8, 9, 10], max_size=10)

        queue += other
        print(queue)

def mul(self, other):

Note

        Returns a new queue with the items from this queue repeated the given number of times

Param

        other: int
            The number of times to repeat the queue

Return

        new_queue: Queue
            A new queue with the items from this queue repeated the given number of times

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        new_queue = queue * 3
        print(new_queue)

def imul(self, other):

Note

        Returns this queue with the items from this queue repeated the given number of times

Param

        other: int
            The number of times to repeat the queue

Return

        self: Queue
            This queue with the items from this queue repeated the given number of times

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        queue *= 3
        print(queue)

def str(self):

Note

        Returns a string representation of the queue

Param

        None

Return

        string: str
            A string representation of the queue

Example

        queue = Queue([1, 2, 3, 4, 5], max_size=10)

        print(queue)


Documentation For toolbox/database.py

def set_storage_path(path):

Note

    This function is used to set the path to the folder where the database files will be stored

Param

ters
    ----------
    path : str
        The path to the folder where the database files will be stored

Return

    None
        This function does not return anything

Example

    set_storage_path('C:/Users/JohnDoe/Documents/MyDatabase')

Reference

    No Links

def slugify(value, allow_unicode=False):

Note

    This function is used to slugify strings, which basically means to remove all special characters and replace them with dashes.
    This is useful for creating file names from strings.

Param

ters
    ----------
    value : str
        The string to be slugified
    allow_unicode : bool
        Whether or not to allow unicode characters

Return

    str
        The slugified string

Example

    a = slugify('Hello World')

Reference

    https://github.com/django/django/blob/master/django/utils/text.py

def get(name: str):

Note

    This function is used to load objects from the database folder

Param

ters
    ----------
    name : str
        The name of the file to be loaded

Return

    object or None
        The object loaded from the file, could be anything

Example

    spreadsheet_data = get('spreadsheet_people')

Reference

    No Links

def get_modified_date(name: str):

Note

    This function is used to get the last modified date of a file in the database folder

Param

ters
    ----------
    name : str
        The name of the file to be loaded

Return

    datetime.datetime or None
        The datetime object of the last modified date

Example

    date = get_modified_date('spreadsheet_people')

Reference

    No Links

def save(name: str, data: any) -> None:

Note

    This function is used to save objects to the database folder

Param

ters
    ----------
    name : str
        The name of the file to be saved
    data : any
        The data to be saved

Return

    None
        This function does not return anything

Example

    spreadsheet_data = {"People": ["Bill", "Kent", "Steve"], "Ages": [20, 30, 40]}

    save('spreadsheet_people', spreadsheet_data)

Reference

    No Links

def delete_database(name: str) -> object:

Note

    This function is used to delete objects from the database folder

Param

ters
    ----------
    name : str
        The name of the file to be deleted

Return

    object or None
        The object loaded from the file, could be anything

Example

    spreadsheet_data = {"People": ["Bill", "Kent", "Steve"], "Ages": [20, 30, 40]}

    save('spreadsheet_people', spreadsheet_data)

    delete_database('spreadsheet_people')

Reference

    No Links

def save_key(platform: str, key: str, override: bool = False) -> None:

Note

    This function is used to save keys in a secure location

Param

ters
    ----------
    platform: str
        The name of the platform to be saved (e.g. 'google')
    key: str
        The key to be saved (e.g. '<google_api_key>')
    override: bool
        Whether or not to override the key if it already exists

Return

    None
        This function does not return anything

Example

    save_key('google', '<google_api_key>')

Reference

    https://www.nylas.com/blog/making-use-of-environment-variables-in-python/

def load_key(platform: str) -> str:

Note

        This function is used to load keys from a secure location

Param

ters
        ----------
        platform: str
            The key to be loaded (e.g. '<google_api_key>')

Return

        str or None
            This function returns the key if it exists, otherwise it returns None

Example

        key = load_key('google')

Reference

        https://www.nylas.com/blog/making-use-of-environment-variables-in-python/