Skip to content

Commit

Permalink
Removed SL API workaround after clarification with Dukascopy.
Browse files Browse the repository at this point in the history
  • Loading branch information
juxeii authored and juxeii committed Mar 8, 2017
1 parent 190e2c1 commit 3d61aea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ public Completable setStopLossPrice(final IOrder order,
final double newSL,
final OfferSide offerSide,
final double trailingStep) {
return trailingStep < 0
? completable(() -> order.setStopLossPrice(newSL, offerSide))
: completable(() -> order.setStopLossPrice(newSL,
offerSide,
trailingStep));
return completable(() -> order.setStopLossPrice(newSL,
offerSide,
trailingStep));
}

public Completable setTakeProfitPrice(final IOrder order,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private OfferSide evalOfferSide(final Optional<OfferSide> maybeOfferSide) {
}

private double evalTrailingStep(final Optional<Double> maybeTrailingStep) {
return maybeTrailingStep.orElse(-1.0);
return maybeTrailingStep.orElse(0.0);
}

public final IOrder order() {
Expand Down Expand Up @@ -123,6 +123,7 @@ public Builder withTrailingStep(final double trailingStep) {
return this;
}

@Override
public SetSLParams build() {
return new SetSLParams(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public void askIsOfferSideWhenOrderIsShort() {
}

@Test
public void trailingStepIsNegativeWhenNotSpecified() {
public void trailingStepIsZeroWhenNotSpecified() {
setSLParams = SetSLParams
.setSLAtPrice(buyOrderEURUSD, newSL)
.build();

assertThat(setSLParams.trailingStep(), equalTo(-1.0));
assertThat(setSLParams.trailingStep(), equalTo(0.0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ public class AsPipsSetup {
public void setUp() {
when(calculationUtilMock.slPriceForPips(orderForTest, pips))
.thenReturn(newSL);
when(orderTaskExecutorMock.setStopLossPrice(orderForTest, newSL, OfferSide.ASK, -1.0))
when(orderTaskExecutorMock.setStopLossPrice(orderForTest, newSL, OfferSide.ASK, 0.0))
.thenReturn(emptyCompletable());

observable = basicTask.setStopLossPrice(SetSLParams
Expand Down Expand Up @@ -700,7 +700,7 @@ public void verifyTaskExecutorCall() {
verify(orderTaskExecutorMock).setStopLossPrice(orderForTest,
newSL,
OfferSide.ASK,
-1);
0.0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,6 @@ public void taskExecutorCallsOnStrategyThreadWithAction() throws Exception {
}
}

public class APIWorkaroundTrailingstep {

private final double newSL = 1.1234;
private final double trailingStep = -1;

@Before
public void setUp() {
taskExecutor.setStopLossPrice(orderForTest,
newSL,
OfferSide.ASK,
trailingStep);
}

@Test
public void taskExecutorIsCalledWithoutTrailingStep() throws Exception {
captureAndRunAction();
verify(orderForTest).setStopLossPrice(newSL, OfferSide.ASK);
}
}

public class SetTakeProfitSetup {

private final double newTP = 1.1234;
Expand Down

0 comments on commit 3d61aea

Please sign in to comment.