|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
org.akutan.EfficientFrontier
public class EfficientFrontier
Applet/Main class for Application that displays the results from the optimization code. Allows the user to select one or more assets and an optimization method and then uses the optimizer to compute the mean variance frontier and/or the efficient frontier and displays several views.
| Nested Class Summary | |
|---|---|
static class |
EfficientFrontier.SampleData
Little inner class value object we use to hold raw input data for a given month so we can use a single collection rather than several arrays. |
| Nested classes/interfaces inherited from class javax.swing.JApplet |
|---|
javax.swing.JApplet.AccessibleJApplet |
| Nested classes/interfaces inherited from class java.applet.Applet |
|---|
java.applet.Applet.AccessibleApplet |
| Nested classes/interfaces inherited from class java.awt.Panel |
|---|
java.awt.Panel.AccessibleAWTPanel |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected org.jfree.chart.plot.XYPlot |
_areaPlot
|
protected org.jfree.chart.plot.PiePlot |
_piePlot
|
| Fields inherited from class javax.swing.JApplet |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.print.Printable |
|---|
NO_SUCH_PAGE, PAGE_EXISTS |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
EfficientFrontier()
Constructs |
|
| Method Summary | |
|---|---|
void |
action(java.awt.event.ActionEvent event,
java.lang.Object arg)
Action handler for the buttons on the main control panel, these are Go and Clear. |
void |
constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height)
helper method to set layout constraints when adding a component to a container. |
void |
constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height,
int fill,
int anchor,
double weight_x,
double weight_y,
int top,
int left,
int bottom,
int right)
Helper method to apply layout constraint to a component as it's added to a container. |
void |
constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height,
int top,
int left,
int bottom,
int right)
Helper method to set layout constraints when adding a component to a container. |
protected org.jfree.chart.JFreeChart |
createChart(org.jfree.data.xy.XYDataset xydataset)
Called to create the Efficient Frontier chart on the main frame of the application. |
protected void |
createGui()
Called to create the various charts and associated bits during initialization of the application. |
protected void |
createPath()
Given the first optimization run, strips out any path information and draws the path in series 0 with shapes = CrossCircle so that one can see the path of the optimizer. |
protected org.jfree.chart.plot.PiePlot |
createPieChart()
Called to create the pie chart frame and chart objects so they can be filled in when an optimization is run. |
protected void |
dumpPoints(java.util.List<SolvedPoint> points)
Debug method to dump all the points on an efficient frontier to System.out. |
protected java.lang.String |
formatString(java.lang.String s)
Helper method to format a string and squeeze out multiple spaces replacing them with just one. |
protected java.lang.String[] |
getAssets()
Returns the names of the selected assets as an array. |
protected double |
getDouble(java.lang.String number)
helper method to convert a string into a double and deal with any conversion exceptions. |
protected int |
getMonth(java.lang.String month)
Helper method to return the month number given the three letter abbreviation for a month. |
java.lang.String |
getParameter(java.lang.String name)
Wraps the logic for retrieving parameters so we can use the same code as an applet and as an application. |
void |
init()
Initializes the application/applet, handles setting up the UI and loading the raw returns into memory. |
protected void |
loadReturnsFromFile(java.lang.String dataURLName,
java.util.List<EfficientFrontier.SampleData> samplePoints)
Reads the market data (monthly asset returns) from a .csv file and puts them into SampleData objects on a list. |
static void |
main(java.lang.String[] args)
|
void |
paint(java.awt.Graphics g)
New paint method for graphics panel using jfreechart |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat f,
int page)
|
void |
run()
Used with SwingUtilities to cause a paint when a calculation has completed |
void |
setParameter(java.lang.String key,
java.lang.String value)
Sets a parameter for later access by getParameter method. |
void |
stateChanged(javax.swing.event.ChangeEvent changeevent)
Called when the slider moves to update the area chart, the pie chart and the efficient frontier chart |
| Methods inherited from class javax.swing.JApplet |
|---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update |
| Methods inherited from class java.applet.Applet |
|---|
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
| Methods inherited from class java.awt.Panel |
|---|
addNotify |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected org.jfree.chart.plot.XYPlot _areaPlot
protected org.jfree.chart.plot.PiePlot _piePlot
| Constructor Detail |
|---|
public EfficientFrontier()
| Method Detail |
|---|
public void setParameter(java.lang.String key,
java.lang.String value)
key - Name of the parameter to be setvalue - Value for the parameterpublic java.lang.String getParameter(java.lang.String name)
getParameter in class java.applet.Appletname - Name of the parameter for which the value is to be returned
protected void loadReturnsFromFile(java.lang.String dataURLName,
java.util.List<EfficientFrontier.SampleData> samplePoints)
dataURLName - samplePoints -
public int print(java.awt.Graphics g,
java.awt.print.PageFormat f,
int page)
print in interface java.awt.print.Printablepublic void init()
init in class java.applet.Appletprotected int getMonth(java.lang.String month)
month -
protected org.jfree.chart.plot.PiePlot createPieChart()
public void stateChanged(javax.swing.event.ChangeEvent changeevent)
stateChanged in interface javax.swing.event.ChangeListenerchangeevent - The slider eventprotected org.jfree.chart.JFreeChart createChart(org.jfree.data.xy.XYDataset xydataset)
xydataset - Dataset of risk vs return data for points on the efficient
frontier
protected double getDouble(java.lang.String number)
number - String to be converted into a double
protected java.lang.String formatString(java.lang.String s)
s - String to be cleaned
public void constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height,
int fill,
int anchor,
double weight_x,
double weight_y,
int top,
int left,
int bottom,
int right)
container - component - grid_x - grid_y - grid_width - grid_height - fill - anchor - weight_x - weight_y - top - left - bottom - right -
public void constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height)
container - component - grid_x - grid_y - grid_width - grid_height -
public void constrain(java.awt.Container container,
java.awt.Component component,
int grid_x,
int grid_y,
int grid_width,
int grid_height,
int top,
int left,
int bottom,
int right)
container - component - grid_x - grid_y - grid_width - grid_height - top - left - bottom - right - protected void dumpPoints(java.util.List<SolvedPoint> points)
points -
public void action(java.awt.event.ActionEvent event,
java.lang.Object arg)
event - arg - protected java.lang.String[] getAssets()
public void run()
run in interface java.lang.Runnableprotected void createPath()
public void paint(java.awt.Graphics g)
paint in class java.awt.Containerg - protected void createGui()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||