This commit is contained in:
7u83 2017-04-15 12:59:11 +02:00
commit ef8fc3cc05
52 changed files with 866 additions and 2227 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ hs_err_pid*
/build/
/target/
/store/
/nbproject/private

View File

@ -1,9 +0,0 @@
compile.on.save=true
do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
jnlp.signing.keypass=123456
jnlp.signing.storepass=123456
user.properties.file=/home/tobias/.netbeans/8.1/build.properties
ivy.home=/usr/share/java/

View File

@ -1,4 +1,4 @@
#Mon, 27 Mar 2017 16:09:01 +0200
#Thu, 13 Apr 2017 20:27:39 +0200
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
@ -71,7 +71,7 @@ jnlp.signed=true
jnlp.signing=key
jnlp.signing.alias=SeSim
jnlp.signing.keystore=/home/tube/jkeystore
main.class=gui.NewMDIApplication
main.class=gui.SeSimApplication
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
@ -93,5 +93,5 @@ run.test.classpath=${javac.test.classpath}\:${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
ivy.home=/usr/share/java/
ivy.classpath=lib/commons-cli-1.0-javadoc.jar\:lib/commons-cli-1.0-sources.jar\:lib/commons-cli-1.0.jar\:lib/commons-lang-2.0-javadoc.jar\:lib/commons-lang-2.0-sources.jar\:lib/commons-lang-2.0.jar\:lib/commons-logging-1.0.jar\:lib/json-20160810-javadoc.jar\:lib/json-20160810-sources.jar\:lib/json-20160810.jar

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="629" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="333" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

View File

@ -1,445 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
import gui.Globals;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import javax.swing.Scrollable;
import sesim.Exchange;
import sesim.OHLCData;
import sesim.OHLCDataItem;
import sesim.Quote;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class FullChart extends javax.swing.JPanel {
public class Chart extends javax.swing.JPanel implements Exchange.QuoteReceiver, Scrollable {
/**
* Creates new form Chart
*/
public Chart() {
initComponentsChart();
if (Globals.se == null) {
return;
}
Globals.se.addQuoteReceiver(this);
//Graphics g = this.getGraphics();
//g.drawString("Hello world", 0, 0);
}
int item_width = 10;
int items = 350;
long ntime = 0;
OHLCData data = new OHLCData(2000);
OHLCDataItem current = null;
// int min;
// int max;
int getY(float Y) {
return 0;
}
void drawCandle(Graphics2D g, OHLCData d, int x, int y) {
}
@Override
public Dimension getPreferredScrollableViewportSize() {
return this.getPreferredSize();
}
@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
return 100;
}
@Override
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
return 100;
}
@Override
public boolean getScrollableTracksViewportWidth() {
return false;
}
@Override
public boolean getScrollableTracksViewportHeight() {
return false;
}
class XLegendDef {
double unit_width = 1;
int big_tick = 10;
long start;
XLegendDef() {
}
String getAt(int unit) {
Date date = new Date(0 + unit * 5000);
// DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
String dateFormatted = formatter.format(date);
return dateFormatted;
}
}
void drawOHLC(Graphics2D g, int x, OHLCDataItem di) {
}
void drawXLegend(Graphics2D g, XLegendDef xld) {
//XLegendDef xld = new XLegendDef();
g = (Graphics2D) g.create();
int xl_height = 30;
Dimension dim = this.getSize();
int em_height = g.getFontMetrics().getHeight();
int em_width = g.getFontMetrics().stringWidth("M");
int y = dim.height - em_height * 3;
g.drawLine(0, y, dim.width, y);
int n;
double x;
for (n = 0, x = 0; x < dim.width; x += em_width * xld.unit_width) {
if (n % xld.big_tick == 0) {
g.drawLine((int) x, y, (int) x, y + em_height);
} else {
g.drawLine((int) x, y, (int) x, y + em_height / 2);
}
if (n % xld.big_tick == 0) {
String text = "Hello";
text = xld.getAt(n);
int swidth = g.getFontMetrics().stringWidth(text);
g.drawString(text, (int) x - swidth / 2, y + em_height * 2);
}
OHLCDataItem d;
try {
d = data.data.get(n);
} catch (Exception e) {
d = null;
}
n++;
}
}
private void getData() {
}
class RenderCtx {
Rectangle rect;
float scaling;
float min;
Graphics2D g;
float iwidth;
float getY(float y) {
return rect.height - ((y - min) * scaling);
}
}
float getY(float y, float min, float s, Rectangle r) {
return r.height - ((y - min) * s);
}
private void old_drawItem(Graphics2D g, Rectangle r, int prevx, int x, OHLCDataItem prev, OHLCDataItem item, float s, float min) {
if (prev == null) {
prev = item;
}
g.drawLine(prevx, (int) getY(prev.close, min, s, r), x, (int) getY(item.close, min, s, r));
g.drawLine(r.x, r.height + r.y, r.x + r.width, r.height + r.y);
}
private void drawItem_l(RenderCtx ctx, int prevx, int x, OHLCDataItem prev, OHLCDataItem item) {
if (prev == null) {
prev = item;
}
Graphics2D g = ctx.g;
Rectangle r = ctx.rect;
g.drawLine(prevx, (int) ctx.getY(prev.close), x, (int) ctx.getY(item.close));
g.drawLine(r.x, r.height + r.y, r.x + r.width, r.height + r.y);
}
private void drawItem(RenderCtx ctx, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
if (prev == null) {
prev = i;
}
Graphics2D g = ctx.g;
Rectangle r = ctx.rect;
// g.drawLine(prevx, (int) ctx.getY(prev.close), x, (int) ctx.getY(item.close));
// g.drawLine(x,(int)ctx.getY(i.high),x,(int)ctx.getY(i.low));
if (i.open < i.close) {
g.setColor(Color.BLACK);
g.drawLine(x, (int) ctx.getY(i.close), x, (int) ctx.getY(i.high));
g.drawLine(x, (int) ctx.getY(i.low), x, (int) ctx.getY(i.open));
float w = ctx.iwidth;
float h = (int) (ctx.getY(i.open) - ctx.getY(i.close));
// System.out.printf("CLO: %f %f \n", w, h);
g.setColor(Color.GREEN);
g.fillRect((int) (x - w / 2), (int) ctx.getY(i.close), (int) w, (int) h);
g.setColor(Color.BLACK);
g.drawRect((int) (x - w / 2), (int) ctx.getY(i.close), (int) w, (int) h);
} else {
g.setColor(Color.RED);
g.drawLine(x, (int) ctx.getY(i.high), x, (int) ctx.getY(i.close));
g.drawLine(x, (int) ctx.getY(i.open), x, (int) ctx.getY(i.low));
float w = ctx.iwidth;
float h = (int) (ctx.getY(i.close) - ctx.getY(i.open));
g.fillRect((int) (x - w / 2), (int) ctx.getY(i.open), (int) w, (int) h);
g.setColor(Color.BLACK);
g.drawRect((int) (x - w / 2), (int) ctx.getY(i.open), (int) w, (int) h);
}
g.drawLine(r.x, r.height + r.y, r.x + r.width, r.height + r.y);
}
private void drawYLegend(Graphics2D g) {
// Dimension dim = jScrollPane1.
//Dimension dim = new Dimension();
Rectangle dim = g.getClipBounds();
//dim.height = 300;
System.out.printf("GetX %d %d\n", dim.x,dim.width);
Dimension dim0 = this.getSize();
//Rectangle dim = this.getVisibleRect();
g.drawLine(dim.width+dim.x - 50, 0, dim.x+dim.width - 50, dim.height);
// System.out.printf("Size: %d %d\n",dim.width,dim.height);
// System.exit(0);
}
private void draw(Graphics2D g) {
if (data == null) {
return;
}
if (data.size() == 0) {
return;
}
OHLCDataItem di0 = data.get(0);
XLegendDef xld = new XLegendDef();
this.drawXLegend(g, xld);
this.drawYLegend(g);
int em_height = g.getFontMetrics().getHeight();
int em_width = g.getFontMetrics().stringWidth("M");
this.getSize();
int pwidth = em_width * items;
int phight = 400;
this.setPreferredSize(new Dimension(pwidth, phight));
this.revalidate();
Dimension dim = this.getSize();
Iterator<OHLCDataItem> it = data.iterator();
OHLCDataItem prev = null;
int myi = 0;
RenderCtx ctx = new RenderCtx();
Rectangle r = new Rectangle(0, 2 * em_width, pwidth, dim.height - 6 * em_width);
ctx.rect = r;
ctx.scaling = (float) r.height / (data.getMax() - data.getMin());
ctx.min = data.getMin();
ctx.g = g;
ctx.iwidth = em_width - em_width / 5f;
//System.out.printf("Scaling: %f %f %f %f %f\n",diff,(float)r.height,data.getMin(),data.getMax(),yscaling);
while (it.hasNext()) {
OHLCDataItem di = it.next();
int x = myi * em_width;
this.drawItem(ctx, x - em_width, x, prev, di); //, ctx.scaling, data.getMin());
myi++;
prev = di;
}
}
@Override
public void paintComponent(Graphics go) {
super.paintComponent(go);
Graphics2D g = (Graphics2D) go;
g.setColor(Color.GRAY);
g.setBackground(Color.BLACK);
// g.get
Rectangle bounds = g.getDeviceConfiguration().getBounds();
// System.out.print(bounds.width + "\n");
//g.fillRect(0, 0, 100, 100);
Dimension d = this.getSize();
//g.drawString("Hello world", 810, 10);
//g.drawLine(0, 0, d.width, d.height);
//this.setPreferredSize(new Dimension(2000,4000));
draw(g);
}
/**
* This method is called from within the constructor to initialize the
* form. WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponentsChart() {
setBackground(java.awt.Color.white);
setBorder(null);
setOpaque(false);
setPreferredSize(new java.awt.Dimension(300, 300));
setRequestFocusEnabled(false);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>
@Override
public void UpdateQuote(Quote q) {
// System.out.print("Quote Received\n");
// this.realTimeAdd(q.time, (float) q.price, (float)q.volume);
data.realTimeAdd(q.time, (float) q.price, (float) q.volume);
// this.invalidate();
this.repaint();
}
// Variables declaration - do not modify
// End of variables declaration
}
/**
* Creates new form FullChart
*/
public FullChart() {
initComponents();
Chart chart = new Chart();
// this.jScrollPane1.setViewportView(chart);
// this.jScrollPane1.setRowHeaderView(chart);
// this.jScrollPane1.setCorner(JScrollPane., chart);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 629, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 333, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

View File

@ -1,65 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Legend extends javax.swing.JPanel {
/**
* Creates new form Legend
*/
public Legend() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

View File

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="133" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTabbedPane1" pref="168" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="184" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jTabbedPane1" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="jCheckBox1">
<Properties>
<Property name="text" type="java.lang.String" value="jCheckBox1"/>
</Properties>
</Component>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="chart.Chart" name="chart1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="tab1">
<Property name="tabTitle" type="java.lang.String" value="tab1"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="168" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="239" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewJInternalFrame extends javax.swing.JInternalFrame {
/**
* Creates new form NewJInternalFrame
*/
public NewJInternalFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jCheckBox1 = new javax.swing.JCheckBox();
jTabbedPane1 = new javax.swing.JTabbedPane();
chart1 = new chart.Chart();
jButton1.setText("jButton1");
jCheckBox1.setText("jCheckBox1");
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
chart1.setLayout(chart1Layout);
chart1Layout.setHorizontalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 168, Short.MAX_VALUE)
);
chart1Layout.setVerticalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 239, Short.MAX_VALUE)
);
jTabbedPane1.addTab("tab1", chart1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(133, 133, 133)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jCheckBox1)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jCheckBox1)
.addContainerGap(184, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private chart.Chart chart1;
private javax.swing.JButton jButton1;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration//GEN-END:variables
}

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jTabbedPane1" pref="516" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jTabbedPane1" pref="437" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="chart.Chart" name="chart1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="tab1">
<Property name="tabTitle" type="java.lang.String" value="tab1"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="516" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="408" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewJPanel extends javax.swing.JPanel {
/**
* Creates new form NewJPanel
*/
public NewJPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
chart1 = new chart.Chart();
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
chart1.setLayout(chart1Layout);
chart1Layout.setHorizontalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 516, Short.MAX_VALUE)
);
chart1Layout.setVerticalGroup(
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 408, Short.MAX_VALUE)
);
jTabbedPane1.addTab("tab1", chart1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 516, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private chart.Chart chart1;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration//GEN-END:variables
}

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="388" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" pref="294" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>

