-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is Version 1.0 of the application.
- Loading branch information
Steven Shaw
committed
Aug 20, 2012
0 parents
commit 6dfd750
Showing
25 changed files
with
5,171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.vspscc | ||
.builds | ||
*.dotCover | ||
|
||
## TODO: If you have NuGet Package Restore enabled, uncomment this | ||
#packages/ | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper* | ||
|
||
# Installshield output folder | ||
[Ee]xpress | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish | ||
|
||
# Others | ||
[Bb]in | ||
[Oo]bj | ||
sql | ||
TestResults | ||
*.Cache | ||
ClientBin | ||
stylecop.* | ||
~$* | ||
*.dbmdl | ||
Generated_Code #added for RIA/Silverlight projects | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
|
||
|
||
|
||
############ | ||
## Windows | ||
############ | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[co] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
|
||
# Mac crap | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright (c) <2012> <Steven Shaw, Andrew Schmitz> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
------------------------------------------------------------------------------- | ||
* Algorithmic Stock Trader | ||
* | ||
* @author: Steven Shaw | ||
* @email: [email protected] | ||
* @date: 8/18/12 | ||
------------------------------------------------------------------------------- | ||
|
||
Overview: | ||
The purpose of this application is to simulate trading on the United States | ||
Stock market with an emphasis on automated trading. This application makes | ||
it easy to code your own stock trading algorithms and test them. To do so, | ||
simply copy the AlgorithmTemplate class and create your own algorithm. Each | ||
algorithm must implement the Algorithm Interface. Then, add your algorithm | ||
to the availableAlgorithms list in the ConsoleView class and run the application. | ||
It does have one algorithm built in that uses Fibonacci Retracements. | ||
|
||
The application uses the Yahoo! Finance API for stock data. I was going to | ||
use the Google Finance API, however, I learned that it is being shutdown | ||
in October of 2012. If you would like to use a different API to retrieve the | ||
data, add a new class in the incoming_data_sources package. | ||
Note that the ConsoleView class uses the Yahoo! Finance API in a few areas. | ||
|
||
The application serializes the user's Portfolio upon exiting. To use a new | ||
Portfolio, delete the "portfolio.ser" file and restart. Future versions | ||
will not require this to use a new portfolio. | ||
|
||
NOTE: | ||
My application does not make real purchases. It merely simulates purchases. | ||
Be weary of following the advice that the algorithms produce. This application | ||
is meant to be a educational resource. Nothing more, nothing less. | ||
|
||
How to run: | ||
Either run the application in an IDE such as Eclipse or navigate to where | ||
the executable jar is located and use the following command. | ||
|
||
java -jar Algorithmic_Stock_Trader.jar | ||
|
||
------------------------------------------------------------------------------- | ||
Future Features | ||
------------------------------------------------------------------------------- | ||
Add and Remove funds. | ||
|
||
Account Summary page. | ||
|
||
Implement a way to construct a new Portfolio. | ||
|
||
Modify the way the simulation duration is entered. Ex) 50 min or 2 hours. | ||
|
||
Add a GUI. | ||
|
||
Implement Short Selling and Buy To Cover Order Types. Menus already in place. | ||
|
||
Implement market on close, limit, stop, stop limit, trailing stop $, and | ||
trailing stop % price types. All the classes are created and in place. | ||
|
||
Multi-thread the simulation to increase performance. | ||
|
||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
------------------------------------------------------------------------------- | ||
Known Issues | ||
------------------------------------------------------------------------------- | ||
If $0 is entered when creating a portfolio, you can't purchase stocks | ||
and you can't add money later. | ||
|
||
Yahoo sometimes sends back random errors. Not sure of the cause. | ||
|
||
Can only make trades and execute algorithms during regular market hours. | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
------------------------------------------------------------------------------- | ||
Legal: | ||
------------------------------------------------------------------------------- | ||
|
||
I am licensing my application under The MIT License (MIT). | ||
The complete license can be found in LICENSE.txt. | ||
|
||
I (Steven Shaw) and ALL contributors are NOT RESPONSIBLE | ||
for any financial loss you may endure while using this application. | ||
The information that the application retrieves is meant for PERSONAL USE ONLY! | ||
|
||
This application uses the Yahoo! Finance API to retrieve financial data. | ||
By using this application you agree to Yahoo! Inc.'s Terms of Service. | ||
|
||
Yahoo! Inc's Terms of Service can be found here: | ||
http://info.yahoo.com/legal/us/yahoo/utos/utos-173.html | ||
|
||
By accessing the Yahoo! site, you agree not to redistribute the information | ||
found therein. | ||
|
||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
------------------------------------------------------------------------------- | ||
Change Log: | ||
------------------------------------------------------------------------------- | ||
[email protected] Initial Revision | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package algorithms; | ||
|
||
import stocks.Portfolio; | ||
import trade_types.Trade; | ||
|
||
/** | ||
* Interface that defines the layout for custom Algorithms | ||
* Each algorithm class that is created must use this interface | ||
* | ||
* @author Steven Shaw | ||
* @email [email protected] | ||
* | ||
*/ | ||
public interface Algorithm { | ||
|
||
/** | ||
* Sets up the algorithm that will be executed | ||
* | ||
* @param portfolio | ||
*/ | ||
public void setup(Portfolio portfolio); | ||
|
||
/** | ||
* Creates a set of Trades based on an algorithm | ||
* | ||
* @return trades that were computed from an algorithm | ||
*/ | ||
public Trade[] evaluate(); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
Algorithmic Stock Trader/src/algorithms/AlgorithmTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package algorithms; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
||
import stocks.Portfolio; | ||
import trade_types.Trade; | ||
|
||
/** | ||
* Template to build new algorithms from | ||
* | ||
* @author Steven Shaw | ||
* @email [email protected] | ||
* | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class AlgorithmTemplate implements Algorithm { | ||
|
||
// Portfolio and watch list for a trader | ||
private Portfolio myPortfolio; | ||
private ArrayList<String> watchList; | ||
|
||
@Override | ||
public void setup(Portfolio portfolio) { | ||
myPortfolio = portfolio; | ||
watchList = portfolio.getWatchList(); | ||
} | ||
|
||
@Override | ||
public Trade[] evaluate() { | ||
Trade[] newTrades = null; | ||
|
||
|
||
// Your Algorithm Goes Here | ||
|
||
|
||
return newTrades; | ||
} | ||
} |
Oops, something went wrong.