Quantopian Flashcards

1
Q

You can print lines you want with the word print

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In python, what is pandas?

A

A library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If I gave numpy the alias “np”, and I imported some data and named it “sample”, how would I calculate the mean and standard deviation of the data using numpy?

A

np.mean(sample), np.std(sample)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Quantopian’s IPython interface, what is one of the functions that can be used to pull some real price data?

A

get_pricing()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is one of the functions that can be used to calculate returns?

A

pct_change()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If I wanted to calculate the 100 day moving average using daily data, I can use pandas built-in tools to do so. The data is loaded in and named “price_data”. Assuming I load in pandas with the alias “pd”, then what would be the correct way to write the function to calculate the 100 day moving average using pandas?

A

pd.rolling_mean(price_data, window=100)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If “”” This text is enclosed between the triple quotes “”” then it is referred to as

A

a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

13.198 is what type of variable in Python?

A

Float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens to the number 13.198 when I run the following code,

int(13.198)

A

Truncate any digits after the decimal point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What will running the following code in Python create?

[1, ‘This’, 3, ‘that’]

A

List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can the colon symbol be used to slice in Python?

A

List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

If I wanted to grab the last item from a list in Python, which line of code would I need to run? Assume the name of the list is defined as X.

A

X[-1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

You can change any part of a tuple because it is immutable.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If I have two different variables, X and Y, and I wanted to know if they are the same, I would run the following code

print (X == Y)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the two main components that make up a dictionary in Python?

A

Key and Value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Numpy arrays can be created with multiple dimensions

A

True

17
Q

Assume an array is defined as “tmp”. Which line of code would we need to run to get the dimensions of the array?

A

tmp.shape

18
Q

A slice of an array will select a group of elements starting from the first element specified up to, and including, the last element indicated.

A

False

19
Q

If I wanted to select the first row of a 2-d array, I would execute which of the following code? Assume the array is defined as “tmp”.

A

tmp[0,:]

20
Q

Assume you have a set of returns and weights such that the weights are between 0 and 1, and sum to 1. Which line of code would return the expected return of your portfolio? Assume you load the numpy library in as np, define average returns as “mean_returns”, and weights as “weights”.

A

np.dot(weights, mean_returns)

21
Q

Assume you define weights as “weights”, average returns as “mean_returns”, the covariance of returns as “cov”, and you load the numpy library in as np. How would I use this information to calculate the volatility of my portfolio?

A

np.dot(np.dot(weights, cov), weights.T)

22
Q

A pandas Series is a 1-dimensional array with labels that can contain any data type.

A

True

23
Q

Every Series has a name.

A

True

24
Q

If you have a sample of daily data and the index is in DatetimeIndex format, which line of code would allow me to convert the daily data to monthly data? Assume the daily data is defined as “x”.

A

x.resample(‘M’)

25
Q

Assume I have return data that has some missing values (‘NaN’). Which line of code will replace the missing values with the average returns? Assume you define the returns data as “x”.

A

x.fillna(x.mean())

26
Q

The .dropna() function will automatically replace NaN values with the average

A

False

27
Q

If you wanted to print the summary statistics for your returns data, defined as “x”, how would you do so?

A

x.describe()

28
Q

If you are given a set of price data, defined as “x”, how would you calculate the multiplicative returns using pandas built-in methods simultaneously dropping the first set of missing values?

A

x.pct_change()[1:]

29
Q

Assume you have a set of monthly pricing data defined as “x” and you load in the pandas library as pd. Which pandas built-in function allows you to calculate the 12 month rolling average price?

A

pd.rolling_mean(x, 12)

30
Q

If you have monthly pricing data defined as “x” and you load in the pandas library as pd. Which line of code would calculate the 12 month rolling volatility?

A

pd.rolling_std(x, 365)

31
Q

If you have a pandas DataFrame defined as “df” and you want the average of each column, which line of code would you run?

A

df.mean(axis=0)

32
Q

Assume you have a pandas DataFrame defined as “df”. If you wanted to access the names of the columns, you would run which line of code?

A

df.columns

33
Q

To get the standard deviation from a pandas DataFrame defined as “df”, I could run which of the following lines of code?

A

df.std()