Activequant Examples¶
Misc examples demonstrating how to use Activequant components to do stuff like
- download historical data
- save it in the database
- run backtester
- run automated trading system on a paper trading account
Building Examples Using Eclipse¶
You need SVN (aka Subversion) eclipse plugin and Q4E Maven Eclipse plugin.
Building and Running Examples¶
- Checkout
activequant-examplesmodule (use trunk or release, depending on your goals. Most recent and less stable stuff is under trunk). - Right-click on the project in Eclipse's Project Explorer. Choose Project Properties. Make sure you are using Java Compiler version 1.5 or higher.
- Right-click on the project in Eclipse's Project Explorer and enable Maven nature.
- Wait till Eclipse builds the project (may take some time, be patient).
- Browse sources - look for the classes with
mainmethod (runnable classes). You can try running them.
... from the command line
Check out from subversion the project activequant examples (see above). Once done, run in the folder:ustaudinger@debian:~/work/aqt-examples$ mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building AQ :: Examples [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. Downloading: http://activequant.org/m2/external/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://activequant.org/m2/repo/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://repo1.maven.org/maven2/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom ....
Be very patient on the first time. Get two cups of coffee and read something ... In the meantime Maven2 will update in all dependencies.
On second time compilation it will all go very fast and you'll see something like this:ustaudinger@debian:~/work/aqt-examples$ mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building AQ :: Examples [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. Downloading: http://activequant.org/m2/external/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://activequant.org/m2/repo/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://repo1.maven.org/maven2/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://activequant.org/m2/external/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom Downloading: http://activequant.org/m2/repo/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom Downloading: http://repo1.maven.org/maven2/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom [WARNING] While downloading jexcelapi:jxl:2.6 This artifact has been relocated to net.sourceforge.jexcelapi:jxl:2.6. Downloading: http://activequant.org/m2/external/com/ib/client/9.20/client-9.20.pom Downloading: http://activequant.org/m2/repo/com/ib/client/9.20/client-9.20.pom Downloading: http://repo1.maven.org/maven2/com/ib/client/9.20/client-9.20.pom Downloading: http://activequant.org/m2/external/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom Downloading: http://activequant.org/m2/repo/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom Downloading: http://repo1.maven.org/maven2/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom [INFO] [compiler:compile] [INFO] Compiling 121 source files to /home/ustaudinger/work/aqt-examples/target/classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30 seconds [INFO] Finished at: Sun Apr 19 18:17:58 UTC 2009 [INFO] Final Memory: 12M/26M [INFO] ------------------------------------------------------------------------ ustaudinger@debian:~/work/aqt-examples$ ls
Using the CTS data file converter¶
The CTS data file converter is an example application which can read the dat files generated from the CTS project on aq.org.
Run it, for example, directly from maven2:
ustaudinger@debian:~/work/aqt-examples$ mvn exec:java -Dexec.mainClass="org.activequant.cts.DataImporter" [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'exec'. [INFO] ------------------------------------------------------------------------ [INFO] Building AQ :: Examples [INFO] task-segment: [exec:java] [INFO] ------------------------------------------------------------------------ [INFO] Preparing exec:java [INFO] No goals needed for project - skipping Downloading: http://activequant.org/m2/external/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://activequant.org/m2/repo/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://repo1.maven.org/maven2/flanagan/flanagan/1.1.0/flanagan-1.1.0.pom Downloading: http://activequant.org/m2/external/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom Downloading: http://activequant.org/m2/repo/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom Downloading: http://repo1.maven.org/maven2/org/ta-lib/ta-lib/0.3.0/ta-lib-0.3.0.pom [WARNING] While downloading jexcelapi:jxl:2.6 This artifact has been relocated to net.sourceforge.jexcelapi:jxl:2.6. Downloading: http://activequant.org/m2/external/com/ib/client/9.20/client-9.20.pom Downloading: http://activequant.org/m2/repo/com/ib/client/9.20/client-9.20.pom Downloading: http://repo1.maven.org/maven2/com/ib/client/9.20/client-9.20.pom Downloading: http://activequant.org/m2/external/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom Downloading: http://activequant.org/m2/repo/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom Downloading: http://repo1.maven.org/maven2/org/otfeed/otfeed-driver/0.1.1/otfeed-driver-0.1.1.pom [INFO] [exec:java] This command line tool requires as parameters: (1) a hibernate config file, (2) the filename to import. Example: java DataImporter hibernate.cfg.xml 123123.datA fully working command line looks like this:
ustaudinger@debian:~/work/aqt-examples$ mvn exec:java -Dlog4j.configuration=file:///home/ustaudinger/work/aqt-examples/log4j.xml xec.mainClass="org.activequant.cts.DataImporter" -Dexec.args="/home/ustaudinger/work/aqt-examples/hibernate.cfg.xml /home/share/cts/cts-data-relay/bin/Debug/recorded_data/20090409/"
In case you want to use mysql, edit the pom file and uncomment the mysql section (search for it).