Example #1
0
 public static Trade CreateTrade(Security security, System.DateTime datetime, double price, double volume, string tradeno, SmartCOM3Lib.StOrder_Action action)
 {
     return new Trade()
     {
         ID = tradeno,
         Time = datetime,
         Price = (decimal)price,
         Volume = (decimal)volume,
         Direction = SmartToSide(action).Value,
         Security = security
     };
 }
 public void CancelOrders(Security security = null, eSide? direction = null)
 {
     //TODO
 }
        private void _smartServer_UpdateBidAsk(string symbol, int row, int nrows, double bid, double bidsize, double ask, double asksize)
        {
            if (row == 0)
            {
                updateSecurity = this.Lookup(symbol, "symbol");
                updateSecurity.Depth.Update(row, nrows, bid, bidsize, ask, asksize);
            }
            else if (updateSecurity != null)
            {
                if (row < updateSecurity.Depth.Depth)
                {
                    updateSecurity.Depth.Update(row, nrows, bid, bidsize, ask, asksize);
                }

                if (updateSecurity.Depth.IsUpdate)
                {
                    updateSecurity.Depth.IsUpdate = false;
                    OnMarketDepthChanged(updateSecurity.Depth);
                    updateSecurity = null;
                }
            }

        }
        public Order CreateBuyLimit(Portfolio portfolio, Security security, decimal price, decimal volume)
        {
            ++_lastUserId;

            return new Order()
            {
                UserID = _lastUserId,
                Portfolio = portfolio,
                Security = security,
                Direction = eSide.Buy,
                Type = eOrderType.Limit,
                Price = price,
                Volume = volume
            };
        }
        public Order CreateBuyStopLimit(Portfolio portfolio, Security security, decimal volume)
        {
            ++_lastUserId;

            return new Order()
            {
                UserID = _lastUserId,
                Portfolio = portfolio,
                Security = security,
                Direction = eSide.Sell,
                Type = eOrderType.Market,
                Price = 1,
                Volume = volume
            };
        }
 public void RegisterMarketDepths(Security security)
 {
     if (!RegisteredMarketDepths.Contains(security))
     {
         _smartServer.ListenBidAsks(security.Symbol);
         RegisteredMarketDepths.Add(security);
     }
 }
 public void UnRegisterMarketDepths(Security security)
 {
     if (RegisteredMarketDepths.Contains(security))
     {
         _smartServer.CancelBidAsks(security.Symbol);
         RegisteredMarketDepths.Remove(security);
     }
 }
 public void UnRegisterSecurity(Security security)
 {
     if (RegisteredSecurities.Contains(security))
     {
         _smartServer.CancelQuotes(security.Symbol);
         RegisteredSecurities.Remove(security);
     }
 }
 public void RegisterSecurity(Security security)
 {
     if (!RegisteredSecurities.Contains(security))
     {
         _smartServer.ListenQuotes(security.Symbol);
         RegisteredSecurities.Add(security);
     }
 }
 public void UnRegisterTrades(Security security)
 {
     if (RegisteredTrades.Contains(security))
     {
         _smartServer.CancelTicks(security.Symbol);
         RegisteredTrades.Remove(security);
     }
 }
 public void RegisterTrades(Security security)
 {
     if (!RegisteredTrades.Contains(security))
     {
         _smartServer.ListenTicks(security.Symbol);
         RegisteredTrades.Add(security);
     }
 }
 private void OnNewSecurities(Security security, bool lastEvent)
 {
     if (NewSecurities != null) NewSecurities(security, lastEvent);
 }