import json
import datetime as dt
import pandas as pd
import numpy as np
import imp
backend = imp.load_compiled(‘flagwatch_back_end’, ‘__pycache__/flagwatch_back_end.cpython-38.pyc’)
# DO NOT MODIFY
# Create a global FlagWatch API object. This object supports three methods:
# 1. fw.describe_endpoints()
# 2. fw.describe_sample_data()
# 3. fw.request(URL)
fw = backend.FlagWatch(STUDENT_ID)
########################################################################
# Part 1
########################################################################
def endpoint(requested_date, requested_code):
“”” Get the FlagWatch URL endpoint for this date and item
Parameters
———-
requested_date : datetime.datetime
The date for the desired FlagWatch data
requested_code: str
The three characters code for either the FlagWatch ticker or exchange as specified by
your API.
Returns
——-
str
The FlagWatch endpoint URL beginning with `www.flagwatch.org`.
Notes
—–
– You should assume that the requested_code is three characters. However,
it may be upper cased, lower cased, or have some mixture of case.
“””
pass
########################################################################
# Part 2
########################################################################
def get_single_data_item(requested_date, requested_ticker, requested_exchange, requested_price_type):
“”” Get the FlagWatch price data for this date, ticker, exchange, and pricing type
Parameters
———-
requested_date : datetime.datetime
The date for the desired FlagWatch data
requested_ticker: str
The three characters code for the FlagWatch ticker of interest.
requested_exchange: str
The three characters code for the FlagWatch exchange of interest.
requested_price_type: str
The type of pricing information required: “OPEN”, “CLOSE”, “HIGH”, or “LOW”
Returns
——-
float
The price information.
Notes
—–
– You should assume that the requested_ticker and requested_exchange are
each three characters long. However, these may be upper cased, lower
cased, or have some mixture of case. Similarly, requested_price_type
will be one of the four options, but may be of any case structure.
Hint
—-
You should use one of the methods of the instance `fw`. Remember that
the method fw.describe_sample_data() returns an EXAMPLE. You do not
want to use that method here.
“””
pass
########################################################################
# Part 3
########################################################################
def get_time_series(requested_ticker, requested_exchange, requested_price_type):
“”” Get the FlagWatch timeseries for 2020 January for the requested ticker,
exchange, and price type
Parameters
———-
requested_ticker: str
The three characters code for the FlagWatch ticker of interest.
requested_exchange: str
The three characters code for the FlagWatch exchange of interest.
requested_price_type: str
The type of pricing information required: “OPEN”, “CLOSE”, “HIGH”, or “LOW”
Returns
——-
pandas.Series
The desired time series with a sorted datetime index.
Notes
—–
– You should assume that the requested_ticker and requested_exchange are
each three characters long. However, these may be upper cased, lower cased,
or have some mixture of case. Similarly, requested_price_type will be one of
the four options, but may be of any case structure.
Hints
—–
– The series will contain prices for all calendar days in January 2020
(from day 1 to day 31).
– Remember that the function `get_single_data_item` returns the price
for a single day
– Remember that the date parameter in `get_single_data_item` is a
datetime instance
“””
pass
########################################################################
# Part 4
########################################################################
def get_dataframe(ticker_exchange_price_combinations):
“”” Get a FlagWatch Pandas.DataFrame for 2020 January using the requested
ticker-exchange-price combinations.
Parameters
———-
ticker_exchange_price_combinations : list
A list of tuples where each tuple is a (ticker, exchange, price)
combination. For example, (“bic”, “got”, “open”) is the tuple for
bicoulour, Mt. GoT, and open price. (“str”, “cis”, “high”) is the tuple
for stripes, coininsecure, and high price.
Returns
——-
pandas.DataFrame
The desired data DataFrame with a chronological datetime index.
The column labels should be formatted as
“:”
where:
stands for the ticker code (upper case)
stands for the exchange code (upper case)
stands for the type of quote (upper case)
Examples:
– A (“bic”, “got”, “open”) tuple results in a column named “BICGOT:OPEN”
– A (“str”, “cis”, “high”) tuple results in a column named “STRCIS:HIGH”
“””
pass

Found something interesting ?

• On-time delivery guarantee
• PhD-level professional writers
• Free Plagiarism Report

• 100% money-back guarantee
• Absolute Privacy & Confidentiality
• High Quality custom-written papers

Grab your Discount!

25% Coupon Code: SAVE25
get 25% !!