In addition to the API, we have provided a Java SDK to make it easier for Java programmers. We are working to provide SDK for other languages too. This page provides tutorial on how to use the API with Java programming language. This tutorial assumes that you are a Java programmer and you are familiar with the Java programming language.
Download the Investfly SDK Kit InvestflySDK.zip. Unzip the file. You should have InvestflySDK folder after extraction.
Open 'StrategiesExecutor.java'. Double-click src, then com, then Investfly, then api, then samples. You will find 'StrategiesExecutor.java' here. Open the file with a source editor. Replace the following with your username and password that you use to access http://www.Investfly.com
private static final String USER_NAME = "replace_with_your_username";
private static final String PASSWORD = "replace_with_your_password;
You must have an account with us to use the API. If you do not, you can sign up at http://www.investfly.com/register. This is the top level file that will run your strategies.
Two Strategies are implemented in MovingAverageCrossover.java and Contrarian.java respectively. These files are in the examples folder. These are basic strategies used for illustration only. Open these files and look over the strategies.
Go to the extracted InvestflySDK folder, double click either compile.sh (linux) or compile.bat (windows) to compile. You must have javac compiler in your path for the script to work. If they are installed but not in your path, edit the compile.sh/compile.bat and supply full path to javac commands.
Run your strategies by double-clicking run.sh (linux) or run.bat (windows) inside the InvestflySDK folder. You must have Java installed in your path to run this command. You should see portfolio messages getting printed in console window. That's it! Now, login to http://www.investfly.com/login to see which stock(s) your portfolio bought.
Executing these strategies requires Java to make HTTP web connection to Investfly. If you get SocketConnection Exception or similar exception, make sure that you are not behind corporate firewall. If you use proxy to access outside network, edit run.sh or run.bat and put in your proxy settings as JVM parameters after java -Dhttp.proxyHost=10.10.10.10 -Dhttp.proxyPort=8800.
You should run your strategies at regular intervals (daily, weekly, monthly) depending on the logic behind your portfolio. If your portfolio is a long-term portfolio, you may run it every month, if it is a short-term, you may want to run it every day. You can run your strategies manually, but you are strongly advised to setup a scheduled task (windows) or cronjob (linux) for running your strategies at your desired interval so that you do not have to worry about it. You can monitor the results of your strategies by using the performance chart at http://www.investfly.com.
For setting up scheduled task in windows, see
For setting up cronjob in linux, see http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
Once you have run the example strategies, you should start writing our own strategies. Please see API documentation for all REST API calls you can make.