package quantisan.qte_lmax;

import com.lmax.api.FixedPointNumber;
import com.lmax.api.TimeInForce;
import com.lmax.api.order.AmendStopsRequest;
import com.lmax.api.order.MarketOrderSpecification;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class OrderTest {
    @Test
    public void testToMarketOrder() throws Exception {
        long instrument = 4001;
        String orderId = "my order 1";
        FixedPointNumber quantity = FixedPointNumber.valueOf("1.0");
        FixedPointNumber stopLossOffset = FixedPointNumber.valueOf("10.0");
        MarketOrderSpecification mos = new MarketOrderSpecification(instrument, orderId, quantity, TimeInForce.IMMEDIATE_OR_CANCEL,stopLossOffset, null);
        // {:instrument "EURUSD", :order-id "my order 1", :quantity "0.1", :stop-loss-offset "10", :order-type :market}
        assertEquals(mos.toString(),
                Order.toMarketOrder("{:instrument \"EURUSD\", :order-id \"my order 1\", :quantity 1, :stop-loss-offset 10}").toString());
    }

    @Ignore @Test
    public void testToAmendStopOrder() throws Exception {
        long instrument = 4001;
        String orderId = "my order 1";
        FixedPointNumber stopLossOffset = FixedPointNumber.valueOf(10);
        AmendStopsRequest request = new AmendStopsRequest(instrument, orderId, orderId, stopLossOffset, null);
        assertEquals(request,  // BUG equals useless and no toString
                Order.toAmendStopOrder("{:order-type :amend-stop, :instrument \"EURUSD\", :order-id \"my order 1\", :stop-loss-offset 10}"));
    }

    @Test
    public void testParseOrderType() throws Exception {
        assertEquals(Order.OrderType.MARKET, Order.parseOrderType("{:order-type :market}"));
        assertEquals(Order.OrderType.AMEND_STOP, Order.parseOrderType("{:order-type :amend-stop}"));
        assertEquals(Order.OrderType.UNKNOWN, Order.parseOrderType("{}"));
    }
}
@@ -353,24 +353,32 @@
 rTest %7B%0A    
+@Ignore 
 @Test%0A    pu
@@ -843,23 +843,23 @@
 r-id %22my
- 
+_
 order
- 
+_
 1%22, :qua
@@ -916,16 +916,18 @@
 market%7D%0A
+//
         
@@ -955,16 +955,18 @@
 ring(),%0A
+//
         
@@ -1029,31 +1029,31 @@
 rder-id %5C%22my
- 
+_
 order
- 
+_
 1%5C%22, :quanti
@@ -1424,32 +1424,34 @@
 sOffset, null);%0A
+//
         assertEq
@@ -1503,16 +1503,18 @@
 oString%0A
+//
         
@@ -1658,16 +1658,24 @@
  %7D%0A%0A    
+@Ignore 
 @Test%0A  

order test ignores all bc redo class