Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-s committed Mar 20, 2021
1 parent 4017f31 commit 29b8d00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
18 changes: 10 additions & 8 deletions @TDAmeritrade/getFundamental.m
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion @TDAmeritrade/getPriceHistory.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 29b8d00

Please sign in to comment.