Example #1
0
 public StopOrderTransaction(TransactionID id, DateTime time, int userID, AccountID accountID, TransactionID batchID, RequestID requestID, TransactionType type, InstrumentName instrument, double units, PriceValue price, PriceValue priceBound, TimeInForce timeInForce, DateTime gTDTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, StopOrderReason reason, ClientExtensions clientExtensions, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, OrderID replacesOrderID, TransactionID cancellingTransactionID)
 {
     this.Id                      = id;
     this.Time                    = time;
     this.UserID                  = userID;
     this.AccountID               = accountID;
     this.BatchID                 = batchID;
     this.RequestID               = requestID;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.PriceBound              = priceBound;
     this.TimeInForce             = timeInForce;
     this.GTDTime                 = gTDTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.Reason                  = reason;
     this.ClientExtensions        = clientExtensions;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.ReplacesOrderID         = replacesOrderID;
     this.CancellingTransactionID = cancellingTransactionID;
 }
Example #2
0
 public StopOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, PriceValue price, PriceValue priceBound, TimeInForce timeInForce, DateTime gtdTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime, OrderID replacesOrderID, OrderID replacedByOrderID)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.PriceBound              = priceBound;
     this.TimeInForce             = timeInForce;
     this.GtdTime                 = gtdTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
     this.ReplacesOrderID         = replacesOrderID;
     this.ReplacedByOrderID       = replacedByOrderID;
 }
Example #3
0
 public MarketOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.MARKET);
     this.Instrument              = new InstrumentName();
     this.TimeInForce             = new TimeInForce(ETimeInForce.FOK);
     this.PriceBound              = new PriceValue();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TradeClose              = new MarketOrderTradeClose();
     this.LongPositionCloseout    = new MarketOrderPositionCloseout();
     this.ShortPositionCloseout   = new MarketOrderPositionCloseout();
     this.MarginCloseout          = new MarketOrderMarginCloseout();
     this.DelayedTradeClose       = new MarketOrderDelayedTradeClose();
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
 }
Example #4
0
 public StopOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.STOP);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.PriceBound              = new PriceValue();
     this.TimeInForce             = new TimeInForce(ETimeInForce.GTC);
     this.GtdTime                 = new DateTime();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TriggerCondition        = new OrderTriggerCondition(EOrderTriggerCondition.DEFAULT);
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
     this.ReplacesOrderID         = new OrderID();
     this.ReplacedByOrderID       = new OrderID();
 }
Example #5
0
 public MarketOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, TimeInForce timeInForce, PriceValue priceBound, OrderPositionFill positionFill, MarketOrderTradeClose tradeClose, MarketOrderPositionCloseout longPositionCloseout, MarketOrderPositionCloseout shortPositionCloseout, MarketOrderMarginCloseout marginCloseout, MarketOrderDelayedTradeClose delayedTradeClose, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.TimeInForce             = timeInForce;
     this.PriceBound              = priceBound;
     this.PositionFill            = positionFill;
     this.TradeClose              = tradeClose;
     this.LongPositionCloseout    = longPositionCloseout;
     this.ShortPositionCloseout   = shortPositionCloseout;
     this.MarginCloseout          = marginCloseout;
     this.DelayedTradeClose       = delayedTradeClose;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
 }
