Python代写:CS413MarketInformation


这次需要代写的作业分为两个部分,第一部分是关于读写一份Market Information的程序,第二部分是关于Order book的程序。

Requirement

Goal of this project: reading/writing csv files, plotting a chart, creating
some calculations (daily return, monthly return) from the data, using data
structure

  • Unzip the file markedata.zip
  • You will find 19 csv files with information about stocks (for the Part I)
  • You will find 3 csv files with information about exchange (BARX, EDGX, NYSE) (for the Part 2)

Part I: Reading a CSV file containing Market Information

Load the content of these files into the following data structure:
market_data[‘Symbol’] = {‘Open’:[], ‘High’:[], ‘Low’:[], ‘Close’:[], ‘Volume’:[], ‘Adjusted’:[], ‘Date’:[]}
—|—
Since you have to handle many symbols, market_data should be a dictionary of
dictionary.
Every values of this dictionary of dictionary will be a list of number or
float or date.

Task 1

Create this dictionary

Task 2

Create a new key in this dictionary being a list of values representing the
moving average for 10 days.
It means that market_data will be:
market_data[‘Symbol’] = {‘Open’:[], ‘High’:[], ‘Low’:[], ‘Close’:[], ‘Volume’:[], ‘Adjusted’:[], ‘Date’:[], ‘MA_10’:[]}
—|—
Since it is a moving average, there are some parts without values; you will
just use None as a value. All the different lists should have the same length.

Task 3

You will create another key in this dictionary containing the daily return for
every day (the first day shouldn’t have any return)
You will calculate the return using the adjusted price (the adjusted price
taking into account split and dividends)

Task 4

You will create:

  • A function ‘maximum_return’, which will return the best return across all the symbols. The return should contain the return and the date associated
  • A function ‘minimum_return’, which will return the best return across all the symbols. The return should contain the return and the date associated
  • A function ‘best_return_for_one_month’, which will return the best return across all the symbols for a 1-month period. The return should contain the return and the month/year

Task 5

Plot a chart for MSFT, NVDA, GOOGL representing the daily market price.
You will use the library the library matplot.
import matplotlib
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel(‘some numbers’)
plt.show()
—|—

Creating an order book

You are creating an order book builder for your trading system. The book
builder will have as an input a list of files with the same format. Each
exchange will have a given file. During this exercise, you will take 3 venues
(3 files) as input: ARCA, EDGX, NYSE.
You will need to read the three files at the same time (to make it
deterministic, you will always read ARCA first then EDGX second).
An order book is defined as the following on wiki:
A book builder is a component of a trading system sorting the orders from
different exchanges by price and by side. It is a critical component: Primary
source of market information for trading models.
In this assignment, you will read the files and get the orders coming from the
different exchanges.
You will create a class capable to handle the market data coming one by one
and build a book for each side. In this part I, you will just need to handle
one symbol for 3 different exchanges. But in the following part, you will have
a book for different symbols, therefore it is important to have your book
handling many symbols.

Task 1

You will create the class book_builder having for functions: process_tick
(tick), this function will update the book ‘bid’ ‘offer’ with the input tick
top_of_book(), this function will return the top of the book for bid and offer

Task 2

You will create the functions:

  • getBestBid returning the best bid (price, volume, venue)
  • getBestOffer returning the best bid (price, volume, venue)

Task 3

You will create the function:

  • getBidVolumeBetween(price1, price2) returning the total volume between price1 and price2 for bids.
  • getOfferVolumeBetween(price1, price2) returning the total volume between price1 and price2 for offers

文章作者: SafePoker
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 SafePoker !
  目录