Showing posts with label pycha. Show all posts
Showing posts with label pycha. Show all posts

Monday, 2 July 2012

Changes, Changes and... Changes!

The code relatives to chart is finally ok..
Now the program is capable to:
  • plot a chart with the data ordered by date
  • put the correct label on the chart ticks
  • put an explicative label on the axis
  • calculate a good y-range for displaying the chart (see this option of pycha)
  • for every click on one of the symbol on the stocks list, it display the last month of data on the chart.
  • I added a reload button... if you want you can trash all your dowloaded data and download it again.
About pycha: this is the complete list of options and if you want to specify ticks labels, you need to give pycha something like this:


[

{'v': 0, 'label': 'day1'},
{'v': 1, 'label': 'day2'},
{'v': 2, 'label': 'day3'}

]


It is a list of dictionary.
so record 0 will have day 1 on the first tick.. and so on...


Tomorrow I will spend my after-work time, trying to put it on the ppa and making it ready for the ubuntuappshowdown!

Last screenshot here:



After that, I will spend my resting time for:
  • finish about page.
  • unity integration.
  • make it possible to change data displayed on chart
  • caching data (I want to reduce queries to yahoo whenever is possible).

I need also some graphics.. for icons at least.

Friday, 22 June 2012

Data downloading... complete!

Ok here it is again.
Today, I'm happier than yesterday.. just because the things went as expected and I can go to sleep earlier...

This is how it looks the new experiment:

That chart display google stock quote (on a predefined period) integrated with pycha library and gtk3!

What I learnt
If you want to:
  • draw on a GTK3 drawing area, you need to register to "draw" event.The "expose" event doesn't exist anymore.
  • update a drawing area widget, you must call queue_draw on that widget
  • get the dimension and position of a widget, you can call the methoed "get_allocation()" on that widget. This methoed give back a Rectangle object with this properties: x,y,width,height.
  • plot with pycha, you have to create a context from the drawing area widget and from the context a surface, than pass the surface to pycha. More info on this point soon.
Yahoo Finance and Stock Quote Data
The stock quote data is obtained from Yahoo Finance, thanks to a web services present on their portal.
Thanks to Corey Goldberg with his library ystockquote obtain these data is a pretty easy task.
I have only to understand how much deep I can go with this script and if it is enough for what I'm looking for...
I also don't know where I can find the right keyword for stock quote companies: Google is GOOG , Apple is AAPL but I don't know where to find a list of these keywords.. or better a webservices to query.

After this research.. I need to pass to design & a bit of mockups!
 




Thursday, 21 June 2012

Lack of documentation

Yesterday I spent a lot of time trying to plot a Chart in a Gtk Drawing Area, using quickly, Glade3, pygtk and pycha.

Some criticism about these tools:
  • "hackish" style... you fix some problem thanks god to people like this: http://somethingididnotknow.wordpress.com/2012/01/27/retrieve-the-window-object-from-widgets-with-pygobject-gtk3.
  • general lack of documentation. what you find around the web is usually deprecated and it doesn't work when you try it
  • the gtk documentation is mainly in C, not in python, and sometimes have a C function called pippo() doesn't mean it exists the equivalent python function pippo()..but something like pyPippo()....
  • when you need a library for a simple task, like plotting on a screen, you can find a lot of solutions, but find the one that just works , it is hard. Many library examples just doesn't work.. you have to find the solution. Read this http://detrasproject.wordpress.com/2011/04/04/show-graphs-using-pygtk/ Also if you don't want plot chart, read the post to understand what I mean. It's not coding.. it's hacking.
  • Trying to plot a line chart inside a drawing area...it has been a bad experience.. and the result not satisfying for now... it looks good but there are a lot of bug to fix.
a prototype.

Quickly, pygtk, glade etc are great tool.. but Ubuntu need documentation, keeping it updated with examples and easy to find tutorial on "how to solve a simple task" or a page with the most important and working library for solve a task.
The hackish approach is not for all, we are in 2012.

This is not an attack to ubuntu community or in general to opensource.
Instead it is an important point, where community should think and improve.

I will post later the recipe for plot a pycha inside a GTK window made with Glade.