ramesth / truetrade

Automatically exported from code.google.com/p/truetrade
0 stars 0 forks source link

delete old mysql data on new download #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
when the same information is dowloaded for an instrument, it appears twice
in the mysql database

to reproduce

1. make and select an instrument
2. download data from yahoo
3. download the same data again

result: you see the same dataline twice.

A simple solution would be to prompt for an overwrite of all data for an
instrument if a user downloads and some data is present. 

Alternatively, we could disentangle the name of an instrument from the
stock symbol. This way a user could name instruments

"MSFT-1990-1995" and "MSFT-2000-2005", and perform downloads on the same
instrument for different time spans.

Any thoughts? Don't hold back if this stuff just shows i don't understand
the design.

Original issue reported on code.google.com by damiaan....@econ.kuleuven.be on 30 May 2007 at 7:54

GoogleCodeExporter commented 8 years ago
What would the use case be for separating out two different data series for the 
same
instrument?  I'm more comfortable adding the ability to save series to a flat 
file
and delete a series from the DB, that way users can manage what is in the DB 
however
they wish without adding in hacks to the data model.

The duplicate data issue can be solved in a few ways.  If we want to be simple, 
we
could add a unique() constraint to the BAR table as:
        unique(bar_series_id, timespan_id, begin_time)

To modify an existing DB, the syntax is:

     alter table bar add unique(bar_series_id, timespan_id, begin_time);

The downside is that it generates an SQL Exception for each duplicate row which 
is
slooooow to process.  I made these changes, but wouldn't mind having a better
solution.  Does anyone have any suggestions for how to check for duplication in 
a
more efficient fashion?

Original comment by tyrotra...@gmail.com on 30 May 2007 at 10:26