My coworker gave me a program for me to create for her husband (I guess his work? I don't know). The program should evaluate stocks between days/months, and create an evaluation report (csv file) based on the evaluations per day, and also a result of buys/shorts in each individual stock name.
It sounds a little confusing, but overall it hasn't really been TOO hard to program. The issue I have more of is the wording, and I'm not sure if my evaluation is being done properly.
Wording of Problem
So, using that description I have created the following code (A lot is excluded, the important part is below)
So, although this coding block is a tad long, here's what it essentially does:
For every day between the smallestDay and biggestDay (Defined earlier, can change depending on input, but is set to not surpass the input file's bounds), it does the following:
If it's not the first day, it sets the Vectors for the previous Day's Buys and Shorts.
Then it resets the Vectors for the current day's Buys and Shorts (So that there is no accidental overlap).
Then, as long as it is not the last day, it does the current Day's trading and records them in the current day's Buys and Shorts, as well as adding them into Vectors for the total buys/shorts of a single stock.
Then, as long as it is not the first day, it does a comparison of the previous day's returns.
Here's the issue I'm having: Due to the wording (or my misunderstanding of the wording), I'm not sure if I should be evaluating the returns of the current day compared to the previous day's for the same stock, or just doing calculations on the previous day's return. I think the latter sounds a little silly (why wouldn't I just do it on the same day?), but really I'm unsure and I don't really want to write a whole lot if it will end up useless.
So really, at this point, I'm mostly looking for an outside thought at the moment as to what I need to do for the last part of this. The recording of total buys/shorts works, and the returns work as is, but I feel like they are wrong because of this misunderstanding of the wording.
If anyone has any insight, I would love to hear it. I still have some other stuff for this project (I have to implement a monthly returns scenario too), but it shouldn't be too hard once I figure this out.
Also, my code may not be the most efficient at the moment, but right now I'm more concerned with getting this working before my coworker needs it. If I have time left later I can tidy it up, but I'm still unsure of when she wants it by so I'm trying to get it working first.
Edit: So I ended up changing the lower section of the code to the following:
Basically it compares each of the previous day's sold/purchased stock to the current day's value. It subtracts current - previous, because I want the difference. I then average both bought and shorted stocks, and do the same buy + short as before.
In case anyone was wondering, if I do buy - short (As it is described in the documentation), Everything ends up positive change, so I know it's wrong (Sometimes as high as 14 or 15 percent).
I'm still not sure if this is right, but I cannot keep sitting around thinking about it so I did it anyway, and commented out the old stuff just in case I need to go back.