0

I am building an app that uses the Oanda API to retrieve historical forex data. There are 28 forex pairs and 10 years worth of historical data. Since none of this data changes I was planning on saving it into my database rather than blowing up the API.

My goal is to initially populate the database for all pairs and then update the data once per minute from then on.

What I can't figure out is how to do this effectively.

Where should the logic for this live inside the Django app? How can I execute the initial population of the data so that it will save?

It's the saving that is giving me the most problems. As far as I can tell Django only likes to save model instances from the shell.

Any help would be greatly appreciated.

2 Answers2

0

Generally you should do operations like this inside proper view.

If you want to save some data once per minute just create a method that will implement it and refresh it with for example Ajax from time to time (for example once per minute). You don't have to render page from beginning - everything can work in the background.

Remember that you will need psycopg2 module to interact with Postgres

m.antkowicz
  • 13,268
  • 18
  • 37
0

You might want to take a look at this answer and to the django-admin commands.

I hope this helps! =)

Community
  • 1
  • 1
jlnabais
  • 829
  • 1
  • 6
  • 18
  • 1
    I found django-admin commands on my own and it is exactly what I needed. Thanks for the help. –  Sep 10 '15 at 15:56