Esempio n. 1
0
 public static bool InstrumentTypeToSecurityType(OQ.InstrumentType instrType, out IB.SecurityType secType)
 {
     secType = SecurityType.Undefined;
     switch (instrType)
     {
         case InstrumentType.Bond:
             secType = SecurityType.Bond;
             break;
         case InstrumentType.ETF:
             secType = SecurityType.Stock;
             break;
         case InstrumentType.FX:
             secType = SecurityType.Cash;
             break;
         case InstrumentType.FutOpt:
             secType = SecurityType.FutureOption;
             break;
         case InstrumentType.Futures:
             secType = SecurityType.Future;
             break;
         case InstrumentType.Index:
             secType = SecurityType.Index;
             break;
         case InstrumentType.Option:
             secType = SecurityType.Option;
             break;
         case InstrumentType.Stock:
             secType = SecurityType.Stock;
             break;
         case InstrumentType.MultiLeg:
         default:
             return false;
     }
     return true;
 }
Esempio n. 2
0
 public static bool FAAllocationMethodTOIBFAMethod(IB.FinancialAdvisorAllocationMethod ibFaMethod,
     out OQ.IBFaMethod oqFaMethod)
 {
     oqFaMethod = IBFaMethod.Undefined;
     switch (ibFaMethod)
     {
         case FinancialAdvisorAllocationMethod.AvailableEquity:
             oqFaMethod = IBFaMethod.AvailableEquity;
             break;
         case FinancialAdvisorAllocationMethod.EqualQuantity:
             oqFaMethod = IBFaMethod.EqualQuantity;
             break;
         case FinancialAdvisorAllocationMethod.NetLiquidity:
             oqFaMethod = IBFaMethod.NetLiq;
             break;
         case FinancialAdvisorAllocationMethod.PercentChange:
             oqFaMethod = IBFaMethod.PctChange;
             break;
         case FinancialAdvisorAllocationMethod.None:
         default:
             return false;
     }
     return true;
 }
Esempio n. 3
0
 public static bool OrderStateToOrderStatus(IB.OrderStatus ibstatus, out OQ.OrderStatus status)
 {
     status = OQ.OrderStatus.New;
     switch (ibstatus)
     {
         case IB.OrderStatus.ApiCancelled:
         case IB.OrderStatus.Canceled:
             status = OQ.OrderStatus.Cancelled;
             break;
         case IB.OrderStatus.Inactive:
         case IB.OrderStatus.ApiPending:
         case IB.OrderStatus.PendingSubmit:
         case IB.OrderStatus.PreSubmitted:
         case IB.OrderStatus.Submitted:
             status = OQ.OrderStatus.PendingNew;
             break;
         case IB.OrderStatus.Filled:
             status = OQ.OrderStatus.Filled;
             break;
         case IB.OrderStatus.PartiallyFilled:
             status = OQ.OrderStatus.PartiallyFilled;
             break;
         case IB.OrderStatus.PendingCancel:
             status = OQ.OrderStatus.PendingCancel;
             break;
         default:
         case IB.OrderStatus.Unknown:
             return false;
     }
     return true;
 }
Esempio n. 4
0
 public static bool OrderTypeToOrderType(IB.OrderType ibordertype, out OQ.OrderType oqordertype)
 {
     oqordertype = OQ.OrderType.Market;
     switch (ibordertype)
     {
         case IB.OrderType.Limit:
         case IB.OrderType.LimitOnClose:
             oqordertype = OQ.OrderType.Limit;
             break;
         case IB.OrderType.Market:
             oqordertype = OQ.OrderType.Market;
             break;
         case IB.OrderType.MarketOnClose:
             oqordertype = OQ.OrderType.MarketOnClose;
             break;
         case IB.OrderType.Stop:
             oqordertype = OQ.OrderType.Stop;
             break;
         case IB.OrderType.StopLimit:
             oqordertype = OQ.OrderType.StopLimit;
             break;
         case IB.OrderType.TrailingStop:
             oqordertype = OQ.OrderType.Trail;
             break;
         case IB.OrderType.TrailingStopLimit:
             oqordertype = OQ.OrderType.TrailLimit;
             break;
         default:
         case IB.OrderType.Volatility:
         case IB.OrderType.VolumeWeightedAveragePrice:
         case IB.OrderType.Scale:
         case IB.OrderType.Relative:
         case IB.OrderType.PeggedToMarket:
         case IB.OrderType.Default:
         case IB.OrderType.Empty:
             return false;
     }
     return true;
 }
