diff --git a/@TDAmeritrade/getFundamental.m b/@TDAmeritrade/getFundamental.m index 238fa21..625c9ab 100644 --- a/@TDAmeritrade/getFundamental.m +++ b/@TDAmeritrade/getFundamental.m @@ -1,8 +1,10 @@ % get fundamental info -function fdata = getFundamental(self, progressbar, UseCache) +function fdata = getFundamental(self, o) -if nargin < 3 - UseCache = true; +arguments + self (1,1) TDAmeritrade + o.ProgressBar matlab.ui.dialog.ProgressDialog + o.UseCache (1,1) logical = true end cloc = fullfile(userpath,'tdameritrade','fundamental_data'); @@ -15,15 +17,15 @@ % progress - if nargin > 1 && isa(progressbar,'matlab.ui.dialog.ProgressDialog') - progressbar.Value = (length(self.tickers) - i)/length(self.tickers); - progressbar.Message = ['Downloading fundamental data: ' T]; + if nargin > 1 && isa(o.ProgressBar,'matlab.ui.dialog.ProgressDialog') + o.ProgressBar.Value = (length(self.tickers) - i)/length(self.tickers); + o.ProgressBar.Message = ['Downloading fundamental data: ' T]; else disp(T) end % first check the cache - if UseCache + if o.UseCache try load(fullfile(cloc,[T '.mat']),'FunData') fdata(i) = FunData; @@ -37,7 +39,7 @@ curl_str = 'https://api.tdameritrade.com/v1/instruments?&symbol=TICKER&projection=fundamental&apikey='; curl_str = strrep(curl_str,'TICKER',T); - curl_str = [curl_str self.API_key]; + curl_str = [curl_str self.APIKey]; data = webread(curl_str); try diff --git a/@TDAmeritrade/getPriceHistory.m b/@TDAmeritrade/getPriceHistory.m index 2f2c90e..9809251 100644 --- a/@TDAmeritrade/getPriceHistory.m +++ b/@TDAmeritrade/getPriceHistory.m @@ -20,7 +20,7 @@ curl_str = strrep(curl_str,'END_DATE',mat2str(posixtime(self.EndDate)*1000)); curl_str = strrep(curl_str,'START_DATE',mat2str(posixtime(self.StartDate)*1000)); - curl_str = [curl_str self.API_key]; + curl_str = [curl_str self.APIKey]; temp = webread(curl_str); if temp.empty diff --git a/README.md b/README.md index 9ff00ad..2270467 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,16 @@ data = T.getPriceHistory; Currently, only daily information is available, but future work will support all available frequencies. +You can plot this using: + +``` +plot(data(1).Time,data(1).Close) +``` + +and you should get something like this: + +![](https://user-images.githubusercontent.com/6005346/111885025-a9677d00-899b-11eb-9300-211822763cfc.png) + ### Get delayed quotes ```matlab @@ -58,16 +68,16 @@ returns a structure array with various fundamental information (e.g., `quickRati This information is cached on disk, so subsequent calls will load from the cache and will not ping TDA's servers. If you want to force a fetch from the server, use: ``` -f = T.getFundamental([],false); +f = T.getFundamental('UseCache',false); ``` ### Get option chain ``` -o = T.getOptionChain; +o = T.getOptionChain('Type','Call'); ``` -returns the full option chain for the symbols requested. +returns the full option chain for the symbols requested. Results are returned as an array of [OptionContract](https://github.com/sg-s/tdameritrade-matlab-api/blob/main/OptionContract.m). ### Get transactions from account