代写MTH5005: Programming in Python II Project 2代写Python编程

Project 2

MTH5005: Programming in Python II

1 Overview

For this project, you will extend the functionality of your PriceTracker class to track additional statistics, and also implement a new class MarketTracker that tracks several prices at once.

Due Date and Submission

The assignment is due on 25 April 2025 at 23:59. To submit the assignment, you must:

1.  Commit and push your final project code in your repository username-project-2 (where username is your username) to QMUL’s GitHub Server at https://github. qmul. ac. uk. The procedure for this is exactly the same as what we have been doing in lab sessions, and you should use the same repository we have been using in Labs 6, 7, 8, and 9.

2.  Go to the module’s QMPlus page and visit the submission portal for the assignment. You do not need to upload anything here, but you will need to confirm that your project has been pushed and you now want it marked.

Only code submissions via your git repository on github.qmul.ac.uk will be accepted.  It is not possible to upload your code via QMPlus and email submissions will NOT be accepted.

Late submissions will be handled according to the School’s Late Submission Policy:

For every period of 24 hours, or part thereof, that an assignment is overdue there shall be a deduction of five per cent of the total marks available (i.e. five marks for an assessment marked out of 100).  After seven calendar days (168 hours or more late) the mark shall be reduced to zero, and recorded as 0FL (zero, fail, late).

https://qmplus.qmul.ac.uk/mod/book/view.php?id=2699291&chapterid=236293

Warning

•  Your code should be properly formatted and commented. Poorly formatted code will receive deductions.

•  Your code should not have any syntax errors. If you program cannot be run due to a syntax error, you will receive 0 marks for the relevant part of the submission. Your code will be tested against Python 3.11 and you can check that it runs correctly by running one of the code testers on our GitHub site.

•  Correct code should still pass the relevant tests from labs 6, 7, 8, and 9 even after completing Task 1 and 2. You should ensure that the final version of your code passes the relevant lab tests. Here, “relevant tests” means all tests from each of labs 6, 8, and 9 and the tests for range_query in lab 7.

•  It is better to submit an incomplete or incorrect solution that correctly runs than a hastily finished solution that Python cannot load!

It is fine to collaborate during labs and discuss general solutions to problems, but you should write your own code and documentation.  Submissions that are liter- ally identical to one another or to a common third source may result in academic misconduct charges!

Files to submit

Your submission should include the following files and functionality, implemented over the last several labs:

TreeNode . py

This should contain your TreeNode class from Lab 6, which defines a type for nodes in your MinHeap class.

BST. py

This should contain a function range_query that can be used to query a range for any given instance of BST

Heap. py

This should contain the implementation of the MinHeap class from Lab 8, which is used by your price tracker.

PriceTracker. py

This should contain the PriceTracker class from Lab 8, together with the specified additions discussed in the next sections.

MarketTracker. py

This should contain a new class MarketTracker described in the fol- lowing sections.

Your code will likely depend on other files that you have been provided, including AVLTree . py and Node . py. You can include these (and any other Python files) in your repository, but these will not be marked. We will be testing your code using the versions of these files that you were provided, so you must ensure your code works without any modifications to files other than those in the above table!

Marks Breakdown

Your code will be tested using a similar framework to that you have been using to check your code in the labs, but we will be running additional checks for correctness. There are 100 marks available for this assignment, broken down as follows:

10 marks

All required functions, methods, and classes are present and correctly documented with docstrings.

10 marks

At least 5 commits made to your repository—one after completing each of Labs 6, 7, 8, and 9 and one after completing the instructions here. All should have informative messages to identify them.

50 marks

Correctness tests for the classes TreeNode, Heap, and PriceTracker developed in labs 6, 8, and 9 and the function range_query from Lab 7.

15 marks

Correctness tests for the additional statistics you will implement in PriceTracker as part of Task 1

15 marks

Correctness tests for the additional class MarketTracker you will im- plement as part of Task 2

2 Task 1: Tracking additional data

For the first additional task, you should modify your PriceTracker class so that it also main- tains a record of the 10-day maximum and 10-day average price of an asset. Two notes:

•  You should be able to do the first by maintaining a second heap in your class along with the existing min-heap.  You should not implement a new class for max-heaps.  Instead, you should find a way to use a min-heap as a max-heap.

Hint: Think about what you might do with numerical keys k to ensure that the element with largest value of k was at the top of a min-heap.

•  In order to maintain the average, it should be sufficient to keep track of only the current average over the most recent 10-day window, computed as the sum of all prices in the window divided by the number of prices in the window. You should not need a heap or anything fancy for this.  You should think of a way to update this average without com- pletely recalculating it from scratch each time a price arrives.

Hint: it may be useful to maintain an extra attribute in your PriceTracker class that keeps track of the number of prices in the current window.

Your AVLTree should now store tuples of the form.

1 ( price : float

2 ten_ day _min : float

3 ten_ day _max : float

4 ten_ day _avg : float )

Note that is important that the first 2 elements of each tuple remain the same as in Lab 9! This will allow us to test your code from Lab 9 regardless of whether you have completed this task or not.

3 Task 2: Tracking multiple prices

The PriceTracker class allows us to track data for a single asset.  For this task, you must im- plement the tracking of multiple assets in a market. Declare a new class MarketTracker in the file MarketTracker. py. Your class should maintain a price tracker for each separate asset, and should have the following methods:

•   add_price(self’ name:  str ’  time:  datetime’ price:  float) that takes a name for an asset, a time, and a price. For example:

1 add _price ( " NVDA " datetime (2025 ’   3 ’ 31 ’ 15 ’ 5) ’ 110 . 40)

represents a data point saying that Nvidia stock was worth 110.40 at 15:05:00 on 31 March 2025. Your method should update the price tracker for the asset with the given name. For example, the above call should add the specified time and price to the tracker “NVDA”.

•   get_price_data(self’ name:  str ’  start:  datetime’  end:  datetime) —this should function exactly as the method for your PriceTracker class, except that it takes an extra parameter name of type str representing the name of the asset whose data in the given range should be returned. For example, if mt is a MarketTracker instance, then calling:

1 mt . get _price_ data ( " NVDA "

2 datetime (2025 ’ 3 ’ 1) ’

3 datetime (2025 ’ 4 ’ 1) )

should return an ordered list of tuples containing all the data that was recorded for the as- set named “NVDA” between 1 March 2025 and 1 April 2025. Each tuple you return should have the form.

1 ( time :   datetime ’ ( price : float

2 ten_ day _min : float

3 ten_ day _max : float

4 ten_ day _avg : float ) )

That is, each should be a pair whose first element is a time and whose second element is a tuple containing all price data for this time. If an asset symbol is not found, your method should raise a KeyError.

In order to keep things relatively simple, when processing a new price with your add_price method, you should only update the data point for the specified asset. This means that not all assets will have the same number or frequency of data points. It maybe helpful to think of your class as maintaining a list of statistics related to the times at which an asset’s price was updated.


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图