R/csi.R

#################################################################################
##
##   R package rcsi by Alexios Ghalanos Copyright (C) 2008, 2009
##   This file is part of the R package rcsi.
##
##   The R package rcsi is free software: you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation, either version 3 of the License, or
##   (at your option) any later version.
##
##   The R package rcsi is distributed in the hope that it will be useful,
##   but WITHOUT ANY WARRANTY; without even the implied warranty of
##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##   GNU General Public License for more details.
##
#################################################################################

startUA <- function()
{
	# Create the COM reference to UA.Api2
	if(inherits(try(library(RDCOMClient), silent = TRUE), "try-error"))
	{
		cat("\nPlease manually download and install the RDCOM package from \nhttp://www.omegahat.org/RDCOMClient/ before continuing\n")
		cat("\nDetaching package RCSI...\n")
		detach("library:RCSI")
		return()
	} else{
		require(RDCOMClient)
	}
	.ua = COMCreate("UA.Api2") # foreground
	.ua[["WindowState"]] = 1 #!0=Normal, 1=Minimized, 2=Maximized
	assign(".ua", .ua, env = .GlobalEnv)
	# make sure we are returning decimal numbers
	if(.ua[["ShowDecimalPoint"]] != 1) .ua[["ShowDecimalPoint"]] = 1
	cat(paste("\nCOMMODITY SYSTEMS INCORPORATED"))
	cat(paste("\nCSI Unfair Advantage Version : ", .ua[["VersionNumber"]],"\n\n"))
}

stopUA = function()
{
	.ua[["HoldUAOpenOnClose"]] = 0
	.ua = NULL
}

.getCSInum = function(symbol)
{	
	if(!exists(".ua")) startUA()
    .ua[["MarketSymbol"]] = symbol
    csinum = .ua$FindMarketNumber()
    return(csinum)
}

Try the RCSI package in your browser

Any scripts or data that you put into this service are public.

RCSI documentation built on May 2, 2019, 4:50 p.m.