/AutoTrading

In this HW, we will implement a very aged prediction problem from the financial field. Given a series of stock prices, including daily open, high, low, and close prices, decide your daily action and make your best profit for the future trading. Can you beat the simple “buy-and-hold” strategy? Please check the sample data. You will see each line contains four tuples: open-high-low-close. The sample data is NASDAQ:GOOG. The data, called training_data.csv, contains more-than-five-year daily prices, whose line number corresponds to the time sequence. Another data, called testing_data.csv, contains one-year daily prices, which corresponds to the time period next to the final date in training_data.csv. In this project, we ignore the transaction cost, meaning that you can do an action every day if you want without extra expense (at most one action can be executed within one day, as the open price)

Primary LanguagePython

AutoTrading

In this HW, we will implement a very aged prediction problem from the financial field. Given a series of stock prices, including daily open, high, low, and close prices, decide your daily action and make your best profit for the future trading. Can you beat the simple “buy-and-hold” strategy? Please check the sample data. You will see each line contains four tuples: open-high-low-close. The sample data is NASDAQ:GOOG. The data, called training_data.csv, contains more-than-five-year daily prices, whose line number corresponds to the time sequence. Another data, called testing_data.csv, contains one-year daily prices, which corresponds to the time period next to the final date in training_data.csv. In this project, we ignore the transaction cost, meaning that you can do an action every day if you want without extra expense (at most one action can be executed within one day, as the open price)

Method

Probability table

Use the the difference of two day open price to decide which action class it belongs to.If the differece of price is > 1,it belongs to class -1;if the differece of price is <-1 ,it belongs to class 1;other belong to class 0. With the training dataset, calculating the probability of which action would to be executed behind each of class. e.g,behind class -1, the probability of executing action 1 is 0.5 , 0 is 0.2 and -1 is 0.3. Generate 10 random number related to the probability table. The mean of the random numbers are that which action will be executed.

Moving Average

Use the close prices of 5 and 10 consecutive days to calculate mean values, which are called MA5 and MA10 respectively.If the close price > MA5 > MA10, it means price will rise.If the close price < MA5 < MA10, it means price will fall.Use the two law to decide which action should be taken.