This is a sample MATLAB script that follows the Authorization Code grant type. Here are some key features:
- Automatically open TradeStation login screen in the MATLAB browser
- Listen for authorization code to generate access token
- Make a simple request to the TradeStation WebAPI
- Deserialize data from JSON into MATLAB objects
Modify your Key/Secret/BaseUrl:
APIKEY = '';
APISECRET = '';
BASEURL = 'https://sim.api.tradestation.com/v2/';
Supported BASEURL environments include:
- SIMULATED TRADING - https://sim.api.tradestation.com/v2/
- LIVE TRADING - https://api.tradestation.com/v2/
- Copy tradestationwebapi.m and associated dependencies to your MATLAB Path
- Execute tradestationwebapi in MATLAB
If you can make this sample code easier to understand, please fork the repository and send a pull request. We will review the changes and merge as appropriate.
If you get a message about SSL problems, you will need to add the TradeStation WebAPI SSL certificates to your MATLAB approved certificate store. Take a look at these two resources:
- Can I force MATLAB to open secure websites with untrusted SSL certificates?
- Convert .pem to .crt and .key
If there are any problems, open an issue and we'll take a look! You can also give us feedback by e-mailing webapi@tradestation.com