fixed some bugs with randomtrader and schedduler
This commit is contained in:
parent
4dcc9d8d56
commit
9653a789f1
@ -1,4 +1,4 @@
|
|||||||
#Tue, 11 Apr 2017 07:53:43 +0200
|
#Tue, 11 Apr 2017 19:27:26 +0200
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
@ -29,6 +29,7 @@ import java.awt.Dialog;
|
|||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
@ -46,6 +47,7 @@ import java.util.logging.Logger;
|
|||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
|
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@ -69,7 +71,28 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
* Creates new form NewMDIApplication
|
* Creates new form NewMDIApplication
|
||||||
*/
|
*/
|
||||||
public SeSimApplication() {
|
public SeSimApplication() {
|
||||||
|
|
||||||
initComponents();
|
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("");
|
setTitle("");
|
||||||
boolean init = Globals.prefs.getBoolean("initilized", false);
|
boolean init = Globals.prefs.getBoolean("initilized", false);
|
||||||
if (!init){
|
if (!init){
|
||||||
@ -77,7 +100,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
Globals.prefs.putBoolean("initilized", true);
|
Globals.prefs.putBoolean("initilized", true);
|
||||||
}
|
}
|
||||||
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
||||||
this.setLocationRelativeTo(null);
|
//this.setLocationRelativeTo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoTraderInterface createTraderNew(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
AutoTraderInterface createTraderNew(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
||||||
@ -859,6 +882,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
System.out.printf("ID %s\n", d.getIDstring());
|
System.out.printf("ID %s\n", d.getIDstring());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//System.exit(0);
|
||||||
|
|
||||||
//System.exit(0);
|
//System.exit(0);
|
||||||
Globals.initGlobals();
|
Globals.initGlobals();
|
||||||
@ -884,6 +908,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
|||||||
.getPath()).toString(); //.getName();
|
.getPath()).toString(); //.getName();
|
||||||
|
|
||||||
System.out.printf("Creating Application\n");
|
System.out.printf("Creating Application\n");
|
||||||
|
|
||||||
new SeSimApplication().setVisible(true);
|
new SeSimApplication().setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -37,6 +37,7 @@ import sesim.Exchange;
|
|||||||
import sesim.Exchange.Account;
|
import sesim.Exchange.Account;
|
||||||
import sesim.Exchange.AccountListener;
|
import sesim.Exchange.AccountListener;
|
||||||
import sesim.Exchange.OrderStatus;
|
import sesim.Exchange.OrderStatus;
|
||||||
|
import sesim.Exchange.OrderType;
|
||||||
import sesim.Quote;
|
import sesim.Quote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,14 +79,19 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean intask = false;
|
boolean intask = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long timerTask() {
|
public long timerTask() {
|
||||||
intask = true;
|
intask = true;
|
||||||
|
owait = null;
|
||||||
sesim.Exchange.Account a = se.getAccount(account_id);
|
sesim.Exchange.Account a = se.getAccount(account_id);
|
||||||
long rc = this.doTrade();
|
long rc = this.doTrade();
|
||||||
setStatus("Sleeping for %d ms", rc);
|
setStatus("Sleeping for %d ms", rc);
|
||||||
intask = false;
|
intask = false;
|
||||||
setStatus("Return fromtask %d", rc);
|
setStatus("Return fromtask %d", rc);
|
||||||
|
|
||||||
|
if (owait != null)
|
||||||
|
return owait;
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -118,8 +124,8 @@ setStatus("Return fromtask %d", rc);
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setStatus(String format, Object... arguments) {
|
void setStatus(String format, Object... arguments) {
|
||||||
String s = String.format(format, arguments);
|
// String s = String.format(format, arguments);
|
||||||
System.out.printf("%s: %s\n", this.getName(), s);
|
// System.out.printf("%s: %s\n", this.getName(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Float[] to_float(JSONArray a) {
|
private Float[] to_float(JSONArray a) {
|
||||||
@ -141,6 +147,8 @@ setStatus("Return fromtask %d", rc);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long owait = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putConfig(JSONObject cfg) {
|
public void putConfig(JSONObject cfg) {
|
||||||
if (cfg == null) {
|
if (cfg == null) {
|
||||||
@ -196,20 +204,18 @@ setStatus("Return fromtask %d", rc);
|
|||||||
@Override
|
@Override
|
||||||
public void accountUpdated(Account a, Exchange.Order o) {
|
public void accountUpdated(Account a, Exchange.Order o) {
|
||||||
setStatus("Account update -%s ", o.getOrderStatus().toString());
|
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());
|
//System.out.printf("Order updated %s %d\n", o.getOrderStatus().toString(), Thread.currentThread().getId());
|
||||||
if (o.getOrderStatus() == OrderStatus.CLOSED) {
|
if (o.getOrderStatus() == OrderStatus.CLOSED) {
|
||||||
|
|
||||||
// System.out.printf("Enteter canel timer %d\n", Thread.currentThread().getId());
|
if (!intask) {
|
||||||
//System.out.printf("back from canel timer %d\n", System.identityHashCode(this));
|
|
||||||
//System.exit(0);
|
|
||||||
// setStatus("Order closed, %s", o.getType().toString());
|
|
||||||
Long w = waitAfterOrder();
|
Long w = waitAfterOrder();
|
||||||
|
|
||||||
// System.out.printf("We have now to wait for %d\n", w);
|
|
||||||
// se.timer.cancelTimerTask(this);
|
|
||||||
// timerTask = se.timer.startTimerTask(this, w);
|
|
||||||
setStatus("Reschedule %d", w);
|
setStatus("Reschedule %d", w);
|
||||||
se.timer.rescheduleTimerTask(timerTask, w);
|
se.timer.rescheduleTimerTask(timerTask, w);
|
||||||
|
} else {
|
||||||
|
owait = waitAfterOrder();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// System.out.printf("Updatetd Account\n", "");
|
// System.out.printf("Updatetd Account\n", "");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user