Example #6
0
 public MarketOrderRejectTransaction(
     TransactionID id,
     DateTime time,
     int userId,
     AccountID accountID,
     TransactionID batchID,
     RequestID requestID,
     TransactionType type,
     InstrumentName instrument,
     double units,
     TimeInForce timeInForce,
     PriceValue priceBound,
     OrderPositionFill positionFill,
     MarketOrderTradeClose tradeClose,
     MarketOrderPositionCloseout longPositionCloseout,
     MarketOrderPositionCloseout shortPositionCloseout,
     MarketOrderMarginCloseout marginCloseout,
     MarketOrderDelayedTradeClose delayedTradeClose,
     MarketOrderReason reason,
     ClientExtensions clientExtensions,
     TakeProfitDetails takeProfitOnFill,
     StopLossDetails stopLossOnFill,
     TrailingStopLossDetails trailingStopLossOnFill,
     ClientExtensions tradeClientExtensions,
     TransactionRejectReason rejectReason
     )
 {
     this.Id                     = id;
     this.Time                   = time;
     this.UserId                 = userId;
     this.AccountID              = accountID;
     this.BatchID                = batchID;
     this.RequestID              = requestID;
     this.Type                   = type;
     this.Instrument             = instrument;
     this.Units                  = units;
     this.TimeInForce            = timeInForce;
     this.PriceBound             = priceBound;
     this.PositionFill           = positionFill;
     this.TradeClose             = tradeClose;
     this.LongPositionCloseout   = longPositionCloseout;
     this.ShortPositionCloseout  = shortPositionCloseout;
     this.MarginCloseout         = marginCloseout;
     this.DelayedTradeClose      = delayedTradeClose;
     this.Reason                 = reason;
     this.ClientExtensions       = clientExtensions;
     this.TakeProfitOnFill       = takeProfitOnFill;
     this.StopLossOnFill         = stopLossOnFill;
     this.TrailingStopLossOnFill = trailingStopLossOnFill;
     this.TradeClientExtensions  = tradeClientExtensions;
     this.RejectReason           = rejectReason;
 }
Example #7
0
        /// <summary>
        /// Open a new trade for the account asynchronously
        /// </summary>
        /// <param name="instrument">The name of the instrument</param>
        /// <param name="direction">The direction of the trade</param>
        /// <param name="units">Units to buy</param>
        /// <param name="trailingStopLossInPips">The trailing stoploss in pips</param>
        /// <returns>The created trade order</returns>
        public async Task <ClientModel.CreateOrderResponse> OpenTradeAsync(ClientModel.InstrumentName instrument, TradeDirection direction, long units, int trailingStopLossInPips)
        {
            // TODO: check if market is open
            // TODO: add more possibilities here to create different kinds of MarketOrders (take the profit, stop loss etc)
            // TODO: type is missing from orders should be fixed on yaml level
            var trailingStopLoss = new TrailingStopLossDetails(ResolvePipToUnits(instrument, trailingStopLossInPips));
            var order            = new MarketOrder(instrument, units * ResolveDiretionToMultiplier(direction), trailingStopLossOnFill: trailingStopLoss);

            return(await _connection.OrderApi.CreateOrderAsync(_accountId, new CreateOrderRequest(new
            {
                Instrument = order.Instrument,
                Units = order.Units,
                TrailingStopLossOnFill = order.TrailingStopLossOnFill,
                Type = "MARKET"
            })));
        }
 public FixedPriceOrderTransaction()
 {
     this.Id                     = new TransactionID();
     this.Time                   = new DateTime();
     this.AccountID              = new AccountID();
     this.BatchID                = new TransactionID();
     this.RequestID              = new RequestID();
     this.Type                   = new TransactionType(ETransactionType.FIXED_PRICE_ORDER);
     this.Instrument             = new InstrumentName();
     this.Price                  = new PriceValue();
     this.PositionFill           = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.Reason                 = new FixedPriceOrderReason();
     this.ClientExtensions       = new ClientExtensions();
     this.TakeProfitOnFill       = new TakeProfitDetails();
     this.StopLossOnFill         = new StopLossDetails();
     this.TrailingStopLossOnFill = new TrailingStopLossDetails();
     this.TradeClientExtensions  = new ClientExtensions();
 }
        public static IHasPrices Create(string type)
        {
            IHasPrices priceObject;

            switch (type)
            {
            case "OkonkwoOandaV20.TradeLibrary.Transaction.TakeProfitDetails":
                priceObject = new TakeProfitDetails(); break;

            case "OkonkwoOandaV20.TradeLibrary.Transaction.StopLossDetails":
                priceObject = new StopLossDetails(); break;

            case "OkonkwoOandaV20.TradeLibrary.Transaction.TrailingStopLossDetails":
                priceObject = new TrailingStopLossDetails(); break;

            default: priceObject = null; break;
            }

            return(priceObject);
        }
 public FixedPriceOrderTransaction(
     TransactionID id,
     DateTime time,
     int userId,
     AccountID accountID,
     TransactionID batchID,
     RequestID requestID,
     TransactionType type,
     InstrumentName instrument,
     double units,
     PriceValue price,
     OrderPositionFill positionFill,
     string tradeState,
     FixedPriceOrderReason reason,
     ClientExtensions clientExtensions,
     TakeProfitDetails takeProfitOnFill,
     StopLossDetails stopLossOnFill,
     TrailingStopLossDetails trailingStopLossOnFill,
     ClientExtensions tradeClientExtensions
     )
 {
     this.Id                     = id;
     this.Time                   = time;
     this.UserId                 = userId;
     this.AccountID              = accountID;
     this.BatchID                = batchID;
     this.RequestID              = requestID;
     this.Type                   = type;
     this.Instrument             = instrument;
     this.Units                  = units;
     this.Price                  = price;
     this.PositionFill           = positionFill;
     this.TradeState             = tradeState;
     this.Reason                 = reason;
     this.ClientExtensions       = clientExtensions;
     this.TakeProfitOnFill       = takeProfitOnFill;
     this.StopLossOnFill         = stopLossOnFill;
     this.TrailingStopLossOnFill = trailingStopLossOnFill;
     this.TradeClientExtensions  = tradeClientExtensions;
 }
