Sterling API "access all open positions"

Basically what I'm interested in doing is accessing all open positions in sterling and sending a market order to close the position


How do you do this via the sterling API (to access all open positions) get the sides and the # of shares?

Thanks
 
You can do this in tradelink which is 100% free and open source, works with sterling and many other brokers :

http://tradelink.googlecode.com

here is the code to do this in a strategy/response :

Code:
public class MyResponse : ResponseTemplate
{
  // runs when you start the strategy
  override void Reset()
  { 
      foreach (Position p in pt)
         sendorder(new MarketOrderFlat(p));
  }
  PositionTracker pt = new PositionTracker();
   override void GotPosition(Position p)
  {
     pt.Adjust(p);
  }
}


here is the code to do this in an exe application
Code:
public static class Program
{
    static TLClient tl = new TLClient_WM();
    static PositionTracker pt = new PositionTracker();
     public static void Main(string[] args)
     {
           tl.gotPosition+=new PositionDelegate(pt.Adjust);
           tl.RequestPositions();
           // wait for positions to arrive
           System.Threading.Thread.Sleep(500);
           // close all flat positions
           foreach (Position p in pt)
               tl.SendOrder(new MarketOrderFlat(p));
     }
}

http://tradelink.googlecode.com
 
All the Screentoaster video tutorials are down, are there plans to reupload these to youtube? Some of the most important "how to" videos can't be accessed.

Thanks.
 
Back
Top