Some work on traders ...
This commit is contained in:
parent
818282d4cb
commit
5fa813df72
@ -12,6 +12,9 @@ public class Account {
|
||||
*/
|
||||
public double money = 0;
|
||||
|
||||
/**
|
||||
* Name of this account
|
||||
*/
|
||||
public String name = "";
|
||||
|
||||
public boolean orderpending = false;
|
||||
|
@ -95,9 +95,9 @@ public class Exchange extends Thread {
|
||||
|
||||
Logger.info(
|
||||
String.format("BID: %s(%s) LAST: %.2f(%d) ASK: %s(%s)\n",
|
||||
b.format_limit(), b.format_size(),
|
||||
b.format_limit(), b.format_volume(),
|
||||
lastprice, lastsize,
|
||||
a.format_limit(), a.format_size())
|
||||
a.format_limit(), a.format_volume())
|
||||
);
|
||||
|
||||
}
|
||||
@ -194,6 +194,11 @@ public class Exchange extends Thread {
|
||||
// SellOrder op = ask.peek();
|
||||
|
||||
}
|
||||
|
||||
private void InitOrder(Order o){
|
||||
double moneyNeeded = o.volume * o.limit;
|
||||
|
||||
}
|
||||
|
||||
public void SendOrder(SellOrder o) {
|
||||
// System.out.println("EX Sellorder");
|
||||
|
@ -2,7 +2,7 @@ package SeSim;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MTrader implements Trader {
|
||||
public class MTrader extends Trader {
|
||||
|
||||
Exchange ex;
|
||||
Random rand;
|
||||
|
@ -42,7 +42,7 @@ public abstract class Order implements Comparable<Order> {
|
||||
return String.format("%.2f", limit);
|
||||
}
|
||||
|
||||
String format_size() {
|
||||
String format_volume() {
|
||||
return String.format("%d", volume);
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,13 @@ package SeSim;
|
||||
import java.util.Random;
|
||||
import SeSim.Order.OrderStatus;
|
||||
|
||||
public class RandomTrader extends ThreadedTrader {
|
||||
public class RandomTrader extends Trader {
|
||||
|
||||
// public Account account=new Account();
|
||||
Exchange ex = null;
|
||||
Random rand = new Random();
|
||||
|
||||
public String name;
|
||||
|
||||
|
||||
// my current order
|
||||
private Order myorder = null;
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package SeSim;
|
||||
|
||||
public abstract class ThreadedTrader extends Thread implements Trader {
|
||||
public abstract class ThreadedTrader extends Thread {
|
||||
|
||||
protected long sleeptime = 100;
|
||||
|
||||
public void RandomTrader(Exchange ex, long shares, double money) {
|
||||
// this.ex=ex;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -15,8 +16,9 @@ public abstract class ThreadedTrader extends Thread implements Trader {
|
||||
sleep(sleeptime);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Interrupted");
|
||||
return;
|
||||
}
|
||||
trade();
|
||||
// trade();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package SeSim;
|
||||
|
||||
public interface Trader {
|
||||
public abstract class Trader {
|
||||
|
||||
// String name = null;
|
||||
String name = null;
|
||||
|
||||
public void trade();
|
||||
public abstract void trade();
|
||||
public Account account = new Account();
|
||||
|
||||
|
||||
// public Exchange ex=null;
|
||||
|
||||
};
|
||||
|
36
src/Traders/ManTrader.java
Normal file
36
src/Traders/ManTrader.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 Traders;
|
||||
|
||||
import SeSim.Trader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ManTrader {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user