Example #11
0
 public FixedPriceOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.FIXED_PRICE);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
 }
Example #12
0
 public LimitOrderRejectTransaction()
 {
     this.Id                      = new TransactionID();
     this.Time                    = new DateTime();
     this.AccountID               = new AccountID();
     this.BatchID                 = new TransactionID();
     this.RequestID               = new RequestID();
     this.Type                    = new TransactionType(ETransactionType.LIMIT_ORDER_REJECT);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.TimeInForce             = new TimeInForce();
     this.GTDTime                 = new DateTime();
     this.PositionFill            = new OrderPositionFill();
     this.TriggerCondition        = new OrderTriggerCondition(EOrderTriggerCondition.DEFAULT);
     this.Reason                  = new LimitOrderReason();
     this.ClientExtensions        = new ClientExtensions();
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.IntendedReplacesOrderID = new OrderID();
     this.RejectReason            = new TransactionRejectReason();
 }
Example #13
0
 public StopOrderTransaction()
 {
     this.Id                      = new TransactionID();
     this.Time                    = new DateTime();
     this.AccountID               = new AccountID();
     this.BatchID                 = new TransactionID();
     this.RequestID               = new RequestID();
     this.Type                    = new TransactionType(ETransactionType.STOP_ORDER);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.PriceBound              = new PriceValue();
     this.TimeInForce             = new TimeInForce(ETimeInForce.GTC);
     this.GTDTime                 = new DateTime();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TriggerCondition        = new OrderTriggerCondition(EOrderTriggerCondition.DEFAULT);
     this.Reason                  = new StopOrderReason();
     this.ClientExtensions        = new ClientExtensions();
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.ReplacesOrderID         = new OrderID();
     this.CancellingTransactionID = new TransactionID();
 }
Example #14
0
 public FixedPriceOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, PriceValue price, OrderPositionFill positionFill, string tradeState, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.PositionFill            = positionFill;
     this.TradeState              = tradeState;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
 }
Example #15
0
 public virtual void SetTrailingStopLoss(string action, TrailingStopLossDetails details)
 {
     trailingStopLossAction = action;
     trailingStopLoss       = action == TradeOrdersAction.Cancel ? null : details;
 }
 public PutTradeOrderRequest(TrailingStopLossDetails value)
 {
     this.TrailingStopLoss = value;
 }