Correct SL calculation
This commit is contained in:
parent
236138a822
commit
703fe209b2
@ -1,4 +1,4 @@
|
|||||||
#Tue, 08 Jan 2019 13:27:57 +0100
|
#Tue, 08 Jan 2019 19:25:21 +0100
|
||||||
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=
|
||||||
|
@ -119,12 +119,12 @@ public class Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized void add(AssetPack pack) {
|
synchronized void add(AssetPack pack) {
|
||||||
assets.put(pack.asset, get(pack.asset) + pack.volume);
|
assets.put(pack.asset, get(pack.asset,false) + pack.volume);
|
||||||
// assets_bound.put(pack.asset, getAvail(pack.asset) + pack.volume);
|
// assets_bound.put(pack.asset, getAvail(pack.asset) + pack.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void sub(AssetPack pack) {
|
synchronized void sub(AssetPack pack) {
|
||||||
assets.put(pack.asset, get(pack.asset) - pack.volume);
|
assets.put(pack.asset, get(pack.asset,false) - pack.volume);
|
||||||
// assets_bound.put(pack.asset, getAvail(pack.asset) - pack.volume);
|
// assets_bound.put(pack.asset, getAvail(pack.asset) - pack.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ public class Account {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Double calcStopLoss(Exchange ex, AbstractAsset asset, AbstractAsset currency) {
|
public Double calcStopLoss(Exchange ex, AbstractAsset asset, AbstractAsset currency) {
|
||||||
Double e = (get(currency));
|
Double e = (get(currency,false));
|
||||||
for (AbstractAsset a : assets.keySet()) {
|
for (AbstractAsset a : assets.keySet()) {
|
||||||
if (a.equals(asset)) {
|
if (a.equals(asset)) {
|
||||||
continue;
|
continue;
|
||||||
@ -302,7 +302,7 @@ public class Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TradingEngine api = (TradingEngine) ex.getAPI(pair);
|
TradingEngine api = (TradingEngine) ex.getAPI(pair);
|
||||||
Double v = get(a) * api.last_quote.price;
|
Double v = get(a,false) * api.last_quote.price;
|
||||||
e = e + v;
|
e = e + v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class SimpleTrader extends AbstractTrader implements EventListener {
|
|||||||
|
|
||||||
pack = new AssetPack(p.getCurrency(), 1000);
|
pack = new AssetPack(p.getCurrency(), 1000);
|
||||||
account_b.add(pack);
|
account_b.add(pack);
|
||||||
account_b.setLeverage(0.1);
|
account_b.setLeverage(9);
|
||||||
|
|
||||||
pack = new AssetPack(p.getCurrency(), 10000);
|
pack = new AssetPack(p.getCurrency(), 10000);
|
||||||
account_1.add(pack);
|
account_1.add(pack);
|
||||||
@ -142,10 +142,12 @@ public class SimpleTrader extends AbstractTrader implements EventListener {
|
|||||||
getWorld().getAssetBySymbol("EUR"));
|
getWorld().getAssetBySymbol("EUR"));
|
||||||
TradingAPI mapi = ex.getAPI(msftp);
|
TradingAPI mapi = ex.getAPI(msftp);
|
||||||
|
|
||||||
Order ob = api.createOrder(account_b, Order.Type.SELLLIMIT, 10, 100);
|
Order ob = api.createOrder(account_b, Order.Type.BUYLIMIT, 20, 100);
|
||||||
|
Order obm = mapi.createOrder(account_b, Order.Type.BUYLIMIT, 20, 100);
|
||||||
|
|
||||||
|
|
||||||
Order oba = api.createOrder(account_1, Order.Type.BUYLIMIT, 10, 100);
|
Order oba = api.createOrder(account_1, Order.Type.SELLLIMIT, 10, 100);
|
||||||
|
Order obam = mapi.createOrder(account_1, Order.Type.SELLLIMIT, 20, 100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ class TradingEngine implements TradingAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
executeOrders();
|
executeOrders();
|
||||||
//last_quote.price = 90; //75-12.5;
|
last_quote.price = 90; //75-12.5;
|
||||||
for (FiringEvent e : book_listener) {
|
for (FiringEvent e : book_listener) {
|
||||||
e.fire();
|
e.fire();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user