Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

FINANCIAL DATA ANALYTICS

(a) Assume you have a table named StaffSalaries with the following contents:

Display in table form the results of the following two SQL instructions (you might use the characters |, !, - or _to help display the table in the text response)

(i) [5 marks] SELECT Gender FROM LatestIncrease WHERE Bonus > Salary;

(ii) [5 marks]

SELECT Surname, Bonus

FROM StaffSalaries

WHERE Gender='Male' AND LatestIncrease>0.10;

(iii) [5 marks ] If the following instruction

INSERT INTO StaffSalaries

(Surname, FirstName)

VALUES('Anders', 'Sanders');

*does not cause an error*, what can you deduce about how the table was created?

(b) Say we have a table named AlbumCatalogue with fields: AlbumID, ArtistID, CurrentPrice, ReleaseYear, and MediaFormat, and a table named Artists with fields: ArtistID, YearFirstWork, and Country.

None of these fields is allowed to be missing in the database and the primary key for each of these tables is the first field.

(i) [5 marks] Write the CREATE TABLE SQL instruction that creates the two tables. You are free to choose details such as data type but make sure you make meaningful choices. Make sure that you codify the relationship between the two tables so as to ensure referential integrity.

(ii) [5 marks] Write a SQL instruction that displays all the information (AlbumID, ArtistID, CurrentPrice, ReleaseYear, and MediaFormat) for all albums with artists domiciled in USA (Country='USA').

(note that percentage quantities are equivalent to decimal numbers in the usual fashion, i.e. 10% represents the number 0.10)



(a) [5 marks] Explain the result of the calculation mean(diff(v)) where v is an R vector. Given a simple example using the digits in your student ID as the vector v.

(b) [5 marks] What does log-return mean? Explain step-by-step why the R instruction

diff(log(EURUSD$Close)) calculates the sequence of log-returns.

(c) [5 marks] Find five incorrect lines in the following R code and provide fixes:

(assume all necessary libraries have been loaded)

(d) In calculating the volatility of an asset it is a typical mistake to use the actual asset values instead of the returns. Assume that we have retrieved Apple share price data with:

AAPL <- get.hist.quote("AAPL")

(i) [5 marks] Write R code that calculates and displays the volatility of Apple close share prices.

(ii) [5 marks] Write code that calculates it incorrectly assuming you make the mistake described above. Use an annualisation factor of 252.


(a) [5 marks] What does the instruction

import pandas as pd

achieve? How will your programme be different if instead you use

import pandas

(b) [5 marks] Spot and fix two errors in the following code: