Пример #1
0
 public void OnBookingFailed(Trade newTrade)
 {
     _ready             = false;
     newTrade.Direction = SIGNAL_CODE.FAILED;
     newTrade.Id        = newTrade.Reference;
     newTrade.Publish();
 }
Пример #2
0
        protected virtual void OnBookingFailed(Trade newTrade)
        {
            _trades.Remove(newTrade);
            var pos = GetPosition(newTrade.Epic);

            if (pos != null)
            {
                pos.RemoveIncomingTrade(newTrade);
            }
            newTrade.Direction = SIGNAL_CODE.FAILED;
            newTrade.Id        = newTrade.Reference;
            newTrade.Publish();
        }
Пример #3
0
 bool openTrade(Dictionary <string, object> trade_notification)
 {
     lock (_incomingTrades)
     {
         string dealId = trade_notification["dealId"].ToString();
         if (_tradePositions.ContainsKey(dealId))
         {
             return(true);
         }
         Trade trade = null;
         bool  res   = false;
         if (AwaitingTrade)
         {
             res = pullTrade(_name, out trade);
         }
         else
         {
             _manualOverride = true;
             res             = true;
             Log.Instance.WriteEntry("Detected a manual position opening: " + _name + ". deal: " + dealId, System.Diagnostics.EventLogEntryType.Warning);
         }
         var reference = trade_notification["dealReference"].ToString();
         var direction = trade_notification["direction"].ToString() == "SELL" ? SIGNAL_CODE.SELL : SIGNAL_CODE.BUY;
         var tradeSize = int.Parse(trade_notification["size"].ToString());
         if (direction == SIGNAL_CODE.SELL)
         {
             tradeSize *= -1;
         }
         _lastTrade = trade;
         _tradePositions[dealId] = tradeSize;
         _quantity += tradeSize;
         if (_lastTrade != null)
         {
             _lastTrade.Id = dealId;
             _assetValue   = _lastTrade.Price;
             _lastTrade.Publish();
             Log.Instance.WriteEntry("Created a new trade: " + _lastTrade.Id);
         }
         return(res);
     }
 }