Introduced TraderConfig
This commit is contained in:
parent
62f4462c86
commit
2b575d87dd
@ -151,7 +151,7 @@ public class MainWin extends javax.swing.JFrame {
|
||||
|
||||
se = new Exchange();
|
||||
myAccount = new Account(se,1000,100000000.0);
|
||||
myTrader = new Traders.ManTrader(myAccount);
|
||||
myTrader = new Traders.ManTrader(myAccount,null);
|
||||
|
||||
/* Account otherAccount = new Account(se,1000,1000);
|
||||
Traders.ManTrader otherTrader = new Traders.ManTrader(otherAccount);
|
||||
@ -159,7 +159,7 @@ public class MainWin extends javax.swing.JFrame {
|
||||
|
||||
*/
|
||||
Account traccount = new Account(se,5500,1000000.0);
|
||||
RandomTrader rt = new RandomTrader(traccount);
|
||||
RandomTrader rt = new RandomTrader(traccount,null);
|
||||
TraderRunner tr = new TraderRunner(rt);
|
||||
tr.start();
|
||||
|
||||
|
@ -7,8 +7,8 @@ public class MTrader extends Trader {
|
||||
Exchange ex;
|
||||
Random rand;
|
||||
|
||||
public MTrader(Account account) {
|
||||
super(account);
|
||||
public MTrader(Account account,TraderConfig config) {
|
||||
super(account,config);
|
||||
}
|
||||
|
||||
/* public MTrader(Exchange ex1, long shares, double money) {
|
||||
|
@ -31,6 +31,7 @@ public abstract class Trader {
|
||||
|
||||
public abstract void trade();
|
||||
public Account account;
|
||||
public TraderConfig config;
|
||||
|
||||
public void sell(long shares, double limit){
|
||||
account.sell(shares, limit);
|
||||
@ -44,8 +45,9 @@ public abstract class Trader {
|
||||
* Construct a Trader object
|
||||
* @param account Account for this trader
|
||||
*/
|
||||
public Trader(Account account){
|
||||
public Trader(Account account, TraderConfig config){
|
||||
this.account=account;
|
||||
this.config=config;
|
||||
}
|
||||
|
||||
|
||||
|
34
src/SeSim/TraderConfig.java
Normal file
34
src/SeSim/TraderConfig.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public abstract class TraderConfig {
|
||||
|
||||
}
|
@ -27,17 +27,20 @@ package Traders;
|
||||
|
||||
import SeSim.Account;
|
||||
import SeSim.Trader;
|
||||
import SeSim.TraderConfig;
|
||||
import SeSim.BuyOrder;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ManTrader extends Trader{
|
||||
|
||||
public ManTrader(Account account) {
|
||||
super(account);
|
||||
public ManTrader(Account account,TraderConfig config) {
|
||||
super(account,config);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package Traders;
|
||||
|
||||
import SeSim.Account;
|
||||
import SeSim.Exchange;
|
||||
import SeSim.Order;
|
||||
import java.util.Random;
|
||||
import SeSim.Trader;
|
||||
import SeSim.TraderConfig;
|
||||
|
||||
public class RandomTrader extends Trader {
|
||||
|
||||
@ -12,8 +12,8 @@ public class RandomTrader extends Trader {
|
||||
|
||||
// my current order
|
||||
//private Order myorder = null;
|
||||
public RandomTrader(Account account) {
|
||||
super(account);
|
||||
public RandomTrader(Account account,TraderConfig config) {
|
||||
super(account,config);
|
||||
}
|
||||
|
||||
public void doBuy() {
|
||||
|
Loading…
Reference in New Issue
Block a user