View File

@ -1,73 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewJPanel1 extends javax.swing.JPanel {
/**
* Creates new form NewJPanel1
*/
public NewJPanel1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class OHLCChart extends Chart{
}

View File

@ -61,7 +61,7 @@
<Font component="jTextPane1" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" value="SeSim - Sock Exchange Simulator - Version 0.1&#xa;&#xa;&#xa;Copyright (c) 2017, 7u83 &lt;7u83@mail.ru&gt;&#xa;All rights reserved.&#xa;&#xa;Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:&#xa;&#xa;* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&#xa;&#xa;* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&#xa;&#xa;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&#xa;"/>
<Property name="text" type="java.lang.String" value="SeSim - Stock Exchange Simulator - Version 0.1&#xa;&#xa;&#xa;Copyright (c) 2017, 7u83 &lt;7u83@mail.ru&gt;&#xa;All rights reserved.&#xa;&#xa;Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:&#xa;&#xa;* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&#xa;&#xa;* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&#xa;&#xa;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&#xa;"/>
</Properties>
</Component>
</SubComponents>

View File

@ -37,7 +37,7 @@ public class AboutDialog extends javax.swing.JDialog {
public AboutDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
// this.setLocationRelativeTo(MainWin.instance);
this.setLocationRelativeTo(null);
}
/**
@ -58,7 +58,7 @@ public class AboutDialog extends javax.swing.JDialog {
jTextPane1.setEditable(false);
jTextPane1.setFont(jTextPane1.getFont());
jTextPane1.setText("SeSim - Sock Exchange Simulator - Version 0.1\n\n\nCopyright (c) 2017, 7u83 <7u83@mail.ru>\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n");
jTextPane1.setText("SeSim - Stock Exchange Simulator - Version 0.1\n\n\nCopyright (c) 2017, 7u83 <7u83@mail.ru>\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n");
jScrollPane1.setViewportView(jTextPane1);
jButton1.setMnemonic('c');

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="63" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTextField2" max="32767" attributes="0"/>
<Component id="jTextField1" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace pref="37" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" pref="65" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" pref="70" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jTextField1" max="32767" attributes="0"/>
<Component id="jLabel1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel2" min="-2" pref="25" max="-2" attributes="0"/>
<Component id="jTextField2" alignment="0" min="-2" pref="27" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="358" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Byu"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="Sell"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField1">
<Properties>
<Property name="text" type="java.lang.String" value="325"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Shares:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Limit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField2">
<Properties>
<Property name="text" type="java.lang.String" value="127.00"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField2ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -1,145 +0,0 @@
/*
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package gui;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ControlPanel extends javax.swing.JPanel {
/**
* Creates new form ControlPanel
*/
public ControlPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jButton1.setText("Byu");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Sell");
jTextField1.setText("325");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jLabel1.setText("Shares:");
jLabel2.setText("Limit:");
jTextField2.setText("127.00");
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField2)
.addComponent(jTextField1)))
.addGroup(layout.createSequentialGroup()
.addContainerGap(37, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField1)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(358, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField2ActionPerformed
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
}

View File

@ -41,7 +41,7 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderConfig;
//import sesim.AutoTraderConfig;
/**
*
@ -79,7 +79,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
ja.put(jo);
}
Globals.prefs.put("Traders", ja.toString());
Globals.prefs.put(Globals.PrefKeys.TRADERS, ja.toString());
}
@ -139,7 +139,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
for (int r = 0; r < model.getRowCount(); r++) {
Boolean e = (Boolean) list.getValueAt(r, list.getColumn("Enabled").getModelIndex());
if (e==null){
if (e == null) {
continue;
}
if (!e) {
@ -147,7 +147,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
}
money += (Double) list.getValueAt(r, list.getColumn("Money").getModelIndex());
shares += (Double) list.getValueAt(r, list.getColumn("Shares").getModelIndex());
System.out.printf("Row: %d %f %f\n", r, money, shares);
// System.out.printf("Row: %d %f %f\n", r, money, shares);
}
return money / shares;
}

View File

@ -194,7 +194,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
void resetUI() {
for (Window w : Window.getWindows()) {
System.out.print("Setting frame\n");
SwingUtilities.updateComponentTreeUI(w);
w.pack();
}

View File

@ -36,8 +36,6 @@ import java.util.logging.Logger;
import javax.swing.JPanel;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
@ -75,7 +73,7 @@ public final class EditStrategies extends javax.swing.JDialog {
initComponents();
String dp = new java.io.File(NewMDIApplication.class.getProtectionDomain()
String dp = new java.io.File(SeSimApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString();
@ -93,7 +91,7 @@ public final class EditStrategies extends javax.swing.JDialog {
final String STRATEGYPREFS = "Strategies";
//final String STRATEGYPREFS = "Strategies";
void reloadStrategyConfigs() {
@ -261,7 +259,7 @@ public final class EditStrategies extends javax.swing.JDialog {
private void jComboBoxStrategySelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStrategySelectorActionPerformed
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
JSONObject cfgs = new JSONObject(cfglist);
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
@ -354,12 +352,12 @@ System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
item = item + " - " + d.getName();
}
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
JSONObject cfgs = new JSONObject(cfglist);
cfgs.put(item, o);
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, cfgs.toString());
//this.reloadStrategyConfigs();
this.initComboBox();
@ -381,14 +379,14 @@ System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
String selected = (String) this.jComboBoxStrategySelector.getSelectedItem();
System.out.printf("Selected: %s\n", selected);
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
JSONObject cfgs = new JSONObject(cfglist);
//System.out.printf("CFG vorher: %s\n", cfgs.toString(3));
cfgs.remove(selected);
// System.out.printf("Neue nachher: %s\n", cfgs.toString(3));
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, cfgs.toString());
this.initComboBox();

View File

@ -27,7 +27,9 @@ package gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@ -47,6 +49,12 @@ import sesim.AutoTraderLoader;
* @author 7u83 <7u83@mail.ru>
*/
public class Globals {
public static final String SESIM_FILEEXTENSION = "sesim";
public static final Double SESIM_FILEVERSION = 0.1;
public static final String SESIM_APPTITLE = "SeSim - Stock Exchange Simulator";
public interface CfgListener {
@ -67,14 +75,30 @@ public class Globals {
public static JFrame frame;
static final String STRATEGYPREFS = "Strategies";
static final String TRADERPREFS = "Traders";
// static final String STRATEGYPREFS = "Strategies";
// static final String TRADERPREFS = "Traders";
static final String DEVELSTATUS = "devel_status";
public static final String GODMODE = "godmode";
static public sesim.Exchange se;
/**
* Defines keys for preferences
*/
public static final class PrefKeys{
public static String WORKDIR = "workdir";
public static final String CURRENTFILE = "currentfile";
public static final String SESIMVERSION = "version";
public static final String STRATEGIES = "strategies";
public static final String TRADERS = "traders";
}
static public Preferences prefs;
public static class CfgStrings {
@ -116,18 +140,18 @@ public class Globals {
static AutoTraderLoader tloader;
static void initGlobals() {
String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
ArrayList pathlist = new ArrayList<>(Arrays.asList(a));
System.out.printf("Init tloader\n");
pathlist = new ArrayList<>();
String dp = new java.io.File(NewMDIApplication.class.getProtectionDomain()
String dp = new java.io.File(SeSimApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString();
pathlist.add(dp);
LOGGER.info(String.format("Path %s",dp));
LOGGER.info(String.format("Path %s", dp));
tloader = new AutoTraderLoader(pathlist);
}
@ -135,17 +159,26 @@ public class Globals {
static public final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
static public final JSONArray getTraders() {
String traders_json = Globals.prefs.get(TRADERPREFS, "[]");
String traders_json = Globals.prefs.get(PrefKeys.TRADERS, "[]");
JSONArray traders = new JSONArray(traders_json);
return traders;
}
static public final JSONObject getStrategies() {
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
String cfglist = Globals.prefs.get(PrefKeys.STRATEGIES, "{}");
JSONObject cfgs = new JSONObject(cfglist);
return cfgs;
}
static public final void putStrategies(JSONObject strategies){
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, strategies.toString());
}
static public final void putTraders (JSONArray traders){
Globals.prefs.put(Globals.PrefKeys.TRADERS, traders.toString());
}
static public JSONObject getStrategy(String name) {
return getStrategies().getJSONObject(name);
}
@ -177,24 +210,60 @@ public class Globals {
static public final void saveStrategy(String name, JSONObject cfg) {
JSONObject cfgs = getStrategies();
cfgs.put(name, cfg);
prefs.put(STRATEGYPREFS, cfgs.toString());
prefs.put(PrefKeys.STRATEGIES, cfgs.toString());
}
static void saveFile(File f) {
public static void saveFile(File f) throws FileNotFoundException {
JSONObject sobj = new JSONObject();
JSONArray traders = getTraders();
JSONObject strategies = getStrategies();
sobj.put("strategies", strategies);
sobj.put("traders", traders);
try {
PrintWriter out = new PrintWriter(f.getAbsolutePath());
out.print(sobj.toString(4));
out.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, null, ex);
}
sobj.put(PrefKeys.SESIMVERSION, SESIM_FILEVERSION);
sobj.put(PrefKeys.STRATEGIES, strategies);
sobj.put(PrefKeys.TRADERS, traders);
PrintWriter out;
out = new PrintWriter(f.getAbsolutePath());
out.print(sobj.toString(4));
out.close();
}
public static void loadString(String s) throws IOException{
JSONObject sobj = new JSONObject(s);
Double version = sobj.getDouble(PrefKeys.SESIMVERSION);
if (version > SESIM_FILEVERSION){
throw new IOException("File has wrong version.");
}
JSONArray traders = sobj.getJSONArray(PrefKeys.TRADERS);
JSONObject strategies = sobj.getJSONObject(PrefKeys.STRATEGIES);
putStrategies(strategies);
putTraders(traders);
}
public static void clearAll(){
putStrategies(new JSONObject());
putTraders(new JSONArray());
}
public static void loadFile(File f) throws IOException {
f.getAbsoluteFile();
String s;
s = new String(Files.readAllBytes(f.toPath()));
loadString(s);
}
}

View File

@ -88,7 +88,7 @@ public class MainChart extends chart.Chart {
1 * 24 * 3600 * 1000, 2 * 24 * 3600 * 1000
};
private final Integer default_cmopression = 60 * 1000;
private final Integer default_cmopression = 60 * 60 * 1000;
private void initCtxMenu() {
ButtonGroup group = new ButtonGroup();

View File

@ -55,12 +55,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="1" pref="400" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="221" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>

View File

@ -49,13 +49,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
DefaultTableModel model;
public final void updateModel() {
System.out.printf("Update Model\n");
if (null == account) {
return;
}
System.out.printf("Now updateing\n");
int row = 0;
@ -90,6 +88,7 @@ public class OpenOrdersList extends javax.swing.JPanel {
model.setRowCount(0);
table.setFillsViewportHeight(true);
updateModel();
}
public void initOrderList(Account account) {
@ -179,11 +178,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)
.addComponent(jScrollPane1)
);
}// </editor-fold>//GEN-END:initComponents
@ -191,11 +190,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
Point point = evt.getPoint();
int currentRow = table.rowAtPoint(point);
if (currentRow == -1) {
} else {
if (currentRow != -1) {
table.setRowSelectionInterval(currentRow, currentRow);
} else {
}
int nbuttons = MouseInfo.getNumberOfButtons();
@ -204,9 +203,7 @@ public class OpenOrdersList extends javax.swing.JPanel {
return;
}
this.ctxMenu.show(this, evt.getX(), evt.getY());
System.out.printf("Button %d %d \n", nbuttons, button);
ctxMenu.show(table, point.x,point.y);
}//GEN-LAST:event_tableMousePressed

View File

@ -53,15 +53,6 @@
<Property name="text" type="java.lang.String" value="File"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties>
<Property name="mnemonic" type="int" value="110"/>
<Property name="text" type="java.lang.String" value="New"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="openMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="111"/>
@ -76,6 +67,9 @@
<Property name="mnemonic" type="int" value="115"/>
<Property name="text" type="java.lang.String" value="Save"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenuItem">
<Properties>
@ -87,6 +81,38 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="closeMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="99"/>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator5">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="resetToDefaultsMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="114"/>
<Property name="text" type="java.lang.String" value="Reset to defaults"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetToDefaultsMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="clearMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="99"/>
<Property name="text" type="java.lang.String" value="Clear All"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearMenuItemActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="120"/>
@ -179,21 +205,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="simMenuStopActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator3">
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
<Properties>
<Property name="text" type="java.lang.String" value="Point Zero"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem4ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
<Properties>
<Property name="text" type="java.lang.String" value="jMenuItem5"/>
</Properties>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="viewMenu">
@ -211,22 +222,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewTraderListCheckBoxActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="viewClock">
<Properties>
<Property name="text" type="java.lang.String" value="Clock"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewClockActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
<Properties>
<Property name="text" type="java.lang.String" value="LogWindow"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
<Properties>
<Property name="text" type="java.lang.String" value="Orderbook"/>
@ -243,12 +238,6 @@
<Property name="text" type="java.lang.String" value="Help"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="contentMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="99"/>
<Property name="text" type="java.lang.String" value="Contents"/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem">
<Properties>
<Property name="mnemonic" type="int" value="97"/>
@ -265,6 +254,7 @@
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="SeSim - Stock Exchange Simmulator"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[640, 480]"/>
</Property>

View File

@ -29,17 +29,42 @@ import java.awt.Dialog;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
<<<<<<< HEAD:src/gui/NewMDIApplication.java
=======
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TimerTask;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
import java.util.prefs.Preferences;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
<<<<<<< HEAD:src/gui/NewMDIApplication.java
=======
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
import javax.swing.filechooser.FileNameExtensionFilter;
import org.json.JSONArray;
import org.json.JSONObject;
<<<<<<< HEAD:src/gui/NewMDIApplication.java
=======
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
import sesim.AutoTraderInterface;
import sesim.Exchange;
import sesim.Scheduler;
@ -48,19 +73,42 @@ import sesim.Scheduler;
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewMDIApplication extends javax.swing.JFrame {
public class SeSimApplication extends javax.swing.JFrame {
/**
* Creates new form NewMDIApplication
*/
public NewMDIApplication() {
public SeSimApplication() {
initComponents();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = ge.getScreenDevices();
//Window w = screens[1].getFullScreenWindow();
// JFrame dummy = new JFrame(screens[1].getDefaultConfiguration());
// setLocationRelativeTo(dummy);
// dummy.dispose();
for (GraphicsDevice gd:screens){
//Window w = gd.getFullScreenWindow();
}
setTitle("");
boolean init = Globals.prefs.getBoolean("initilized", false);
if (!init){
resetToDefaults();
Globals.prefs.putBoolean("initilized", true);
}
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
// Globals.frame = this;
//this.setLocationRelativeTo(null);
System.out.printf("Set title\n");
setTitle("SeSim - Stock Exchange Simmulator");
}
AutoTraderInterface createTraderNew(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
@ -163,10 +211,14 @@ public class NewMDIApplication extends javax.swing.JFrame {
statistics1 = new gui.Statistics();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
openMenuItem = new javax.swing.JMenuItem();
saveMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
closeMenuItem = new javax.swing.JMenuItem();
jSeparator5 = new javax.swing.JPopupMenu.Separator();
resetToDefaultsMenuItem = new javax.swing.JMenuItem();
clearMenuItem = new javax.swing.JMenuItem();
jSeparator4 = new javax.swing.JPopupMenu.Separator();
exitMenuItem = new javax.swing.JMenuItem();
editMenu = new javax.swing.JMenu();
editExchangeMenuItem = new javax.swing.JMenuItem();
@ -179,16 +231,10 @@ public class NewMDIApplication extends javax.swing.JFrame {
simMenuStart = new javax.swing.JMenuItem();
simMenuPause = new javax.swing.JMenuItem();
simMenuStop = new javax.swing.JMenuItem();
jSeparator3 = new javax.swing.JPopupMenu.Separator();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
viewMenu = new javax.swing.JMenu();
viewTraderListCheckBox = new javax.swing.JCheckBoxMenuItem();
viewClock = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
helpMenu = new javax.swing.JMenu();
contentMenuItem = new javax.swing.JMenuItem();
aboutMenuItem = new javax.swing.JMenuItem();
jTextArea1.setColumns(20);
@ -203,6 +249,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
jSplitPane1.setTopComponent(jSplitPane2);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SeSim - Stock Exchange Simmulator");
setMinimumSize(new java.awt.Dimension(640, 480));
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
@ -322,15 +369,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
fileMenu.setMnemonic('f');
fileMenu.setText("File");
jMenuItem1.setMnemonic('n');
jMenuItem1.setText("New");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
fileMenu.add(jMenuItem1);
openMenuItem.setMnemonic('o');
openMenuItem.setText("Open");
openMenuItem.addActionListener(new java.awt.event.ActionListener() {
@ -342,6 +380,11 @@ public class NewMDIApplication extends javax.swing.JFrame {
saveMenuItem.setMnemonic('s');
saveMenuItem.setText("Save");
saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveMenuItemActionPerformed(evt);
}
});
fileMenu.add(saveMenuItem);
saveAsMenuItem.setMnemonic('a');
@ -354,6 +397,36 @@ public class NewMDIApplication extends javax.swing.JFrame {
});
fileMenu.add(saveAsMenuItem);
closeMenuItem.setMnemonic('c');
closeMenuItem.setText("Close");
closeMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closeMenuItemActionPerformed(evt);
}
});
fileMenu.add(closeMenuItem);
fileMenu.add(jSeparator5);
resetToDefaultsMenuItem.setMnemonic('r');
resetToDefaultsMenuItem.setText("Reset to defaults");
resetToDefaultsMenuItem.setToolTipText("");
resetToDefaultsMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resetToDefaultsMenuItemActionPerformed(evt);
}
});
fileMenu.add(resetToDefaultsMenuItem);
clearMenuItem.setMnemonic('c');
clearMenuItem.setText("Clear All");
clearMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearMenuItemActionPerformed(evt);
}
});
fileMenu.add(clearMenuItem);
fileMenu.add(jSeparator4);
exitMenuItem.setMnemonic('x');
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
@ -437,18 +510,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
}
});
simMenu.add(simMenuStop);
simMenu.add(jSeparator3);
jMenuItem4.setText("Point Zero");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
simMenu.add(jMenuItem4);
jMenuItem5.setText("jMenuItem5");
simMenu.add(jMenuItem5);
menuBar.add(simMenu);
@ -464,22 +525,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
});
viewMenu.add(viewTraderListCheckBox);
viewClock.setText("Clock");
viewClock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
viewClockActionPerformed(evt);
}
});
viewMenu.add(viewClock);
jMenuItem3.setText("LogWindow");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
viewMenu.add(jMenuItem3);
jCheckBoxMenuItem1.setText("Orderbook");
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -493,10 +538,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
helpMenu.setMnemonic('h');
helpMenu.setText("Help");
contentMenuItem.setMnemonic('c');
contentMenuItem.setText("Contents");
helpMenu.add(contentMenuItem);
aboutMenuItem.setMnemonic('a');
aboutMenuItem.setText("About");
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
@ -605,43 +646,121 @@ public class NewMDIApplication extends javax.swing.JFrame {
private final LoggerDialog log_d = new LoggerDialog(this, false);
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
log_d.setVisible(!log_d.isShowing());
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
JFileChooser fc = getFileChooser();
while (true) {
if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
return;
}
try {
File f = fc.getSelectedFile();
Globals.loadFile(f);
String workdir = fc.getCurrentDirectory().getAbsolutePath();
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, f.getAbsolutePath());
setTitle(f.getName());
return;
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_openMenuItemActionPerformed
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
// initialize a JFileChose with worging directory and extension
private JFileChooser getFileChooser() {
JFileChooser fc = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("SeSim Files", "sesim");
fc.setFileFilter(filter);
String workdir = Globals.prefs.get(Globals.PrefKeys.WORKDIR, "");
fc.setCurrentDirectory(new File(workdir));
FileNameExtensionFilter sesim_filter = new FileNameExtensionFilter("SeSim Files", Globals.SESIM_FILEEXTENSION);
fc.setFileFilter(sesim_filter);
return fc;
}
@Override
public final void setTitle(String filename) {
String name;
name = Globals.SESIM_APPTITLE;
if (!"".equals(filename)) {
name += " (" + filename + ")";
}
super.setTitle(name);
}
private void saveFile(boolean saveAs) {
JFileChooser fc = getFileChooser();
FileFilter sesim_filter = fc.getFileFilter();
while (true) {
String current_file = Globals.prefs.get(Globals.PrefKeys.CURRENTFILE, "");
File fobj;
if (saveAs || "".equals(current_file)) {
if (!"".equals(current_file)) {
fobj = new File(current_file);
fc.setSelectedFile(fobj);
fc.setCurrentDirectory(fobj);
}
saveAs = true;
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
return;
}
} else {
fobj = new File(current_file);
fc.setSelectedFile(fobj);
fc.setCurrentDirectory(fobj);
}
File f = fc.getSelectedFile();
String workdir = fc.getCurrentDirectory().getAbsolutePath();
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
String fn = f.getAbsolutePath();
if (f.exists() && saveAs) {
String s = String.format("File %s already exists. Do you want to overwrite?", fn);
int dialogResult = JOptionPane.showConfirmDialog(this, s, "Warning", JOptionPane.YES_NO_OPTION);
if (dialogResult != JOptionPane.YES_OPTION) {
continue;
}
}
FileFilter selected_filter = fc.getFileFilter();
if (selected_filter == sesim_filter) {
System.out.printf("Filter", selected_filter.toString());
if (!fn.toLowerCase().endsWith("." + Globals.SESIM_FILEEXTENSION)) {
f = new File(fn + "." + Globals.SESIM_FILEEXTENSION);
}
}
try {
Globals.saveFile(f);
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, fn);
setTitle(f.getName());
return;
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "Can't save file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
return;
}
File f = fc.getSelectedFile();
String[] e = ((FileNameExtensionFilter) fc.getFileFilter()).getExtensions();
System.out.printf("Abs: %s\n", f.getAbsoluteFile());
String fn = f.getAbsolutePath();
if (!f.getAbsolutePath().endsWith(e[0])) {
f = new File(f.getAbsolutePath() + "." + e[0]);
}
Globals.saveFile(f);
System.out.printf("Sel File: %s \n", f.getAbsolutePath());
}
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
this.saveFile(true);
}//GEN-LAST:event_saveAsMenuItemActionPerformed
private void editExchangeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editExchangeMenuItemActionPerformed
@ -651,15 +770,29 @@ public class NewMDIApplication extends javax.swing.JFrame {
}//GEN-LAST:event_editExchangeMenuItemActionPerformed
private void viewClockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewClockActionPerformed
ClockDialog cd = new ClockDialog(this, true);
cd.setVisible(rootPaneCheckingEnabled);
private void resetToDefaults(){
InputStream is = getClass().getResourceAsStream("/resources/files/defaultcfg.json");
String df = new Scanner(is, "UTF-8").useDelimiter("\\A").next();
}//GEN-LAST:event_viewClockActionPerformed
try {
Globals.loadString(df);
} catch (IOException ex) {
JOptionPane.showMessageDialog(this, "Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMenuItem1ActionPerformed
}
}
private void resetToDefaultsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetToDefaultsMenuItemActionPerformed
int dialogResult = JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning", JOptionPane.YES_NO_OPTION);
if (dialogResult != JOptionPane.YES_OPTION) {
return;
}
this.resetToDefaults();
}//GEN-LAST:event_resetToDefaultsMenuItemActionPerformed
private void simMenuStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuStartActionPerformed
startSim();
@ -695,37 +828,58 @@ public class NewMDIApplication extends javax.swing.JFrame {
jd.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
Globals.se.pointZero();
}//GEN-LAST:event_jMenuItem4ActionPerformed
TraderListDialog tld = null;
private void viewTraderListCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewTraderListCheckBoxActionPerformed
System.out.printf("Trwindow: %s\n", Boolean.toString(this.viewTraderListCheckBox.getState()));
if (this.viewTraderListCheckBox.getState()) {
if (tld == null) {
tld = new TraderListDialog(this, false);
tld.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
viewTraderListCheckBox.setState(false);
System.out.printf("Set menu false\n");
}
});
javax.swing.SwingUtilities.invokeLater(() -> {
System.out.printf("Trwindow: %s\n", Boolean.toString(this.viewTraderListCheckBox.getState()));
if (this.viewTraderListCheckBox.getState()) {
if (tld == null) {
tld = new TraderListDialog(this, false);
tld.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
viewTraderListCheckBox.setState(false);
System.out.printf("Set menu false\n");
}
});
}
tld.setVisible(true);
} else if (tld != null) {
System.out.printf("Set visible = false\n");
tld.setVisible(false);
}
tld.setVisible(true);
} else if (tld != null) {
System.out.printf("Set visible = false\n");
tld.setVisible(false);
}
});
}//GEN-LAST:event_viewTraderListCheckBoxActionPerformed
private void accelSpinnerPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_accelSpinnerPropertyChange
System.out.printf("Accel Spinner PRop Change\n");
// System.out.printf("Accel Spinner PRop Change\n");
}//GEN-LAST:event_accelSpinnerPropertyChange
private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed
saveFile(false);
}//GEN-LAST:event_saveMenuItemActionPerformed
private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeMenuItemActionPerformed
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
setTitle("");
}//GEN-LAST:event_closeMenuItemActionPerformed
private void clearMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearMenuItemActionPerformed
int dialogResult = JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning", JOptionPane.YES_NO_OPTION);
if (dialogResult != JOptionPane.YES_OPTION) {
return;
}
Globals.clearAll();
}//GEN-LAST:event_clearMenuItemActionPerformed
/**
* @param args the command line arguments
* @throws java.lang.IllegalAccessException
@ -735,37 +889,40 @@ public class NewMDIApplication extends javax.swing.JFrame {
System.out.printf("Main called\n");
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[]gs = ge.getScreenDevices();
for (GraphicsDevice d:gs){
System.out.printf("ID %s\n",d.getIDstring());
GraphicsDevice[] gs = ge.getScreenDevices();
for (GraphicsDevice d : gs) {
System.out.printf("ID %s\n", d.getIDstring());
}
//System.exit(0);
//System.exit(0);
Globals.initGlobals();
//System.exit(0);
Globals.se = new Exchange();
Class<?> c = sesim.Exchange.class;
Globals.prefs = Preferences.userNodeForPackage(c);
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
JDialog.setDefaultLookAndFeelDecorated(true);
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
System.out.printf("In run method now\n");
String x = new java.io.File(NewMDIApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString(); //.getName();
String x = new java.io.File(SeSimApplication.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath()).toString(); //.getName();
System.out.printf("Creating Application\n");
new NewMDIApplication().setVisible(true);
new SeSimApplication().setVisible(true);
}
});
}
@ -775,8 +932,9 @@ public class NewMDIApplication extends javax.swing.JFrame {
private javax.swing.JSpinner accelSpinner;
private gui.MainChart chart;
private javax.swing.JScrollPane chartSrollPane;
private javax.swing.JMenuItem clearMenuItem;
private gui.Clock clock;
private javax.swing.JMenuItem contentMenuItem;
private javax.swing.JMenuItem closeMenuItem;
private javax.swing.JMenuItem deleteMenuItem;
private javax.swing.JMenuItem editExchangeMenuItem;
private javax.swing.JMenu editMenu;
@ -787,15 +945,12 @@ public class NewMDIApplication extends javax.swing.JFrame {
private javax.swing.JButton jButton2;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JPopupMenu.Separator jSeparator3;
private javax.swing.JPopupMenu.Separator jSeparator4;
private javax.swing.JPopupMenu.Separator jSeparator5;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSplitPane jSplitPane2;
private javax.swing.JSplitPane jSplitPane3;
@ -808,6 +963,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
private gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
private javax.swing.JMenuItem pasteMenuItem;
private gui.orderbook.QuoteVertical quoteVertical1;
private javax.swing.JMenuItem resetToDefaultsMenuItem;
private javax.swing.JButton runButton;
private javax.swing.JMenuItem saveAsMenuItem;
private javax.swing.JMenuItem saveMenuItem;
@ -817,7 +973,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
private javax.swing.JMenuItem simMenuStop;
private gui.Statistics statistics1;
private javax.swing.JButton stopButton;
private javax.swing.JMenuItem viewClock;
private javax.swing.JMenu viewMenu;
private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox;
// End of variables declaration//GEN-END:variables

View File

@ -3,8 +3,8 @@
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder/>
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/>
</Border>
</Property>
</Properties>
@ -23,13 +23,82 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="labelHigh" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="labelLow" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tradesLabel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="302" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="280" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelHigh" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelLow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tradesLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="235" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Trades:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Heigh:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Low:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelHigh">
<Properties>
<Property name="text" type="java.lang.String" value="100.00"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelLow">
<Properties>
<Property name="text" type="java.lang.String" value="50.00"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="tradesLabel">
<Properties>
<Property name="text" type="java.lang.String" value="0"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -25,6 +25,10 @@
*/
package gui;
import java.util.Timer;
import java.util.TimerTask;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
@ -36,6 +40,29 @@ public class Statistics extends javax.swing.JPanel {
*/
public Statistics() {
initComponents();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
Exchange.Statistics s = Globals.se.getStatistics();
tradesLabel.setText(String.format("%d", s.trades));
if (s.heigh == null) {
labelHigh.setText("--");
} else {
labelHigh.setText(Globals.se.getMoneyFormatter().format(s.heigh));
}
if (s.low == null) {
labelLow.setText("--");
} else {
labelLow.setText(Globals.se.getMoneyFormatter().format(s.low));
}
}
}, 1000, 1000);
}
/**
@ -47,21 +74,74 @@ public class Statistics extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
labelHigh = new javax.swing.JLabel();
labelLow = new javax.swing.JLabel();
tradesLabel = new javax.swing.JLabel();
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jLabel1.setText("Trades:");
jLabel2.setText("Heigh:");
jLabel3.setText("Low:");
labelHigh.setText("100.00");
labelLow.setText("50.00");
tradesLabel.setText("0");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 380, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelHigh))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelLow))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tradesLabel)))
.addContainerGap(302, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 280, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(labelHigh))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(labelLow))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(tradesLabel))
.addContainerGap(235, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel labelHigh;
private javax.swing.JLabel labelLow;
private javax.swing.JLabel tradesLabel;
// End of variables declaration//GEN-END:variables
}

View File

@ -24,7 +24,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="traderListPanel22" alignment="0" pref="922" max="32767" attributes="0"/>
<Component id="traderListPanel22" alignment="0" pref="714" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">

View File

@ -1,5 +1,7 @@
package gui;
import java.awt.Dialog;
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
@ -40,7 +42,7 @@ public class TraderListDialog extends javax.swing.JDialog {
public TraderListDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
// this.setLocationRelativeTo(MainWin.instance);
setLocationRelativeTo(parent);
}
/**
@ -61,7 +63,7 @@ public class TraderListDialog extends javax.swing.JDialog {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE)
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 714, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

View File

@ -31,6 +31,9 @@ import gui.tools.NummericCellRenderer;
import java.awt.Component;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
@ -121,15 +124,26 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
model = (DefaultTableModel) this.list.getModel();
trader_column = list.getColumnModel().getColumn(0);
list.getColumnModel().getColumn(1).setCellRenderer(new NummericCellRenderer(3));
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
cfgChanged();
// Globals.se.addBookReceiver(Exchange.OrderType.BUYLIMIT, this);
Globals.addCfgListener(this);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// System.out.printf("Update order book\n");
// UpdateOrderBook();
}
}, 1000, 1000);
}
boolean oupdate = false;
boolean new_oupdate = false;
long ouctr = 0;
void oupdater() {
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
model.setRowCount(ob.size());
@ -141,24 +155,33 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
row++;
}
oupdate = false;
synchronized (this) {
oupdate = new_oupdate;
new_oupdate = false;
}
if (oupdate) {
SwingUtilities.invokeLater(() -> {
oupdater();
});
}
}
@Override
public synchronized void UpdateOrderBook() {
public void UpdateOrderBook() {
if (oupdate) {
new_oupdate=true;
return;
synchronized (this) {
if (oupdate) {
new_oupdate = true;
return;
}
oupdate = true;
}
oupdate = true;
SwingUtilities.invokeLater(() -> {
oupdater();
});
}

View File

@ -0,0 +1,60 @@
{
"traders": [
{
"Money": "1000000.0",
"Strategy": "SimpleRandom",
"Enabled": "true",
"Count": "1",
"Shares": "10000.0",
"Name": "Alice"
},
{
"Money": "10000.0",
"Strategy": "SimpleRandom",
"Enabled": "true",
"Count": "1",
"Shares": "100.0",
"Name": "Bob"
}
],
"strategies": {"SimpleRandom": {
"sell_wait": [
10000,
50000
],
"initla_delay": [
0,
5
],
"sell_limit": [
-2,
2
],
"sell_wait_after": [
0,
0
],
"buy_wait": [
10000,
50000
],
"sell_volume": [
100,
100
],
"buy_wait_after": [
0,
0
],
"buy_volume": [
100,
100
],
"buy_limit": [
-2,
2
],
"base": "traders.RandomTraderA"
}},
"version": 0.1
}

View File

@ -29,18 +29,18 @@ import org.json.JSONObject;
import sesim.Scheduler.TimerTaskRunner;
/**
*
*
* @author 7u83 <7u83@mail.ru>
*/
public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRunner {
protected double account_id;
protected Exchange se;
protected AutoTraderConfig config;
// protected AutoTraderConfig config;
protected String name;
public AutoTraderBase(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
/* public AutoTraderBase(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
account_id = se.createAccount(money, shares);
Exchange.Account a = se.getAccount(account_id);
@ -51,7 +51,7 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRu
this.id = id;
}
*/
public AutoTraderBase() {
se = null;
id = 0;
@ -65,7 +65,8 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRu
return name;
}
// @Override
@Override
public long getID() {
return id;
}
@ -75,6 +76,7 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRu
return se.getAccount(account_id);
}
@Override
public void init(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
this.account_id = se.createAccount(money, shares);
se.getAccount(account_id).owner = this;

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2017, tobias
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import javax.swing.JPanel;
import org.json.JSONObject;
/**
*
* @author 7u83
*/
public abstract interface AutoTraderConfig {
public abstract OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares);
public abstract String getDisplayName();
public abstract AutoTraderGui getGui();
public abstract JSONObject getConfig();
public abstract void putConfig(JSONObject cfg);
public abstract boolean getDevelStatus();
}

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2017, tobias
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import org.json.JSONObject;
/**
*
* @author tobias
*/
public abstract class AutoTraderConfigBase implements AutoTraderConfig{
@Override
public boolean getDevelStatus() {
return true;
}
}

View File

@ -29,7 +29,7 @@ import javax.swing.JDialog;
import org.json.JSONObject;
/**
*
* Interface for auto traders
* @author 7u83 <7u83@mail.ru>
*/
public interface AutoTraderInterface {
@ -38,16 +38,42 @@ public interface AutoTraderInterface {
public abstract String getDisplayName();
/**
* Get a graphical user interface to configure the auto trader.
* @return an AutoTraderGui object or null if there is no graphical
* user interface available.
*/
public abstract AutoTraderGui getGui();
public abstract JDialog getGuiConsole();
/**
* Get current configuration of the auto trader as JSON object.
* @return JSONObject containing the configuration
*/
public abstract JSONObject getConfig();
/**
* Set the configuration for auto trader by a JSON object.
* @param cfg the configuration
*/
public abstract void putConfig(JSONObject cfg);
/**
* Return the name of the auto trader.
* @return name
*/
public abstract String getName();
/**
* Initialize the auto trader
* @param se Exechange to trade on
* @param id
* @param name Name of auto trader
* @param money Money
* @param shares Number of shares
* @param cfg
*/
public void init(Exchange se, long id, String name, double money, double shares, JSONObject cfg);
public Exchange.Account getAccount();

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import java.util.SortedSet;
import java.util.List;
import java.util.ArrayList;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AutoTraderList {
SortedSet <OldAutoTrader> traders;
AutoTraderList(){
}
List getTraders(){
return new ArrayList();
}
}

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AutoTraderRunConfig {
AutoTraderConfig config;
int num_traders;
String trader_name;
double initial_money;
double initial_shares;
}

View File

@ -1,5 +1,6 @@
package sesim;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentHashMap;
@ -19,7 +20,9 @@ public class Exchange {
ConcurrentLinkedQueue<Order> order_queue = new ConcurrentLinkedQueue();
private double money_df = 10000;
private int money_decimals=2;
DecimalFormat money_formatter;
/**
* Set the number of decimals used with money
*
@ -27,9 +30,13 @@ public class Exchange {
*/
public void setMoneyDecimals(int n) {
money_df = Math.pow(10, n);
money_decimals=n;
money_formatter=getFormatter(n);
}
private double shares_df = 1;
private double shares_decimals=0;
private DecimalFormat shares_formatter;
/**
* Set the number of decimals for shares
@ -38,6 +45,8 @@ public class Exchange {
*/
public void setSharesDecimals(int n) {
shares_df = Math.pow(10, n);
shares_decimals=n;
shares_formatter = getFormatter(n);
}
public double roundToDecimals(double val, double f) {
@ -51,6 +60,28 @@ public class Exchange {
public double roundMoney(double money) {
return roundToDecimals(money, money_df);
}
public DecimalFormat getFormatter(int n){
DecimalFormat formatter;
String s = "#0.";
if (n == 0) {
s = "#";
} else {
for (int i = 0; i < n; i++) {
s = s + "0";
}
}
return new DecimalFormat(s);
}
public DecimalFormat getMoneyFormatter(){
return money_formatter;
}
public DecimalFormat getSharesFormatter(){
return shares_formatter;
}
/**
* Definition of order types
@ -389,7 +420,8 @@ public class Exchange {
traders = new ArrayList();
num_trades = 0;
statistics = new Statistics();
//num_trades = 0;
this.ohlc_data = new HashMap();
@ -416,28 +448,34 @@ public class Exchange {
public long trades;
public long orders;
public Double heigh;
public Double low;
void reset() {
public final void reset() {
trades = 0;
heigh=null;
low=null;
}
Statistics() {
reset();
}
};
Statistics statistics;
long num_trades = 0;
long num_orders = 0;
// long num_trades = 0;
// long num_orders = 0;
public Statistics getStatistics() {
Statistics s = new Statistics();
return statistics;
/* Statistics s = new Statistics();
s.trades = num_trades;
s.orders = num_orders;
return s;
*/
}
@ -759,8 +797,8 @@ public class Exchange {
// long time = 0;
//double theprice = 12.9;
// long orderid = 1;
double lastprice = 100.0;
long lastsvolume;
//double lastprice = 100.0;
// long lastsvolume;
// private final Locker tradelock = new Locker();
public ArrayList<Order> getOrderBook(OrderType type, int depth) {
@ -935,6 +973,29 @@ public class Exchange {
removeOrderIfExecuted(b);
}
void addQuoteToHistory(Quote q){
if (statistics.heigh==null){
statistics.heigh=q.price;
}
else if (statistics.heigh<q.price){
statistics.heigh=q.price;
}
if (statistics.low==null){
statistics.low=q.price;
}
else if(statistics.low>q.price){
statistics.low=q.price;
}
quoteHistory.add(q);
updateOHLCData(q);
updateQuoteReceivers(q);
}
/**
*
*/
@ -1016,7 +1077,8 @@ public class Exchange {
volume_total += volume;
money_total += price * volume;
num_trades++;
// num_trades++;
statistics.trades++;
this.checkSLOrders(price);
@ -1030,10 +1092,12 @@ public class Exchange {
q.volume = volume_total;
q.time = timer.currentTimeMillis();
this.quoteHistory.add(q);
this.updateOHLCData(q);
this.updateQuoteReceivers(q);
addQuoteToHistory(q);
//this.quoteHistory.add(q);
//this.updateOHLCData(q);
//this.updateQuoteReceivers(q);
}
@ -1058,12 +1122,7 @@ public class Exchange {
long buy_failed = 0;
long sell_failed = 0;
public void ua(Account a){
//.money=1000.0;
// a.shares=100;
}
/**
*
@ -1077,6 +1136,7 @@ public class Exchange {
Account a = accounts.get(account_id);
if (a == null) {
System.out.printf("Order not places account\n");
return -1;
}
@ -1095,7 +1155,7 @@ public class Exchange {
buy_failed++;
break;
}
System.out.printf("Order ffailed %f %f \n",o.volume,o.limit);
return -1;
@ -1104,7 +1164,9 @@ public class Exchange {
// System.out.printf("Getting executor in create Order\n", Thread.currentThread().getId());
synchronized (executor) {
num_orders++;
//num_orders++;
statistics.orders++;
addOrderToBook(o);
a.orders.put(o.id, o);
a.update(o);
@ -1197,7 +1259,7 @@ public class Exchange {
return ad;
}
*/
public ArrayList<OrderData> getOpenOrders(double account_id) {
/* public ArrayList<OrderData> getOpenOrders(double account_id) {
Account a = accounts.get(account_id);
if (a == null) {
@ -1219,5 +1281,6 @@ public class Exchange {
return al;
}
*/
}

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-104,0,0,1,67"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="3"/>
</Layout>
</Form>

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2017, tobias
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
/**
*
* @author tobias
*/
public class NewJPanel extends javax.swing.JPanel {
/**
* Creates new form NewJPanel
*/
public NewJPanel() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS));
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

View File

@ -1,95 +0,0 @@
/*
* Copyright (c) 2017, 7u83
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import org.json.JSONObject;
import sesim.Exchange.Account;
/**
*
* @author 7u83
*/
public abstract class OldAutoTrader implements Scheduler.TimerTaskRunner {
protected double account_id;
protected Exchange se;
protected AutoTraderConfig config;
protected String name;
public OldAutoTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
account_id = se.createAccount(money, shares);
Account a = se.getAccount(account_id);
// a.owner=this;
this.se = se;
this.config = config;
this.name = name;
this.id=id;
}
public OldAutoTrader(){
se=null;
id=0;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public long getID(){
return id;
}
private long id;
public Exchange.Account getAccount(){
return se.getAccount(account_id);
}
public void init(Exchange se,long id,String name, double money, double shares, JSONObject cfg){
this.account_id=se.createAccount(money, shares);
// se.getAccount(account_id).owner=this;
this.se = se;
this.name = name;
this.id=id;
}
public Exchange getSE(){
return se;
}
public abstract void start();
}

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class OrderData {
public long id;
public double limit;
public double volume;
public double executed;
}

View File

@ -232,8 +232,9 @@ public class Scheduler extends Thread {
return task;
}
public void XXXrescheduleTimerTask(TimerTaskDef task, long time) {
public void rescheduleTimerTask(TimerTaskDef task, long time) {
long evtime = time + currentTimeMillis();
task.newevtime=evtime;
set_tasks.add(task);
synchronized (this) {
@ -267,6 +268,7 @@ public class Scheduler extends Thread {
// HashMap<TimerTaskDef, Long> tasks = new HashMap<>();
private boolean addTimerTask(TimerTaskDef e) {
// System.out.printf("Add TimerTask %d %d\n",e.curevtime,e.newevtime);
// long evtime = time + currentTimeMillis();
SortedSet<TimerTaskDef> s = event_queue.get(e.newevtime);
if (s == null) {
@ -292,9 +294,10 @@ public class Scheduler extends Thread {
// if (evtime == null) {
// return;
// }
System.out.printf("Cancel my %d\n", e.id);
SortedSet<TimerTaskDef> s = event_queue.get(e.curevtime);
if (s == null) {
System.out.printf("My not found\n");
return;
}
@ -388,6 +391,8 @@ public class Scheduler extends Thread {
while (!set_tasks.isEmpty()) {
TimerTaskDef td = set_tasks.poll();
System.out.printf("There is a set task %d %d\n",td.curevtime,td.newevtime);
this.cancelMy(td);
this.addTimerTask(td);

View File

@ -31,8 +31,8 @@ import javax.swing.JDialog;
import org.json.JSONObject;
import sesim.AutoTraderBase;
import sesim.AutoTraderConfigBase;
import sesim.AutoTraderConfig;
//import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
import sesim.Exchange;
@ -45,16 +45,17 @@ import sesim.Exchange.OrderStatus;
*/
public class ManTrader extends AutoTraderBase implements AccountListener, AutoTraderInterface{
public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
// super(se, id, name, money, shares, null);
super();
}
// public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
// // super(se, id, name, money, shares, null);
// super();
// }
public ManTrader() {
super();
}
@Override
public void init(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
super.init(se, id, name, money, shares, cfg);
getAccount().setListener(this);
@ -115,9 +116,9 @@ public class ManTrader extends AutoTraderBase implements AccountListener, AutoTr
@Override
public void accountUpdated(Exchange.Account a, Exchange.Order o) {
//this.consoleDialog.cons
System.out.printf("AccountListener called\n");
//System.out.printf("AccountListener called\n");
System.out.printf("%d %s\n", o.getID(), o.getOrderStatus().toString());
//System.out.printf("%d %s\n", o.getID(), o.getOrderStatus().toString());
if (o.getOrderStatus()==OrderStatus.CLOSED){
o.getAccount().getOrders().put(o.getID(), o);

View File

@ -67,4 +67,4 @@
<Component class="traders.ManTrader.AccountBalance" name="accountBalance1">
</Component>
</SubComponents>
</Form>
</Form>

View File

@ -36,12 +36,16 @@ public class ManTraderConsoleDialog extends javax.swing.JDialog {
/**
* Creates new form ManTraderConsole
* @param parent
* @param modal
* @param account
*/
public ManTraderConsoleDialog(java.awt.Frame parent, boolean modal, Account account) {
super(parent, modal);
initComponents();
this.ordersList.initOrderList(account);
this.setTitle(account.getOwner().getName()+" - Trading Console");
this.setLocationRelativeTo(parent);
}
public gui.OpenOrdersList getOrderList(){

View File

@ -37,6 +37,7 @@ import sesim.Exchange;
import sesim.Exchange.Account;
import sesim.Exchange.AccountListener;
import sesim.Exchange.OrderStatus;
import sesim.Exchange.OrderType;
import sesim.Quote;
/**
@ -50,12 +51,12 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-2f, 2f};
public Long[] sell_wait = {10000L, 50000L};
public Long[] wait_after_sell = {1000L, 30000L};
public Long[] wait_after_sell = {0L, 0L};
public Float[] buy_volume = {100f, 100f};
public Float[] buy_limit = {-2f, 2f};
public Long[] buy_wait = {10000L, 50000L};
public Long[] wait_after_buy = {10L, 30L};
public Long[] wait_after_buy = {0L, 0L};
final String INITIAL_DELAY = "initla_delay";
final String SELL_VOLUME = "sell_volume";
@ -73,18 +74,24 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
a.setListener(this);
long delay = (long) (getRandom(initial_delay[0], initial_delay[1]) * 1000);
setStatus("Inital delay: %d\n", delay);
setStatus("Inital delay: %d", delay);
timerTask = se.timer.startTimerTask(this, delay);
}
boolean intask = false;
@Override
public long timerTask() {
// System.out.printf("Enter TimerTask for %d / %d\n", System.identityHashCode(this), Thread.currentThread().getId());
intask = true;
owait = null;
sesim.Exchange.Account a = se.getAccount(account_id);
// System.out.printf("Have Account %d\n", Thread.currentThread().getId());
Globals.se.ua(a);
long rc = this.doTrade();
setStatus("Sleeping for %d ms", rc);
intask = false;
setStatus("Return fromtask %d", rc);
if (owait != null)
return owait;
return rc;
}
@ -117,8 +124,8 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
}
void setStatus(String format, Object... arguments) {
// String s = String.format(format, arguments);
// System.out.printf("%s: %s\n", this.getName(), s);
// String s = String.format(format, arguments);
// System.out.printf("%s: %s\n", this.getName(), s);
}
private Float[] to_float(JSONArray a) {
@ -140,6 +147,8 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
}
Long owait = null;
@Override
public void putConfig(JSONObject cfg) {
if (cfg == null) {
@ -194,20 +203,19 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
@Override
public void accountUpdated(Account a, Exchange.Order o) {
// System.out.printf("Order what %s %d\n", o.getOrderStatus().toString(), Thread.currentThread().getId());
setStatus("Account update -%s ", o.getOrderStatus().toString());
setStatus("In Task: %s", Boolean.toString(this.intask));
//System.out.printf("Order updated %s %d\n", o.getOrderStatus().toString(), Thread.currentThread().getId());
if (o.getOrderStatus() == OrderStatus.CLOSED) {
// System.out.printf("Enteter canel timer %d\n", Thread.currentThread().getId());
// se.timer.cancelTimerTask(this);
//System.out.printf("back from canel timer %d\n", System.identityHashCode(this));
//System.exit(0);
Long w = waitAfterOrder();
if (!intask) {
Long w = waitAfterOrder();
setStatus("Reschedule %d", w);
se.timer.rescheduleTimerTask(timerTask, w);
} else {
owait = waitAfterOrder();
}
setStatus("Order closed, %s", o.getType().toString());
// System.out.printf("We have now to wait for %d\n", w);
//timerTask = se.timer.startTimerTask(this, w);
// se.timer.XXXrescheduleTimerTask(timerTask, w);
}
// System.out.printf("Updatetd Account\n", "");
@ -229,11 +237,12 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
Action mode = Action.RANDOM;
Integer doTrade1(Action a) {
setStatus("doTrade1 with action %s", a.toString());
switch (a) {
case BUY: {
boolean rc = doBuy();
if (rc) {
setStatus("dobuy");
mode = Action.BUY;
return getRandom(buy_wait);
}
@ -244,6 +253,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
case SELL: {
boolean rc = doSell();
if (rc) {
setStatus("dosell");
mode = Action.SELL;
return getRandom(sell_wait);
@ -314,7 +324,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
setStatus("No trade possible, returning 5000");
//System.out.printf("All ha s failed\n");
return 5000;
return 5007;
}
setStatus("Current mode is %s", mode.toString());
@ -434,12 +444,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
// }
// System.out.printf("Create a Sell Order %f %f!!!!\n", volume, limit);
long rc = se.createOrder(account_id, type, volume, limit);
if (rc == -1) {
//System.out.printf("Sell failed %f, %f (%f)\n", volume, limit, ad.getMoney());
return false;
}
return true;
return rc != -1;
}

View File

@ -26,23 +26,18 @@
package traders;
import gui.Globals;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import javax.swing.JDialog;
import org.json.JSONArray;
import org.json.JSONObject;
//import sesim.AccountData;
import sesim.AutoTraderBase;
import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.Exchange;
import sesim.Exchange.Account;
import sesim.Exchange.Order;
import sesim.OrderData;
import sesim.Quote;
/**
@ -158,7 +153,7 @@ public class RandomTraderB extends AutoTraderBase {
@Override
public boolean getDevelStatus() {
return false;
return true;
}
public long cancelOrders() {

View File

@ -1,176 +0,0 @@
/*
* Copyright (c) 2017, 7u83
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package traders;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AutoTraderConfigBase;
import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.Exchange;
import sesim.OldAutoTrader;
/**
*
* @author 7u83
*/
public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTraderConfig {
public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-0.1f, 0.10101f};
public Long[] sell_wait = {10000L, 50000L};
public Long[] wait_after_sell = {1000L, 30000L};
public Float[] buy_volume = {100f, 100f};
public Float[] buy_limit = {-0.1f, 0.10101f};
public Long[] buy_wait = {10000L, 50000L};
public Long[] wait_after_buy = {10L, 30L};
@Override
public OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
if (cfg != null) {
this.putConfig(cfg);
}
return null;
//return new traders.RandomTrader(se, id, name, money, shares, this);
}
@Override
public String getDisplayName() {
return "Random A";
}
@Override
public AutoTraderGui getGui() {
return null;
//return new RandomTraderGui(this);
}
final String SELL_VOLUME = "sell_volume";
final String BUY_VOLUME = "buy_volume";
final String SELL_LIMIT = "sell_limit";
final String BUY_LIMIT = "buy_limit";
final String SELL_WAIT = "sell_wait";
final String BUY_WAIT = "buy_wait";
final String WAIT_AFTER_SELL = "sell_wait_after";
final String WAIT_AFTER_BUY = "buy_wait_after";
@Override
public JSONObject getConfig() {
JSONObject jo = new JSONObject();
jo.put(SELL_VOLUME, sell_volume);
jo.put(BUY_VOLUME, buy_volume);
jo.put(SELL_LIMIT, sell_limit);
jo.put(BUY_LIMIT, buy_limit);
jo.put(SELL_WAIT, sell_wait);
jo.put(BUY_WAIT, buy_wait);
jo.put(WAIT_AFTER_SELL, wait_after_sell);
jo.put(WAIT_AFTER_BUY, wait_after_buy);
jo.put("base",this.getClass().getCanonicalName());
return jo;
}
/* private <T extends Number> T to(Double o){
if (Float==T){
System.out.printf("Double ret %", o.floatValue());
return new T(3);
}
return null;
}
*/
private Float[] to_float(JSONArray a) {
Float[] ret = new Float[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = new Float(a.getDouble(i));
}
return ret;
}
private Integer[] to_integer(JSONArray a) {
Integer[] ret = new Integer[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = a.getInt(i);
}
return ret;
}
private Long[] to_long(JSONArray a) {
Long[] ret = new Long[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = a.getLong(i);
}
return ret;
}
private Number[] to_arn(JSONArray a) {
Number[] ret = new Number[a.length()];
// Float x[] = new Float[2];
for (int i = 0; i < a.length(); i++) {
ret[i] = (Number) a.get(i);
}
return ret;
}
public void putConfig(JSONObject cfg) {
if (cfg == null) {
return;
}
// System.out.printf("Putconfig %s\n", cfg.toString(4));
String cname = cfg.get(SELL_VOLUME).getClass().getName();
// JSONArray a = cfg.getJSONArray(SELL_VOLUME);
// System.out.printf("Array = %s \n", cname);
sell_volume = to_float(cfg.getJSONArray(SELL_VOLUME));
buy_volume = to_float(cfg.getJSONArray(BUY_VOLUME));
sell_limit = to_float(cfg.getJSONArray(SELL_LIMIT));
buy_limit = to_float(cfg.getJSONArray(BUY_LIMIT));
sell_wait = to_long(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_long(cfg.getJSONArray(BUY_WAIT));
wait_after_sell = to_long(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_long(cfg.getJSONArray(WAIT_AFTER_BUY));
}
@Override
public boolean getDevelStatus() {
return false;
}
}