SSOC18 / ssoc18-wiki

Shadi's Summer of Code 2018
0 stars 1 forks source link

[FatimaFawaz] reconciliation tool (7h) #7

Closed shadiakiki1986 closed 6 years ago

shadiakiki1986 commented 6 years ago

@FatimaFawaz let's use this issue as a placeholder for your next task in financial engineering: building a reconciliation tool



Steps
- [x] familiarize yourself with [pandas](http://pandas.pydata.org/) via their [Lessons for new pandas users](https://pandas.pydata.org/pandas-docs/stable/tutorials.html#lessons-for-new-pandas-users) (~1h)
- [x] reconcile two CSV files with [pandas](http://pandas.pydata.org/) (~1h)
    - use the ssoc18.teamshadi.net server to write up a jupyter notebook that reads the files into a dataframe for each using [read_csv](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html)
    - I uploaded 2 sample files to your home directory on the server
    - use the [pandas.DataFrame.merge](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html) function to merge the two dataframes into one dataframe
    - calculate the a new field `diff = position of bank 1 - position of bank 2`
- [x] familiarize yourself with [flask](http://flask.pocoo.org/) (web app microframework) by following the [tutorial](http://flask.pocoo.org/docs/0.12/tutorial/)
- [x] create a flask app that allows a user to upload two files, and that reconciles them (as you did in the notebook above) and displays the reconciled dataframe with the `diff` field (~2h)
- [x] confirm that "symbol" and "position" are in the columns of the uploaded files (~1h)
- [x] list on the home page all the *file pairs* that were already uploaded so that clicking on them will directly go to their reconciliation (without having to re-upload) (~2h)
FatimaFawaz commented 6 years ago

So far I familiarised myself with Pandas, only went as far as need for the reconciliation. I wrote up a Jupiter notebook that read the two files each into a separate dataframe, then I merged the two into another dataframe. I added a column for the diff field where the calculations were made. I started working on Flask but thus far I only managed to reach step 4 of the tutorial. I think I need to go over Python packaging methods in order to make sure I packaged things correctly so that the application can actually get installed. Although, I did get an IP address, the app did not seem to be found. I am not sure if this is how it's supposed to be until I create actual webpages. I used the pipenv installer to for the setup.py and it did create a Pipfile.

shadiakiki1986 commented 6 years ago

Ok. Let's have a call tomorrow and fix you're stuck at

On Wed, Jul 4, 2018, 17:08 Fatima-Fawaz notifications@github.com wrote:

So far I familiarised myself with Pandas, only went as far as need for the reconciliation. I wrote up a Jupiter notebook that read the two files each into a separate dataframe, then I merged the two into another dataframe. I added a column for the diff field where the calculations were made. I started working on Flask but thus far I only managed to reach step 4 of the tutorial. I think I need to go over Python packaging methods in order to make sure I packaged things correctly so that the application can actually get installed. Although, I did get an IP address, the app did not seem to be found. I am not sure if this is how it's supposed to be until I create actual webpages. I used the pipenv installer to for the setup.py and it did create a Pipfile.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/teamshadi/ssoc18/issues/7#issuecomment-402490070, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAOhFRUHecX2qTN6XixB4tFE1eEKQ0Lks5uDMxtgaJpZM4VBATR .

FatimaFawaz commented 6 years ago

Created the reconciliation tool but it will not run beyond showing the webpage and refreshing after uploading the two csv files.

shadiakiki1986 commented 6 years ago

@FatimaFawaz

Please check them out and integrate "flaskr_shadi.py" changes into your own "flaskr.py".

I added 2 new steps for you (above in this issue description). Please check them out

FatimaFawaz commented 6 years ago

What I attempted but isn't working:

shadiakiki1986 commented 6 years ago

@FatimaFawaz I just tried the app. After clicking upload, I got

builtins.PermissionError
PermissionError: [Errno 13] Permission denied: '/home/fatme/Recon/flaskr/flaskr/Upload Folder/f1.csv'

Is this a known issue ATM in your app?

FatimaFawaz commented 6 years ago

No it isn't. I get this on my side. screen shot 2018-07-13 at 2 27 38 pm

shadiakiki1986 commented 6 years ago

Maybe it's related to the filename chosen? I'm using f1.csv and f2.csv. Can you try with that and let me know if it still works for you?

On Fri, Jul 13, 2018 at 2:28 PM Fatima-Fawaz notifications@github.com wrote:

No it isn't. I get this on my side. [image: screen shot 2018-07-13 at 2 27 38 pm] https://user-images.githubusercontent.com/40644150/42689449-035e390a-86a9-11e8-9d69-9ad162247290.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/teamshadi/ssoc18/issues/7#issuecomment-404806508, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAOhMcFNqsbTNGz5hmuLpGJsVZWgivgks5uGIR6gaJpZM4VBATR .

-- Best, Shadi AKIKI www.akikieng.com/shadi

FatimaFawaz commented 6 years ago

It doesn't work with me either. Which is odd considering it took in other file names aside from the ones I tested with. edit: got the same error

shadiakiki1986 commented 6 years ago

No problem. I just tried it with different names, and it's working. Here are my review points

FatimaFawaz commented 6 years ago

Server stopped accepting cookies (too many redirects error). Cleared the cookies on browser and shut down previous terminal runs but nothing changed. The above changes were confirmed to work prior to this.

shadiakiki1986 commented 6 years ago

I just checked your flaskr.py file and found that it was missing the following

def Recon():
    if request.method == 'GET':
        return render_template("DF.html")

Without this, your application was going into an infinite loop. I saved this in flaskr_shadi_2.py and ran it and saw it working.

Now there is another bug: NameError: name 'FileFrame' is not defined.

@MickMek is an engineer who is working with me on another project, but he's familiar with flask too. I'll ask him to get in touch with you today, maybe you guys can have an online meeting on meet.google.com where you can show him your working app and ask him your questions above

shadiakiki1986 commented 6 years ago

So following our phone call now, I added a listfiles route that demonstrates

Let's talk again tomorrow

FatimaFawaz commented 6 years ago

Added a new route that takes in the prefix, the program then does a reconciliation The program works now. However, after going to the URL with the prefix, does not permit upload.

shadiakiki1986 commented 6 years ago

Congratulations! You just got your first working version :smile: I just opened a new github repository for you to commit your current code. Please check your email for details