public string Comment; // This is a purely optional field. public Order(DateTimeOffset timestamp, int contractId, int strategyId, TradeAction action, PositiveInteger quantity, OrderType orderType, TimeInForce timeInForce, decimal desiredPrice) { // Orders are assigned an Id by the OMS, so until then, they have Id == -1. Id = -1; Timestamp = timestamp; ContractId = contractId; StrategyId = strategyId; Action = action; TotalQuantity = quantity; OrderType = orderType; TimeInForce = timeInForce; DesiredPrice = desiredPrice; Comment = ""; Purpose = CommonTypes.Purpose.Unspecified; }
public static Tuple <Order, StopLossOrder, TakeProfitOrder> OrderTriple(Market CurrentMarket, TradeAction Action, int ContractId, int StrategyId, PositiveInteger Quantity, decimal TakeProfit, decimal StopLoss, bool TrailingStopLoss) { decimal desiredPrice = (Action == TradeAction.Buy ? CurrentMarket.Ask : CurrentMarket.Bid); Order entry = MarketOrder(CurrentMarket.Timestamp, Action, ContractId, StrategyId, Quantity, desiredPrice); StopLossOrder stoploss = new StopLossOrder(entry, StopLoss, TrailingStopLoss); TakeProfitOrder takeprofit = new TakeProfitOrder(entry, TakeProfit); return(new Tuple <Order, StopLossOrder, TakeProfitOrder>(entry, stoploss, takeprofit)); }
// Quantity is absolute. public static Order MarketOrder(DateTimeOffset Timestamp, TradeAction Action, int ContractId, int StrategyId, PositiveInteger Quantity, decimal DesiredPrice) { Order o = new Order(Timestamp, ContractId, StrategyId, Action, Quantity, OrderType.Market, TimeInForce.Day, DesiredPrice); return(o); }
public static Order MarketOrder(Market CurrentMarket, TradeAction Action, int StrategyId, PositiveInteger Quantity) { return(MarketOrder(CurrentMarket.Timestamp, Action, CurrentMarket.ContractId, StrategyId, Quantity, (Action == CommonTypes.TradeAction.Buy ? CurrentMarket.Ask : CurrentMarket.Bid))); }
public Contract(int id, string symbol, string type, string exchange, string currency, string primaryExchange, int multiplier, string expiry, decimal strike, string right, string secIdType, string secId, string tradingClass, PositiveInteger lotSize) { IBContract = new IB.Contract(); Id = id; Symbol = symbol; Type = type; Exchange = exchange; PrimaryExchange = primaryExchange; Currency = currency; Multiplier = multiplier; LastTradeDateOrContractMonth = expiry; Strike = (double)strike; Right = right; SecIdType = secIdType; SecId = secId; TradingClass = tradingClass; }