Esempio n. 5
0
        public static bool OQTimeInForceToIBTimeInForce(OQ.TimeInForce oqtif, out IB.TimeInForce ibtif)
        {
            ibtif = IB.TimeInForce.Undefined;
            switch (oqtif)
            {

                case OQ.TimeInForce.Day:
                    ibtif = IB.TimeInForce.Day;
                    break;
                case OQ.TimeInForce.FOK:
                    ibtif = IB.TimeInForce.FillOrKill;
                    break;
                case OQ.TimeInForce.GTC:
                    ibtif = IB.TimeInForce.GoodTillCancel;
                    break;
                case OQ.TimeInForce.GTD:
                    ibtif = IB.TimeInForce.GoodTillDate;
                    break;
                case OQ.TimeInForce.OPG:
                    ibtif = IB.TimeInForce.MarketOnOpen;
                    break;
                case OQ.TimeInForce.ATC:
                case OQ.TimeInForce.GFS:
                case OQ.TimeInForce.GTX:
                case OQ.TimeInForce.IOC:
                default:
                    return false;
            }
            return true;
        }
Esempio n. 6
0
 public static bool OQOrderTypeToIBOrderType(OQ.OrderType oqtype, out IB.OrderType ibtype)
 {
     ibtype = IB.OrderType.Empty;
     switch (oqtype)
     {
         case OQ.OrderType.Limit:
             ibtype = IB.OrderType.Limit;
             break;
         case OQ.OrderType.Market:
             ibtype = IB.OrderType.Market;
             break;
         case OQ.OrderType.MarketOnClose:
             ibtype = IB.OrderType.MarketOnClose;
             break;
         case OQ.OrderType.Stop:
             ibtype = IB.OrderType.Stop;
             break;
         case OQ.OrderType.StopLimit:
             ibtype = IB.OrderType.StopLimit;
             break;
         case OQ.OrderType.Trail:
             ibtype = IB.OrderType.TrailingStop;
             break;
         case OQ.OrderType.TrailLimit:
             ibtype = IB.OrderType.TrailingStopLimit;
             break;
         default:
             return false;
     }
     return true;
 }
Esempio n. 7
0
 public static bool OQFAMethodTOIBFAMethod(OQ.IBFaMethod oqFaMethod,
     out IB.FinancialAdvisorAllocationMethod ibFaMethod)
 {
     ibFaMethod = FinancialAdvisorAllocationMethod.None;
     switch (oqFaMethod)
     {
         case IBFaMethod.AvailableEquity:
             ibFaMethod = FinancialAdvisorAllocationMethod.AvailableEquity;
             break;
         case IBFaMethod.EqualQuantity:
             ibFaMethod = FinancialAdvisorAllocationMethod.EqualQuantity;
             break;
         case IBFaMethod.NetLiq:
             ibFaMethod = FinancialAdvisorAllocationMethod.NetLiquidity;
             break;
         case IBFaMethod.PctChange:
             ibFaMethod = FinancialAdvisorAllocationMethod.PercentChange;
             break;
         case IBFaMethod.Undefined:
             ibFaMethod = FinancialAdvisorAllocationMethod.None;
             break;
         default:
             return false;
     }
     return true;
 }
 private void AcceptOrder(int orderId, IB.Contract contract, IB.Order order)
 {
     int filled = 0;
     int remaining = order.TotalQuantity;
     // Accept
     mockIBClient.Raise(ib => ib.OrderStatus += null,
         new OrderStatusEventArgs(orderId, IB.OrderStatus.Submitted, filled, remaining,
                                  (decimal)order.LimitPrice, 333333, 0, (decimal)0.0, order.ClientId, ""));
 }
        public bool MatchOrders(IB.Order expected, IB.Order actual)
        {
            Assert.AreEqual(expected.Account, actual.Account, "Order.Account");
            Assert.AreEqual(expected.Action, actual.Action, "Order.Action");
            Assert.AreEqual(expected.ClientId, actual.ClientId, "Order.ClientId");
            Assert.AreEqual(expected.OcaGroup, actual.OcaGroup, "Order.OcaGroup");
            Assert.AreEqual(expected.OrderId, actual.OrderId, "Order.OrderId");
            Assert.AreEqual(expected.TotalQuantity, actual.TotalQuantity, "Order.TotalQuantity");
            Assert.AreEqual((double)expected.LimitPrice, (double)actual.LimitPrice, 0.05, "Order.LimitPrice");
            Assert.AreEqual((double)expected.AuxPrice, (double)actual.AuxPrice, 0.005, "Order.AuxPrice");
            Assert.AreEqual(expected.Tif, actual.Tif, "Order.Tif");
            Assert.AreEqual(expected.OrderType, actual.OrderType, "Order.OrderType");

            return true;
        }