Some improvements
This commit is contained in:
parent
346607fec3
commit
f57d1a4cb0
@ -42,7 +42,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
|
|
||||||
public final void initChart(){
|
public final void initChart(){
|
||||||
// data = new OHLCData(60000*30);
|
// data = new OHLCData(60000*30);
|
||||||
data = new OHLCData(60000);
|
data = new OHLCData(60000*1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ public class AskBook extends OrderBook {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
ArrayList <Order> getOrderBook() {
|
ArrayList <Order> getOrderBook() {
|
||||||
return Globals.se.getOrderBook(OrderType.ASK,40);
|
return Globals.se.getOrderBook(OrderType.SELLLIMIT,40);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +48,7 @@ public class AskBook extends OrderBook {
|
|||||||
if (Globals.se == null) {
|
if (Globals.se == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Globals.se.addBookReceiver(OrderType.ASK, this);
|
Globals.se.addBookReceiver(OrderType.SELLLIMIT, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ public class BidBook extends OrderBook {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
ArrayList<Order> getOrderBook() {
|
ArrayList<Order> getOrderBook() {
|
||||||
return Globals.se.getOrderBook(OrderType.BID, 40);
|
return Globals.se.getOrderBook(OrderType.BUYLIMIT, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BidBook() {
|
public BidBook() {
|
||||||
if (Globals.se == null) {
|
if (Globals.se == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Globals.se.addBookReceiver(OrderType.BID, this);
|
Globals.se.addBookReceiver(OrderType.BUYLIMIT, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
54
src/main/java/gui/OrdersList.form
Normal file
54
src/main/java/gui/OrdersList.form
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?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">
|
||||||
|
<Component id="jScrollPane1" alignment="1" pref="400" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="jScrollPane1" pref="215" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JTable" name="order_table">
|
||||||
|
<Properties>
|
||||||
|
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||||
|
<Table columnCount="4" rowCount="4">
|
||||||
|
<Column editable="true" title="ID" type="java.lang.Long"/>
|
||||||
|
<Column editable="true" title="Type" type="java.lang.String"/>
|
||||||
|
<Column editable="true" title="Price" type="java.lang.Double"/>
|
||||||
|
<Column editable="true" title="Volume" type="java.lang.Double"/>
|
||||||
|
</Table>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
119
src/main/java/gui/OrdersList.java
Normal file
119
src/main/java/gui/OrdersList.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* 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 gui;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import sesim.Exchange.Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author tobias
|
||||||
|
*/
|
||||||
|
public class OrdersList extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
public Account account;
|
||||||
|
DefaultTableModel model;
|
||||||
|
|
||||||
|
public final void updateModel(){
|
||||||
|
if (null==account)
|
||||||
|
return;
|
||||||
|
|
||||||
|
account.getOrders().forEach(new BiConsumer() {
|
||||||
|
@Override
|
||||||
|
public void accept(Object k, Object u) {
|
||||||
|
System.out.printf("Key: %d\n", (Long)k);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form OrdersList
|
||||||
|
*/
|
||||||
|
public OrdersList() {
|
||||||
|
initComponents();
|
||||||
|
model = (DefaultTableModel) order_table.getModel();
|
||||||
|
updateModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
order_table = new javax.swing.JTable();
|
||||||
|
|
||||||
|
order_table.setModel(new javax.swing.table.DefaultTableModel(
|
||||||
|
new Object [][] {
|
||||||
|
{null, null, null, null},
|
||||||
|
{null, null, null, null},
|
||||||
|
{null, null, null, null},
|
||||||
|
{null, null, null, null}
|
||||||
|
},
|
||||||
|
new String [] {
|
||||||
|
"ID", "Type", "Price", "Volume"
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Class[] types = new Class [] {
|
||||||
|
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class
|
||||||
|
};
|
||||||
|
|
||||||
|
public Class getColumnClass(int columnIndex) {
|
||||||
|
return types [columnIndex];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jScrollPane1.setViewportView(order_table);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private javax.swing.JTable order_table;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -50,7 +50,7 @@ public class Exchange {
|
|||||||
* Definition of order types
|
* Definition of order types
|
||||||
*/
|
*/
|
||||||
public enum OrderType {
|
public enum OrderType {
|
||||||
BID, ASK
|
BUYLIMIT, SELLLIMIT, STOPLOSS, STOPBUY
|
||||||
}
|
}
|
||||||
|
|
||||||
IDGenerator account_id = new IDGenerator();
|
IDGenerator account_id = new IDGenerator();
|
||||||
@ -101,6 +101,10 @@ public class Exchange {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map getOrders() {
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTraders(JSONArray traderdefs) {
|
public void createTraders(JSONArray traderdefs) {
|
||||||
@ -136,10 +140,10 @@ public class Exchange {
|
|||||||
public int compare(Order left, Order right) {
|
public int compare(Order left, Order right) {
|
||||||
double d;
|
double d;
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case BID:
|
case BUYLIMIT:
|
||||||
d = right.limit - left.limit;
|
d = right.limit - left.limit;
|
||||||
break;
|
break;
|
||||||
case ASK:
|
case SELLLIMIT:
|
||||||
d = left.limit - right.limit;
|
d = left.limit - right.limit;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -164,7 +168,6 @@ public class Exchange {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// return left.id < right.id ? -1 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -181,7 +184,7 @@ public class Exchange {
|
|||||||
private final double initial_volume;
|
private final double initial_volume;
|
||||||
private long id;
|
private long id;
|
||||||
long created;
|
long created;
|
||||||
private Account account;
|
private final Account account;
|
||||||
|
|
||||||
Order(Account account, OrderType type, double volume, double limit) {
|
Order(Account account, OrderType type, double volume, double limit) {
|
||||||
id = order_id.getNext();
|
id = order_id.getNext();
|
||||||
@ -317,8 +320,8 @@ public class Exchange {
|
|||||||
|
|
||||||
public Quote getCurrentPrice() {
|
public Quote getCurrentPrice() {
|
||||||
|
|
||||||
SortedSet<Order> bid = order_books.get(OrderType.BID);
|
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
||||||
SortedSet<Order> ask = order_books.get(OrderType.ASK);
|
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
||||||
|
|
||||||
Quote q = null;
|
Quote q = null;
|
||||||
|
|
||||||
@ -366,9 +369,9 @@ public class Exchange {
|
|||||||
|
|
||||||
private ArrayList<BookReceiver> selectBookReceiver(OrderType t) {
|
private ArrayList<BookReceiver> selectBookReceiver(OrderType t) {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case ASK:
|
case SELLLIMIT:
|
||||||
return ask_bookreceivers;
|
return ask_bookreceivers;
|
||||||
case BID:
|
case BUYLIMIT:
|
||||||
return bid_bookreceivers;
|
return bid_bookreceivers;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -411,8 +414,8 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// long time = 0;
|
// long time = 0;
|
||||||
double theprice = 12.9;
|
//double theprice = 12.9;
|
||||||
long orderid = 1;
|
// long orderid = 1;
|
||||||
|
|
||||||
double lastprice = 100.0;
|
double lastprice = 100.0;
|
||||||
long lastsvolume;
|
long lastsvolume;
|
||||||
@ -476,7 +479,7 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tradelock.unlock();
|
tradelock.unlock();
|
||||||
this.updateBookReceivers(OrderType.BID);
|
this.updateBookReceivers(OrderType.BUYLIMIT);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -525,8 +528,8 @@ public class Exchange {
|
|||||||
*/
|
*/
|
||||||
public void executeOrders() {
|
public void executeOrders() {
|
||||||
|
|
||||||
SortedSet<Order> bid = order_books.get(OrderType.BID);
|
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
||||||
SortedSet<Order> ask = order_books.get(OrderType.ASK);
|
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
||||||
|
|
||||||
double volume_total = 0;
|
double volume_total = 0;
|
||||||
double money_total = 0;
|
double money_total = 0;
|
||||||
@ -594,7 +597,6 @@ public class Exchange {
|
|||||||
*/
|
*/
|
||||||
public long createOrder(double account_id, OrderType type, double volume, double limit) {
|
public long createOrder(double account_id, OrderType type, double volume, double limit) {
|
||||||
|
|
||||||
|
|
||||||
Account a = accounts.get(account_id);
|
Account a = accounts.get(account_id);
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -614,8 +616,8 @@ public class Exchange {
|
|||||||
this.executeOrders();
|
this.executeOrders();
|
||||||
|
|
||||||
tradelock.unlock();
|
tradelock.unlock();
|
||||||
this.updateBookReceivers(OrderType.ASK);
|
this.updateBookReceivers(OrderType.SELLLIMIT);
|
||||||
this.updateBookReceivers(OrderType.BID);
|
this.updateBookReceivers(OrderType.BUYLIMIT);
|
||||||
|
|
||||||
return o.id;
|
return o.id;
|
||||||
}
|
}
|
||||||
|
34
src/main/java/sesim/Order.java
Normal file
34
src/main/java/sesim/Order.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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 Order {
|
||||||
|
|
||||||
|
}
|
@ -26,6 +26,7 @@
|
|||||||
package traders.ManTrader;
|
package traders.ManTrader;
|
||||||
|
|
||||||
import gui.Globals;
|
import gui.Globals;
|
||||||
|
import gui.OrdersList;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderBase;
|
import sesim.AutoTraderBase;
|
||||||
@ -56,8 +57,11 @@ public class ManTrader extends AutoTraderBase implements AutoTraderConfig {
|
|||||||
se.timer.startTimerEvent(this, 0);
|
se.timer.startTimerEvent(this, 0);
|
||||||
consoleDialog = new ManTraderConsoleDialog(Globals.frame, false);
|
consoleDialog = new ManTraderConsoleDialog(Globals.frame, false);
|
||||||
|
|
||||||
|
// consoleDialog. rdersList1.account=trader.getAccount();
|
||||||
|
|
||||||
consoleDialog.getConsole().trader=this;
|
consoleDialog.getConsole().trader=this;
|
||||||
|
|
||||||
|
|
||||||
consoleDialog.setVisible(true);
|
consoleDialog.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,6 +69,8 @@ public class ManTrader extends AutoTraderBase implements AutoTraderConfig {
|
|||||||
@Override
|
@Override
|
||||||
public long timerTask() {
|
public long timerTask() {
|
||||||
System.out.printf("TimerTask\n");
|
System.out.printf("TimerTask\n");
|
||||||
|
OrdersList ol = this.consoleDialog.getConsole().getOrderListPanel();
|
||||||
|
ol.updateModel();
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,16 +16,16 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
|
<Component id="ordersList1" max="32767" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="buyButton" max="32767" attributes="0"/>
|
<Component id="buyButton" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="sellButton" min="-2" pref="191" max="-2" attributes="0"/>
|
<Component id="sellButton" min="-2" pref="191" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<Component id="moneyText" min="-2" pref="330" max="-2" attributes="0"/>
|
<Component id="moneyText" min="-2" pref="330" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace min="0" pref="8" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
@ -54,13 +54,13 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jScrollPane1" min="-2" pref="98" max="-2" attributes="0"/>
|
<Component id="ordersList1" min="-2" pref="148" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="moneyText" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="moneyText" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace pref="29" max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="limitSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
<Component id="limitSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
||||||
@ -81,27 +81,6 @@
|
|||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
|
||||||
<AuxValues>
|
|
||||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
|
||||||
</AuxValues>
|
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
|
||||||
<SubComponents>
|
|
||||||
<Component class="javax.swing.JTable" name="jTable1">
|
|
||||||
<Properties>
|
|
||||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
|
||||||
<Table columnCount="4" rowCount="4">
|
|
||||||
<Column editable="true" title="Title 1" type="java.lang.Object"/>
|
|
||||||
<Column editable="true" title="Title 2" type="java.lang.Object"/>
|
|
||||||
<Column editable="true" title="Title 3" type="java.lang.Object"/>
|
|
||||||
<Column editable="true" title="Title 4" type="java.lang.Object"/>
|
|
||||||
</Table>
|
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
|
||||||
</Container>
|
|
||||||
<Component class="javax.swing.JSpinner" name="limitSpinner">
|
<Component class="javax.swing.JSpinner" name="limitSpinner">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
@ -152,5 +131,7 @@
|
|||||||
<Property name="text" type="java.lang.String" value="jLabel4"/>
|
<Property name="text" type="java.lang.String" value="jLabel4"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="gui.OrdersList" name="ordersList1">
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package traders.ManTrader;
|
package traders.ManTrader;
|
||||||
|
|
||||||
|
import gui.OrdersList;
|
||||||
|
import javax.swing.JTable;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
|
||||||
@ -36,12 +38,16 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
|
|
||||||
public AutoTrader trader;
|
public AutoTrader trader;
|
||||||
|
|
||||||
|
public OrdersList getOrderListPanel(){
|
||||||
|
return this.ordersList1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form ManTraderConsole
|
* Creates new form ManTraderConsole
|
||||||
*/
|
*/
|
||||||
public ManTraderConsole() {
|
public ManTraderConsole() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
// this.ordersList1.account=trader.getAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +59,6 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
jScrollPane1 = new javax.swing.JScrollPane();
|
|
||||||
jTable1 = new javax.swing.JTable();
|
|
||||||
limitSpinner = new javax.swing.JSpinner();
|
limitSpinner = new javax.swing.JSpinner();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
jLabel1 = new javax.swing.JLabel();
|
||||||
jLabel2 = new javax.swing.JLabel();
|
jLabel2 = new javax.swing.JLabel();
|
||||||
@ -63,19 +67,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
sellButton = new javax.swing.JButton();
|
sellButton = new javax.swing.JButton();
|
||||||
jLabel3 = new javax.swing.JLabel();
|
jLabel3 = new javax.swing.JLabel();
|
||||||
moneyText = new javax.swing.JLabel();
|
moneyText = new javax.swing.JLabel();
|
||||||
|
ordersList1 = new gui.OrdersList();
|
||||||
jTable1.setModel(new javax.swing.table.DefaultTableModel(
|
|
||||||
new Object [][] {
|
|
||||||
{null, null, null, null},
|
|
||||||
{null, null, null, null},
|
|
||||||
{null, null, null, null},
|
|
||||||
{null, null, null, null}
|
|
||||||
},
|
|
||||||
new String [] {
|
|
||||||
"Title 1", "Title 2", "Title 3", "Title 4"
|
|
||||||
}
|
|
||||||
));
|
|
||||||
jScrollPane1.setViewportView(jTable1);
|
|
||||||
|
|
||||||
limitSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
|
limitSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
|
||||||
|
|
||||||
@ -107,15 +99,15 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
.addComponent(ordersList1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
.addComponent(buyButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(buyButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(sellButton, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(sellButton, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jLabel2)
|
.addComponent(jLabel2)
|
||||||
@ -129,19 +121,19 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
.addComponent(jLabel3)
|
.addComponent(jLabel3)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(moneyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
.addComponent(moneyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||||
.addGap(0, 8, Short.MAX_VALUE)))
|
.addGap(0, 0, Short.MAX_VALUE)))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(ordersList1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel3)
|
.addComponent(jLabel3)
|
||||||
.addComponent(moneyText))
|
.addComponent(moneyText))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1)
|
||||||
.addComponent(limitSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(limitSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
@ -163,7 +155,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
|
|
||||||
System.out.printf("Should buy: %f %f\n",volume,limit);
|
System.out.printf("Should buy: %f %f\n",volume,limit);
|
||||||
|
|
||||||
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.BID, volume, limit);
|
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.BUYLIMIT, volume, limit);
|
||||||
System.out.printf("The retval is %d",createOrder);
|
System.out.printf("The retval is %d",createOrder);
|
||||||
|
|
||||||
|
|
||||||
@ -175,7 +167,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
|
|
||||||
System.out.printf("Should buy: %f %f\n",volume,limit);
|
System.out.printf("Should buy: %f %f\n",volume,limit);
|
||||||
|
|
||||||
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.ASK, volume, limit);
|
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.SELLLIMIT, volume, limit);
|
||||||
System.out.printf("The retval is %d",createOrder);
|
System.out.printf("The retval is %d",createOrder);
|
||||||
}//GEN-LAST:event_sellButtonActionPerformed
|
}//GEN-LAST:event_sellButtonActionPerformed
|
||||||
|
|
||||||
@ -185,10 +177,9 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JLabel jLabel2;
|
private javax.swing.JLabel jLabel2;
|
||||||
private javax.swing.JLabel jLabel3;
|
private javax.swing.JLabel jLabel3;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
|
||||||
private javax.swing.JTable jTable1;
|
|
||||||
private javax.swing.JSpinner limitSpinner;
|
private javax.swing.JSpinner limitSpinner;
|
||||||
private javax.swing.JLabel moneyText;
|
private javax.swing.JLabel moneyText;
|
||||||
|
private gui.OrdersList ordersList1;
|
||||||
private javax.swing.JButton sellButton;
|
private javax.swing.JButton sellButton;
|
||||||
private javax.swing.JSpinner volumeSpinner;
|
private javax.swing.JSpinner volumeSpinner;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
@ -39,8 +39,11 @@ public class ManTraderConsoleDialog extends javax.swing.JDialog {
|
|||||||
public ManTraderConsoleDialog(java.awt.Frame parent, boolean modal) {
|
public ManTraderConsoleDialog(java.awt.Frame parent, boolean modal) {
|
||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ManTraderConsole getConsole(){
|
public ManTraderConsole getConsole(){
|
||||||
return this.console;
|
return this.console;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
|
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
|
||||||
AccountData ad = this.se.getAccountData(account_id);
|
AccountData ad = this.se.getAccountData(account_id);
|
||||||
|
|
||||||
OrderType type = OrderType.BID;
|
OrderType type = OrderType.BUYLIMIT;
|
||||||
|
|
||||||
if (ad == null || myconfig == null) {
|
if (ad == null || myconfig == null) {
|
||||||
//System.out.printf("%s: myconf = 0 \n", this.getName());
|
//System.out.printf("%s: myconf = 0 \n", this.getName());
|
||||||
@ -226,7 +226,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
|
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
|
||||||
AccountData ad = this.se.getAccountData(account_id);
|
AccountData ad = this.se.getAccountData(account_id);
|
||||||
|
|
||||||
OrderType type = OrderType.ASK;
|
OrderType type = OrderType.SELLLIMIT;
|
||||||
|
|
||||||
//System.out.printf("%s: calling rand for volume\n", this.getName());
|
//System.out.printf("%s: calling rand for volume\n", this.getName());
|
||||||
// how much money we ant to envest?
|
// how much money we ant to envest?
|
||||||
|
Loading…
Reference in New Issue
Block a user