[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Option Script in Amibroker



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@xxx> 
wrote:
>
> Several years ago, someone presented a plugin that would pull 
Option information from CBOE in a pop-up window for which ever ticker 
was charted.....Does anyone have this script....or remember it...I 
was trying to locate it but can not....
> 
> Or...
> 
> Has anyone done anything similar and would like to share....I am 
interested in pulling Option information and Implied volatility %...
> 
> 
> 
> Thank you
> Anthony
>
here u go
/* -----------------------------------------------
  OptionPopup Script for AmiBroker
  by Jim Varney  jvarn359@xxx<-nospam->oo.com
  
  This script grabs the options quote web page from OIC for the
  active stock in Amibroker. The script strips out all the headers
  and extraneous junk and reformats the page to show only the
  quote table. The reformatted web page is shown in a "popup"
  window in the upper left. This allows you to contemplate the 
  right half of the stock chart and the options table at the same
  time.
  
  To use, save this script as "optionpopup.js" in your AmiBroker
  Scripts directory. Then, in Amibroker, add the script
  to the Tools Menu via Tools, Customize.
  
  Tested with Win2000, IE v6.0, AmiBroker v4.60 Standard.
  The hyperlinked quotes in the popup table do not work.
  
  v.2 (2003): Use CBOE web site for quotes.
  v.3 (2004): Use OIC
----------------------------------------------- */ 

var oShell = WScript.CreateObject("WScript.Shell");
var oAB = new ActiveXObject("Broker.Application");
var oIE = new ActiveXObject("internetexplorer.application");

//get the ticker currently active in AmiBroker
Ticker = oAB.ActiveDocument.Name;
myURL = "http://templates.pcquote.com/occ/stringget.php?ticker="; + 
Ticker;

//create DOM object to capture CBOE web page
var oHttpRequest= new ActiveXObject("MSXML2.XMLHTTP");
oHttpRequest.Open("GET", myURL, false);
oHttpRequest.Send();
var txtRecd = oHttpRequest.ResponseText;



//tokens to search for in the OIC html
str1 = "vspace=0><br>";
str2 = "<!-- PC Quote Content Ends here -->";

//call two custom string functions (below)
var num1 = GetIndex(txtRecd, str1)+14;
var num2 = GetIndex(txtRecd, str2);
var txtOptions = GetSubstring(txtRecd, num1, num2); //holds the 
desired data

//override the OIC CSS with this one
var txtStyle =  "<style>" +
"#s8{FONT-SIZE: 10px; COLOR: black; FONT-FAMILY: Arial, Helvetica, 
sans-serif}"+
"#s9{FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Arial, Helvetica, 
sans-serif}"+
"#s12{FONT-SIZE: 12px; COLOR: black; FONT-FAMILY: Arial, Helvetica, 
sans-serif}"+
"#s{FONT-SIZE: 10px; COLOR: black; FONT-FAMILY: Arial, Helvetica, 
sans-serif}"+
"#b{FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Arial, Helvetica, 
sans-serif}"+
".myTitle{FONT-SIZE: 10px; COLOR: black; FONT-FAMILY: Arial, 
Helvetica, sans-serif}"+
"</style>"+
"<body bgcolor = white class =\"myTitle\">"+
"<div class =\"myTitle\">OptionPopUp for AmiBroker by J. Varney" +
"<nbsp><nbsp><nbsp>___<nbsp><nbsp><nbsp>Data is (c)OIC 
www.888options.com</div>"+
"<!-- end my customization>"+
"<!-- begin portion to be snipped from OIC-->"; // end CSS

//write html to a file in the local TEMP directory
var fso, f, r
var ForReading = 1, ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
var aPath = oShell.ExpandEnvironmentStrings("%TEMP%")
+ "\\optionstemp.htm";
f = fso.OpenTextFile(aPath, ForWriting, true);
var myHTML = GetIndustryInfo() + txtOptions;  //concat the options 
data to the CSS
f.Write(myHTML);
f.Close();

//adjust properties of the browser window
oIE.width = 800;
oIE.height = 800;
oIE.StatusBar = false;
oIE.MenuBar = false;
oIE.ToolBar = false;
oIE.navigate(aPath);
oIE.visible = true;

//-- string functions -----------------------
function GetIndex(txt, substr){
   var s = txt.indexOf(substr);
   return(s);
}

function GetSubstring(txt, bgn, end){
   var len = end - bgn;
   var s = txt.substr(bgn, len);
   return(s);
}


function GetIndustryInfo(){
if(Ticker.indexOf("-TC")>0){
	Ticker=Ticker.replace("-TC",".TO");
}

myURL = "http://www.investor.reuters.com/StockOverview.aspx?ticker="; 
+ Ticker;

//create DOM object to capture reuters webpage
oHttpRequest.Open("GET", myURL, false);
oHttpRequest.Send();
var txtRecd = oHttpRequest.ResponseText;

//tokens to search for in the OIC html
stra="<TITLE>";
strb="</TITLE>";
str1 = "<!-- button ad ends -->";
str2 = "<!-- premium text links begins -->";


//call two custom string functions (below)
var num1 = GetIndex(txtRecd, stra) + 6;
var num2 = GetIndex(txtRecd, strb);
var txtTitle=GetSubstring(txtRecd, num1, num2); //holds the desired 
data
num1 = GetIndex(txtRecd, str1);
num2 = GetIndex(txtRecd, str2);
var txtOptions = GetSubstring(txtRecd, num1, num2); //holds the 
desired data
return(txtOptions);
}







Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.26/670 - Release Date: 2/5/2007 2:04 PM