Some imprements
This commit is contained in:
parent
0c152dca81
commit
cd2d0c65ff
@ -43,13 +43,5 @@
|
|||||||
<exec.executable>java</exec.executable>
|
<exec.executable>java</exec.executable>
|
||||||
</properties>
|
</properties>
|
||||||
</action>
|
</action>
|
||||||
<action>
|
|
||||||
<actionName>build</actionName>
|
|
||||||
<packagings>
|
|
||||||
<packaging>*</packaging>
|
|
||||||
</packagings>
|
|
||||||
<goals>
|
|
||||||
<goal>install</goal>
|
|
||||||
</goals>
|
|
||||||
</action>
|
|
||||||
</actions>
|
</actions>
|
||||||
|
23
pom.xml
23
pom.xml
@ -48,6 +48,11 @@
|
|||||||
<artifactId>AbsoluteLayout</artifactId>
|
<artifactId>AbsoluteLayout</artifactId>
|
||||||
<version>SNAPSHOT</version>
|
<version>SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>webstart-maven-plugin</artifactId>
|
||||||
|
<version>1.0-beta-7</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -62,4 +67,22 @@
|
|||||||
<url>file:${project.basedir}/lib</url>
|
<url>file:${project.basedir}/lib</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<version>1.0-beta-7</version>
|
||||||
|
<artifactId>webstart-maven-plugin</artifactId>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<jnlp>
|
||||||
|
<mainClass>com.cauwersin.SeSim.gui.NewMDIApplication</mainClass>
|
||||||
|
</jnlp>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -487,6 +487,15 @@
|
|||||||
</Constraints>
|
</Constraints>
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="gui.Statistics" name="statistics1">
|
||||||
|
<Constraints>
|
||||||
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||||
|
<JSplitPaneConstraints position="top"/>
|
||||||
|
</Constraint>
|
||||||
|
</Constraints>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -68,7 +68,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
System.out.printf("!!!! creating new\n");
|
|
||||||
String base = cfg.getString("base");
|
String base = cfg.getString("base");
|
||||||
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
|
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
|
||||||
if (ac == null) {
|
if (ac == null) {
|
||||||
@ -114,7 +114,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
for (int i1 = 0; i1 < count; i1++) {
|
for (int i1 = 0; i1 < count; i1++) {
|
||||||
AutoTraderInterface trader;
|
AutoTraderInterface trader;
|
||||||
|
|
||||||
System.out.printf("shoudl create new\n");
|
|
||||||
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
|
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
|
||||||
|
|
||||||
Globals.se.traders.add(trader);
|
Globals.se.traders.add(trader);
|
||||||
@ -166,6 +165,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
chart = new chart.Chart();
|
chart = new chart.Chart();
|
||||||
quoteVertical1 = new gui.orderbook.QuoteVertical();
|
quoteVertical1 = new gui.orderbook.QuoteVertical();
|
||||||
jSplitPane5 = new javax.swing.JSplitPane();
|
jSplitPane5 = new javax.swing.JSplitPane();
|
||||||
|
statistics1 = new gui.Statistics();
|
||||||
menuBar = new javax.swing.JMenuBar();
|
menuBar = new javax.swing.JMenuBar();
|
||||||
fileMenu = new javax.swing.JMenu();
|
fileMenu = new javax.swing.JMenu();
|
||||||
jMenuItem1 = new javax.swing.JMenuItem();
|
jMenuItem1 = new javax.swing.JMenuItem();
|
||||||
@ -319,6 +319,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
jSplitPane3.setLeftComponent(quoteVertical1);
|
jSplitPane3.setLeftComponent(quoteVertical1);
|
||||||
|
|
||||||
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||||
|
jSplitPane5.setTopComponent(statistics1);
|
||||||
|
|
||||||
jSplitPane3.setLeftComponent(jSplitPane5);
|
jSplitPane3.setLeftComponent(jSplitPane5);
|
||||||
|
|
||||||
getContentPane().add(jSplitPane3, java.awt.BorderLayout.CENTER);
|
getContentPane().add(jSplitPane3, java.awt.BorderLayout.CENTER);
|
||||||
@ -801,6 +803,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
private javax.swing.JMenuItem simMenuPause;
|
private javax.swing.JMenuItem simMenuPause;
|
||||||
private javax.swing.JMenuItem simMenuStart;
|
private javax.swing.JMenuItem simMenuStart;
|
||||||
private javax.swing.JMenuItem simMenuStop;
|
private javax.swing.JMenuItem simMenuStop;
|
||||||
|
private gui.Statistics statistics1;
|
||||||
private javax.swing.JButton stopButton;
|
private javax.swing.JButton stopButton;
|
||||||
private javax.swing.JMenuItem viewClock;
|
private javax.swing.JMenuItem viewClock;
|
||||||
private javax.swing.JMenu viewMenu;
|
private javax.swing.JMenu viewMenu;
|
||||||
|
@ -62,7 +62,7 @@ public class TraderListPanel extends javax.swing.JPanel {
|
|||||||
sesim.Quote q = Globals.se.getLastQuoete();
|
sesim.Quote q = Globals.se.getLastQuoete();
|
||||||
double price = q == null ? 0 : q.price;
|
double price = q == null ? 0 : q.price;
|
||||||
|
|
||||||
//DefaultTableModel newmodel = new DefaultTableModel();
|
|
||||||
int size = Globals.se.traders.size();
|
int size = Globals.se.traders.size();
|
||||||
model.setRowCount(size);
|
model.setRowCount(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -141,7 +141,7 @@ public class TraderListPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test() {
|
void ZZtest() {
|
||||||
|
|
||||||
// new javax.swing.table.DefaultTableModel
|
// new javax.swing.table.DefaultTableModel
|
||||||
MyModel m = new MyModel(
|
MyModel m = new MyModel(
|
||||||
|
@ -378,8 +378,11 @@ public class Exchange {
|
|||||||
public TreeSet<Quote> quoteHistory; // = new TreeSet<>();
|
public TreeSet<Quote> quoteHistory; // = new TreeSet<>();
|
||||||
|
|
||||||
final void initExchange() {
|
final void initExchange() {
|
||||||
|
buy_orders = 0;
|
||||||
|
sell_orders = 0;
|
||||||
timer = new Scheduler(); // timer = new Scheduler();
|
timer = new Scheduler(); // timer = new Scheduler();
|
||||||
random = new Random(12);
|
// random = new Random(12);
|
||||||
|
random = new Random();
|
||||||
|
|
||||||
quoteHistory = new TreeSet();
|
quoteHistory = new TreeSet();
|
||||||
accounts = new ConcurrentHashMap<>();
|
accounts = new ConcurrentHashMap<>();
|
||||||
@ -413,6 +416,16 @@ public class Exchange {
|
|||||||
|
|
||||||
public long trades;
|
public long trades;
|
||||||
public long orders;
|
public long orders;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
trades = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Statistics() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Statistics statistics;
|
Statistics statistics;
|
||||||
@ -516,7 +529,7 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Double getBestPrice() {
|
public Double getBestPrice() {
|
||||||
System.out.printf("Get BP\n");
|
System.out.printf("Get BP\n");
|
||||||
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
||||||
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
||||||
|
|
||||||
@ -538,14 +551,14 @@ System.out.printf("Get BP\n");
|
|||||||
// there is bid and ask
|
// there is bid and ask
|
||||||
if (a != null && b != null) {
|
if (a != null && b != null) {
|
||||||
Quote q = new Quote();
|
Quote q = new Quote();
|
||||||
System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
System.out.printf("aaaaa bbbbb %f %f \n", a.limit, b.limit);
|
||||||
// if there is no last quote calculate from bid and ask
|
// if there is no last quote calculate from bid and ask
|
||||||
//if (lq == null) {
|
//if (lq == null) {
|
||||||
double rc =(bid.first().limit + ask.first().limit) / 2.0;
|
double rc = (bid.first().limit + ask.first().limit) / 2.0;
|
||||||
System.out.printf("RCRC2.0: %f\n",rc);
|
System.out.printf("RCRC2.0: %f\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
/*
|
/*
|
||||||
if (lq.price < b.limit) {
|
if (lq.price < b.limit) {
|
||||||
return b.limit;
|
return b.limit;
|
||||||
@ -556,7 +569,7 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
|
|
||||||
}
|
}
|
||||||
return lq.price;
|
return lq.price;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
@ -620,12 +633,12 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
Quote q = new Quote();
|
Quote q = new Quote();
|
||||||
|
|
||||||
// if there is no last quote calculate from bid and ask
|
// if there is no last quote calculate from bid and ask
|
||||||
// if (lq == null) {
|
if (lq == null) {
|
||||||
q.price = (bid.first().limit + ask.first().limit) / 2.0;
|
q.price = (bid.first().limit + ask.first().limit) / 2.0;
|
||||||
return q;
|
return q;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/* if (lq.price < b.limit) {
|
if (lq.price < b.limit) {
|
||||||
q.price = b.limit;
|
q.price = b.limit;
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
@ -634,8 +647,7 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
return lq;
|
return lq;
|
||||||
*/
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
Quote q = new Quote();
|
Quote q = new Quote();
|
||||||
@ -1025,9 +1037,32 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long buy_orders = 0;
|
||||||
|
long sell_orders = 0;
|
||||||
|
|
||||||
private void addOrderToBook(Order o) {
|
private void addOrderToBook(Order o) {
|
||||||
order_books.get(o.type).add(o);
|
order_books.get(o.type).add(o);
|
||||||
|
switch (o.type) {
|
||||||
|
case BUY:
|
||||||
|
case BUYLIMIT:
|
||||||
|
buy_orders++;
|
||||||
|
break;
|
||||||
|
case SELL:
|
||||||
|
case SELLLIMIT:
|
||||||
|
sell_orders++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
// System.out.printf("B/S %d/%d Failed B/S: %d/%d\n", buy_orders, sell_orders,buy_failed,sell_failed);
|
||||||
|
}
|
||||||
|
|
||||||
|
long buy_failed = 0;
|
||||||
|
long sell_failed = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public void ua(Account a){
|
||||||
|
//.money=1000.0;
|
||||||
|
// a.shares=100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1044,9 +1079,25 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Order o = new Order(a, type, volume, limit);
|
Order o = new Order(a, type, volume, limit);
|
||||||
if (o.volume <= 0 || o.limit <= 0) {
|
if (o.volume <= 0 || o.limit <= 0) {
|
||||||
|
|
||||||
|
switch (o.type) {
|
||||||
|
case SELL:
|
||||||
|
case SELLLIMIT:
|
||||||
|
sell_failed++;
|
||||||
|
break;
|
||||||
|
case BUY:
|
||||||
|
case BUYLIMIT:
|
||||||
|
buy_failed++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,6 +1140,24 @@ System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
|
|||||||
public Account getAccount(double account_id) {
|
public Account getAccount(double account_id) {
|
||||||
return accounts.get(account_id);
|
return accounts.get(account_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*public AccountData getAccountData(double account_id) {
|
/*public AccountData getAccountData(double account_id) {
|
||||||
tradelock.lock();
|
tradelock.lock();
|
||||||
|
@ -338,7 +338,7 @@ public class Scheduler extends Thread {
|
|||||||
Object rc = event_queue.remove(t);
|
Object rc = event_queue.remove(t);
|
||||||
|
|
||||||
if (s.size() > 1) {
|
if (s.size() > 1) {
|
||||||
System.out.printf("Events in a row: %d\n", s.size());
|
//System.out.printf("Events in a row: %d\n", s.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<TimerTaskDef> it = s.iterator();
|
Iterator<TimerTaskDef> it = s.iterator();
|
||||||
|
@ -73,7 +73,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
a.setListener(this);
|
a.setListener(this);
|
||||||
|
|
||||||
long delay = (long) (getRandom(initial_delay[0], initial_delay[1]) * 1000);
|
long delay = (long) (getRandom(initial_delay[0], initial_delay[1]) * 1000);
|
||||||
setStatus("Inital delay: %d\n",delay);
|
setStatus("Inital delay: %d\n", delay);
|
||||||
timerTask = se.timer.startTimerTask(this, delay);
|
timerTask = se.timer.startTimerTask(this, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +82,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
// System.out.printf("Enter TimerTask for %d / %d\n", System.identityHashCode(this), Thread.currentThread().getId());
|
// System.out.printf("Enter TimerTask for %d / %d\n", System.identityHashCode(this), Thread.currentThread().getId());
|
||||||
sesim.Exchange.Account a = se.getAccount(account_id);
|
sesim.Exchange.Account a = se.getAccount(account_id);
|
||||||
// System.out.printf("Have Account %d\n", Thread.currentThread().getId());
|
// System.out.printf("Have Account %d\n", Thread.currentThread().getId());
|
||||||
|
Globals.se.ua(a);
|
||||||
long rc = this.doTrade();
|
long rc = this.doTrade();
|
||||||
setStatus("Sleeping for %d ms", rc);
|
setStatus("Sleeping for %d ms", rc);
|
||||||
return rc;
|
return rc;
|
||||||
@ -116,7 +117,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +207,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
|
|
||||||
// System.out.printf("We have now to wait for %d\n", w);
|
// System.out.printf("We have now to wait for %d\n", w);
|
||||||
//timerTask = se.timer.startTimerTask(this, w);
|
//timerTask = se.timer.startTimerTask(this, w);
|
||||||
// se.timer.XXXrescheduleTimerTask(timerTask, w);
|
// se.timer.XXXrescheduleTimerTask(timerTask, w);
|
||||||
|
|
||||||
}
|
}
|
||||||
// System.out.printf("Updatetd Account\n", "");
|
// System.out.printf("Updatetd Account\n", "");
|
||||||
|
|
||||||
@ -237,6 +237,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
mode = Action.BUY;
|
mode = Action.BUY;
|
||||||
return getRandom(buy_wait);
|
return getRandom(buy_wait);
|
||||||
}
|
}
|
||||||
|
// System.out.printf("Buy failed\n");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +248,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
return getRandom(sell_wait);
|
return getRandom(sell_wait);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// System.out.printf("Sell failed\n");
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -279,44 +281,43 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
long doTrade() {
|
long doTrade() {
|
||||||
|
|
||||||
long co = cancelOrders();
|
long co = cancelOrders();
|
||||||
setStatus("Orders cancled: %d",co);
|
setStatus("Orders cancled: %d", co);
|
||||||
if (co>0)
|
if (co > 0) {
|
||||||
mode = Action.RANDOM;
|
mode = Action.RANDOM;
|
||||||
|
}
|
||||||
|
|
||||||
Action a = getAction();
|
Action a = getAction();
|
||||||
|
|
||||||
// System.out.printf("Action is %s\n", a.toString());
|
// System.out.printf("Action is %s\n", a.toString());
|
||||||
if (mode == Action.RANDOM) {
|
if (mode == Action.RANDOM) {
|
||||||
|
|
||||||
setStatus("Mode is %s, next action is %s",mode.toString(),a.toString());
|
setStatus("Mode is %s, next action is %s", mode.toString(), a.toString());
|
||||||
|
|
||||||
// System.out.printf("Action: %s\n", a.toString());
|
// System.out.printf("Action: %s\n", a.toString());
|
||||||
Integer rc = doTrade1(a);
|
Integer rc = doTrade1(a);
|
||||||
if (rc != null) {
|
if (rc != null) {
|
||||||
setStatus("Action %s success full, ret %d",a.toString(),rc);
|
setStatus("Action %s successfull, ret %d", a.toString(), rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rc = doTrade1(Action.BUY);
|
rc = doTrade1(Action.BUY);
|
||||||
if (rc != null) {
|
if (rc != null) {
|
||||||
setStatus("BuyAction %s successfull, ret %d",a.toString(),rc);
|
setStatus("BuyAction %s successfull, ret %d", a.toString(), rc);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = doTrade1(Action.SELL);
|
rc = doTrade1(Action.SELL);
|
||||||
if (rc != null) {
|
if (rc != null) {
|
||||||
setStatus("SellAction %s successfull, ret %d",a.toString(),rc);
|
setStatus("SellAction %s successfull, ret %d", a.toString(), rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus("No trade possible, returning 5000");
|
setStatus("No trade possible, returning 5000");
|
||||||
// System.out.printf("All ha s failed\n");
|
//System.out.printf("All ha s failed\n");
|
||||||
return 5000;
|
return 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setStatus("Current mode is %s", mode.toString());
|
||||||
setStatus("Current mode is %s",mode.toString());
|
|
||||||
return waitAfterOrder();
|
return waitAfterOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,23 +380,28 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
|
|
||||||
double limit;
|
double limit;
|
||||||
limit = lp + getRandomAmmount(lp, buy_limit);
|
limit = lp + getRandomAmmount(lp, buy_limit);
|
||||||
|
|
||||||
System.out.printf("Creating Buy Order from lp: %f, %f\n",lp,limit);
|
|
||||||
|
|
||||||
|
//System.out.printf("Creating Buy Order from lp: %f, %f\n",lp,limit);
|
||||||
double volume = money / limit;
|
double volume = money / limit;
|
||||||
|
|
||||||
// System.out.printf("Volume : %f", volume);
|
// System.out.printf("Volume : %f", volume);
|
||||||
limit = se.roundMoney(limit);
|
limit = se.roundMoney(limit);
|
||||||
volume = se.roundShares(volume);
|
volume = se.roundShares(volume);
|
||||||
|
|
||||||
if (volume <= 0 || money <= 0) {
|
// if (volume <= 0 || money <= 0) {
|
||||||
|
// System.out.printf("Buy failed %f, %f / %f (%f)\n", volume,money,limit,ad.getMoney());
|
||||||
// System.out.printf("Buy Order wont work\n");
|
// System.out.printf("Buy Order wont work\n");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
long rc = se.createOrder(account_id, type, volume, limit);
|
||||||
|
|
||||||
|
if (rc == -1) {
|
||||||
|
|
||||||
|
// System.out.printf("Buy failed %f, %f / %f (%f)\n", volume, money, limit, ad.getMoney());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//System.out.printf("Creating Sell Order from lp: %f, %f\n",lp,limit);
|
||||||
|
|
||||||
se.createOrder(account_id, type, volume, limit);
|
|
||||||
System.out.printf("Creating Sell Order from lp: %f, %f\n",lp,limit);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -421,13 +427,18 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
|
|||||||
limit = lp + getRandomAmmount(lp, sell_limit);
|
limit = lp + getRandomAmmount(lp, sell_limit);
|
||||||
se.roundMoney(limit);
|
se.roundMoney(limit);
|
||||||
|
|
||||||
if (volume <= 0 || limit <= 0) {
|
// if (volume <= 0 || limit <= 0) {
|
||||||
|
// System.out.printf("Sell failed %f, %f (%f)\n", volume,limit,ad.getMoney());
|
||||||
// System.out.printf("Sell wont work\n");
|
// System.out.printf("Sell wont work\n");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// 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 false;
|
||||||
}
|
}
|
||||||
// System.out.printf("Create a Sell Order %f %f!!!!\n", volume, limit);
|
|
||||||
se.createOrder(account_id, type, volume, limit);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user