Market sentiment dashboard using Curl and PHP

In this article I will show you how to create a little Dashboard of  Market Sentiment results taken on differents IG Trading web-pages. And feed it in a HTML table for Dashboard.

The use of Curl in PHP will permit you to create Dashboard of data from different Websites, in the same page.

DEMO: See it in action:

Warning: Don't use the following script for Trading! 

Firtly I would like to "read" the market sentiment on IG symbols webpages like the following:

Then I need to scrap from each page two informations:
- Percentage of customer wich have positions open Short/long
- Direction of the position: Short or Long

  1. To do so I will use Curl function of PHP. The following script will extract all text of 'ma__title' class, then the symbol name of Index or currency...
  2. You also need to copy and integrate dom parser functions to "read" the html page and extract some text: you can download here: but you just need to include the following file: simple_html_dom.php in your code.

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url[$x]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

$html = new simple_html_dom();

echo "  <tr>";
echo "<td class='tg-us36'>";
foreach($html->find('.ma__title') as $symbol)
echo "<a href='$url[$x]' target='_blank'>". $symbol->plaintext ."</a>";
echo "</td>";


Each url you provide in $url[$x] array will be read and the results will be append in  HTML in a FOR LOOP

At each row, you can calculate an action depending of the market sentiment, i.e. if you would like to BUY each time Sentiment percentage is above 70% you can add the following scritp:

foreach($html->find('.information-popup strong') as $result) {
if ($precent<71) {echo 'CLOSE';}
if ($result->plaintext == 'ha posizioni short') echo '<b>SELL</b>';
if ($result->plaintext == 'ha posizioni long') echo '<b>BUY</b>';

Notice that you can create trading bots in TagUI which can go to your PHP dashboard and read the "Action" and schedule it each hour or 30' ...


Feel free to ask some question if you have any problem!
Goog Web-scraping!

Nessun commento:

Posta un commento

Heal Health, Finances, Relationships And Other Issues Within 30 Days

You Will Be Able To Automatically Delete Negative Conditioning In You Going From Sickness, Bad Finances, Poor Relationships To Health, Finan...