Hi there,
The python learning curve seems to be steeper than expected :-(
As yesterday, help converting my php app into python/django will be 
appreciated.

I have the following:

--------------------  snip  -------------------
from django.core.management.base import BaseCommand, CommandError
import json
from collections import OrderedDict
from yahoo_finance import Share 
from data.models import MyichiTickers, MyichiHistoricalData

exchange  = 'AMS'
startdate = '2014-04-25'
enddate   = '2014-04-29'
minimum_avg_daily_volume = '100000'

class Command(BaseCommand):
def handle(self, *args, **options):
from yahoo_finance import Share 
from data.models import MyichiTickers
tickers_for_exchange = MyichiTickers.objects.filter(exchange=exchange)[:2]
if tickers_for_exchange:
for tickerlist in tickers_for_exchange:
ticker = Share(tickerlist.ticker) 
if ticker.get_avg_daily_volume() > minimum_avg_daily_volume:
data = json.dumps(ticker.get_historical(startdate, enddate))
data = json.loads(data)
print data

--------------------  snip  -------------------

It may not be perfect, but it works.
I would need to get 'data' into the 'MyichiHistoricalData' model

The output is like this;
--------------------  snip  -------------------
[{u'High': u'6.565', u'Symbol': u'AGN.AS', u'Adj_Close': u'6.31564', 
u'Volume': u'4376000', u'Low': u'6.428', u'Date': u'2014-04-29', u'Close': 
u'6.551', u'Open': u'6.435'}, {u'High': u'6.479', u'Symbol': u'AGN.AS', 
u'Adj_Close': u'6.18742', u'Volume': u'3163200', u'Low': u'6.38', u'Date': 
u'2014-04-28', u'Close': u'6.418', u'Open': u'6.428'}, {u'High': u'6.535', 
u'Symbol': u'AGN.AS', u'Adj_Close': u'6.18259', u'Volume': u'4780100', 
u'Low': u'6.379', u'Date': u'2014-04-25', u'Close': u'6.413', u'Open': 
u'6.529'}]
[{u'High': u'13.94', u'Symbol': u'AH.AS', u'Adj_Close': u'13.57496', 
u'Volume': u'2706600', u'Low': u'13.70', u'Date': u'2014-04-29', u'Close': 
u'13.92', u'Open': u'13.70'}, {u'High': u'13.735', u'Symbol': u'AH.AS', 
u'Adj_Close': u'13.34091', u'Volume': u'2784700', u'Low': u'13.56', 
u'Date': u'2014-04-28', u'Close': u'13.68', u'Open': u'13.565'}, {u'High': 
u'13.675', u'Symbol': u'AH.AS', u'Adj_Close': u'13.23364', u'Volume': 
u'3012500', u'Low': u'13.44', u'Date': u'2014-04-25', u'Close': u'13.57', 
u'Open': u'13.545'}]
--------------------  snip  -------------------

Where I need help it so extract the keys and values and give them the 
correct model field names in order to save them.

It should be easy really, bt several hours of readin, searching, trial & 
error haven't given me the trick yet....

Any suggestions?

Thanks!

Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6e16498-8b13-4b4c-b8ec-489a44b1d274%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to