|
Reg database connection for interactive financial charts |
Posted by kannan on Dec-30-2010 04:01 |
|
Dear sir,
Am a financial analyst and I am not a geek in systems and programs.. I have
planned to buy chartdirector for my website where am going to give a free charting services
for indian stock market. I have the data in Ticker,Date,open,high,low,close,volume format..
How i can upload it in mysql and how can i connect to this chart... pls guide me through... |
Re: Reg database connection for interactive financial charts |
Posted by Peter Kwan on Dec-31-2010 02:00 |
|
Hi kannan,
To import your data to a database, you would need to first design your database structure (the tables, schemas, etc). Then you need to write code to read your data, and write to the data to the database. The exact code depends on the exact format of your data, and the database schema you are using.
To achieve the above, you do not have to be a "geek", but you would need to have skills in programming and database.
To create a chart using your data, you would need to write code to read your data (which can be from your database or from your original format). After your code have read the data, it can pass the data to ChartDirector and ask ChartDirector to create a chart with the data. There are plenty of sample code included in ChartDirector that demonstrates how to create the charts from data.
Hope this can help.
Regards
Peter Kwan |
Re: Reg database connection for interactive financial charts |
Posted by Pankaj Arya on Oct-01-2012 18:59 |
|
Hi Peter,
as you have mentioned. i have created database in sql , i am able to connect to database also. and wrote the following code
function generateRandomData($ticker, $startDate, $endDate, $resolution) {
global $timeStamps, $volData, $highData, $lowData, $openData, $closeData;
$dbhost = "localhost";
$dbuser = "EodData";
$dbpass = "mydbpassword";
$dbname = "EodDataDB";
if(!@mysql_connect($dbhost,$dbuser,$dbpass)) {
echo "<br><br><center>There seems to be some technical problem(s) at the moment, we are trying it fix it. Please visit later.<br>Team.</center>";
die();
} else {
//echo "Connection to the databse is successful<br>" ;
mysql_select_db($dbname);// or report();
// paste Your code below this //
$data = mysql_query("SELECT *
FROM `nse_cash_eod_data`
WHERE SYMBOL = '$ticker'
LIMIT $startDate , $endDate" )
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
$date = new DateTime($info['TIMESTAMP'];);
$unix = $date->getTimestamp();
$timeStamps[]=chartTime2($unix);
$openData[]=$info['OPEN'];
$highData[] =$info['HIGH'];
$lowData[] =$info['LOW'];
$closeData[]=$info['CLOSE'];
$volData[] =$info['TTQTY'];
} // end while
} //end else
} // end generateRandomData
But still i am not able to plot the charts.
i am using php version 5.3.17 on windows server.
Looks like i am quite near to get my charts work
Thanks in Advance
Pankaj Arya |
Re: Reg database connection for interactive financial charts |
Posted by Peter Kwan on Oct-02-2012 02:41 |
|
Hi Pankaj,
You mentioned you can "connect to database". But can you read data from the database with your SQL query?
Your SQL query looks strange to me (or I may not understand your query). For example, you use the "LIMIT" with dates in your query, but the LIMIT is supposed to accept row numbers, not date/time. (Please refer to MySQL documentation for details of their SQL syntax.) Usually, the WHERE clause is used to select the data you want, and the LIMIT clause is to use to limit the number of rows returned (but not to select what is returned).
There is a forum thread below that includes a workable SQL statement. Note that the SQL for every database is different, because every database can have a different schema. You would need to adapt it to your own database.
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1262434685#N1265018420
Hope this can help.
Regards
Peter Kwan |
|