Click or drag to resize

Base algorithms

Along with Quoting, the S# contains the TraderHelper class, which includes a variety of simple trading algorithms methods:

  1. To clear the order book from its own orders through the GetFilteredQuotes(IEnumerableQuote, IEnumerableOrder, IEnumerableOrder) method (to register the orders in relation to other market players and to prevent own algorithms to fight each other):

    C#
    // the sample security
    var someSecurity = trader.Securities.First();
    
    var someOrders = new List<Order>();
    // fill the collection by own orders
    
    // to get the best big price
    Console.WriteLine(trader.GetMarketDepth(someSecurity).GetFilteredQuotes(Sides.Buy, someOrders, null).Max(q => q.Price));
  2. To adjust the price through the ShrinkPrice(Security, Decimal, ShrinkRules) method, so it become a multiple of price increment and trading system accepts the order:

    C#
    // the sample security
    var someSecurity = trader.Securities.First();
    Console.WriteLine(someSecurity.ShrinkPrice(13453.65342));
  3. To get the position on closed trades through the GetPosition method:

    C#
    Console.WriteLine(_trader.GetPosition(Portfolio,Security, clientCode, depoName);
  4. To check whether the current time traded (is session closed? is clearing started?) through the IsTradeTime method:

    C#
    // the sample security
    var someSecurity = trader.Securities.First();
    
    Console.WriteLine(someSecurity.Exchange.IsTradeTime(currentTime));
  5. The rest of the TraderHelper class methods are described in the Order cancel and Order replace sections.

See Also