This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:smalik2:portfolio:cprogproject4 [2012/04/29 01:20] – [Execution] smalik2 | user:smalik2:portfolio:cprogproject4 [2012/04/29 01:27] (current) – [Project: STOCK CHART CANDLES] smalik2 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | |||
+ | A project for C/C++ Programming by Saad Malik during Spring 2012. | ||
+ | |||
+ | This project was begun on April 27, 2012 and is anticipated to take the weekend to complete. Project was completed on April 28, 2012. | ||
+ | |||
+ | =====Objectives===== | ||
+ | The purpose of this project is to make a program that will use stock information to depict useful things about said information. | ||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * successful completion of projects up to this point | ||
+ | * familiarity with file I/O | ||
+ | * familiarity with arrays | ||
+ | |||
+ | =====Background===== | ||
+ | The purpose of this project is to take a file with stock information, | ||
+ | It will also visually output a Candlestick chart. | ||
+ | |||
+ | The candle stick works as such. | ||
+ | |||
+ | At the top, you have the high, where the wick meets the body is the close (if it's a white candle, if it's black it's the open), where the bottom of the body meets the bottom wick it is the open (again, switched if it's a black candle), and the bottom of the bottom wick is the low. | ||
+ | =====Scope===== | ||
+ | Time to theme our exploration of programming in a different context- the financial market. | ||
+ | |||
+ | While you may not be familiar with the stock market and the " | ||
+ | |||
+ | One such unit of measurement is the stock chart candle, which can be used on a number of time-specific stock charts (yearly, monthly, weekly, daily, hourly, minutely, etc.) | ||
+ | |||
+ | Regardless of the time period, the candle can be used to derive all sorts of information: | ||
+ | |||
+ | * direction of trade price | ||
+ | * magnitude of trade price | ||
+ | * high of day with respect to opening/ | ||
+ | * low of day with respect to opening/ | ||
+ | |||
+ | And many other more subtle points of analysis. | ||
+ | |||
+ | There are many great resources out on the internet covering the history and background of the candle, so please go and familiarize yourself with this before proceeding with actual program implementation. If you do not understand the why and how of a candle, you cannot successfully write a program to utilize them. You also are not eligible for receiving any help on program implementation for this project unless and until you can demonstrate familiarity with the concept of stock chart candles. Multiple violations of this will result in automatic deductions from your final project assessment; if you do not read this or do the necessary background research, it will not be spoon fed to you. | ||
+ | |||
+ | For this project, our task will be to implement a program the can read stock data from a text file, and textually render a single candle from that data. | ||
+ | |||
+ | I will be providing a few different data files, and your program must flexibly work with all of them (and any other file of similar format that may be introduced). | ||
+ | |||
+ | So, please implement a program that does the following: | ||
+ | |||
+ | * opens a specified data file for reading (command-line arguments might be particularly useful) | ||
+ | * reads the data to determine the open, close, high, and low | ||
+ | * displays the stock symbol of the data file in question | ||
+ | * displays the determined open, close, high, and low to STDOUT | ||
+ | * utilizes an array for processing of candle visualization | ||
+ | * textually visualizes the candle to STDOUT | ||
+ | |||
+ | I would also like each person to do their own post-visualization candle analysis. What type of candle is it? | ||
+ | |||
+ | Data file for use with the project can be found on Lab46 in: **/ | ||
+ | |||
+ | If you'd like an extra challenge, implement logic that " | ||
+ | =====Code===== | ||
+ | |||
+ | The C code: | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | |||
+ | int main(int argc, char **argv) | ||
+ | { | ||
+ | if (argc != 2) | ||
+ | { | ||
+ | printf(" | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | FILE *stockfile = fopen(*(argv+1), | ||
+ | |||
+ | if (stockfile == 0) | ||
+ | { | ||
+ | printf(" | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | float *values; | ||
+ | values = (float*)malloc(sizeof(float)*255); | ||
+ | char *stocksymbol; | ||
+ | stocksymbol = (char*)malloc(sizeof(char)*10); | ||
+ | int count = 0; | ||
+ | fscanf(stockfile, | ||
+ | | ||
+ | fscanf(stockfile, | ||
+ | while (*(values+count) !=-1.0) | ||
+ | { | ||
+ | ++count; | ||
+ | fscanf(stockfile, | ||
+ | } | ||
+ | count = count-1; | ||
+ | |||
+ | float open=*(values); | ||
+ | float close=*(values+count); | ||
+ | int count2; | ||
+ | float high = *(values); | ||
+ | for(count2=0; | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | high = *(values+count2); | ||
+ | } | ||
+ | } | ||
+ | float low = *(values); | ||
+ | for(count2=0; | ||
+ | { | ||
+ | if(low > *(values+count2)) | ||
+ | { | ||
+ | low = *(values+count2); | ||
+ | } | ||
+ | } | ||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | for(count2=0; | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | printf(" | ||
+ | |||
+ | for(count2=0; | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | printf(" | ||
+ | |||
+ | for(count2=0; | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | printf(" | ||
+ | |||
+ | fclose(stockfile); | ||
+ | return 0; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | =====Execution===== | ||
+ | <cli> | ||
+ | lab46: | ||
+ | Program needs a stock chart file as a command line argument to runlab46: | ||
+ | Could not open file, double check spelling and whatnotlab46: | ||
+ | |||
+ | StockSymbol: | ||
+ | OPEN: 39 CLOSE: 47 HIGH: 52 LOW: 26 | ||
+ | |||
+ | High (51.83): * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | ***** | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | * * | ||
+ | ***** | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | Low (25.98): * | ||
+ | |||
+ | lab46: | ||
+ | </ | ||
+ | =====Reflection===== | ||
+ | This project was a piece of cake. It only took me a few hours to get some of the file input stuff figured out, and after that it was smooth sailing. | ||
+ | |||
+ | It served as a good brushing up on handling information from files. | ||
+ | =====References===== | ||
+ | http:// | ||
+ | |||
+ | Matt Haas | ||