Exemplo n.º 1
0
        public UIController(List<BrokerManager> b, PositionManager pos, MainWindow w)
        {
            runningStrategy = null;
            cummulativePnL = 0;
            win = w;
            brokers = b;
            pos.PositionChange += new PositionChangedEventHandler(positionChange);
            pos.TradeMatched += new TradeMatchedEventHandler(tradeMatched);
            win.StrategyStart += new StrategyStartDelegate(startStrategy);
            win.StrategyStop += new StrategyStopDelegate(stopStrategy);

            //register to receive events from brokers
            foreach (BrokerManager brk in brokers)
            {
                brk.FillUpdate += new FillEventHandler(fillReceived);
                brk.OrderConfirmed += new OrderConfirmEventHandler(orderConfirmed);
                brk.RiskFilterFailure += new RiskFilterFailureEventHandler(riskFilterFailed);
                brk.LastUpdate += new LastUpdateEventHandler(lastUpdate);
            }

            Dictionary<int, String> strategyMap = new Dictionary<int, String>();
            strategyMap.Add(0, "Buy & Hold");
            strategyMap.Add(1, "Pair Trade");
            win.availableStrategies = strategyMap;
        }
Exemplo n.º 2
0
        static void Main()
        {
            //Initialize Position Manager
            FIFOTradeMatcher matcher = new FIFOTradeMatcher();
            PositionManager posMgr = new PositionManager(matcher);

            //Initialize Risk Engine
            SimplePositionLimtRiskFilter riskFilter = new SimplePositionLimtRiskFilter(posMgr);

            //Initialize Broker Managers
            brokers = new List<BrokerManager>();

            //Register to get a call back when this broker is ready to receive orders
            IBBrokerManager ibManager = new IBBrokerManager(riskFilter);
            ibManager.AcceptingOrders += new BrokerReadyEventHandler(readyToAcceptOrders);
            brokers.Add(ibManager);
            
            posMgr.addBrokers(brokers);

            ibManager.connect();

            //Create Main Window
            log.Info("Creating UI components");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //MainWindow win = new MainWindow(controller);
            MainWindow win = new MainWindow();

            //Create UI Controller
            UIController controller = new UIController(brokers, posMgr, win);

            Application.Run(win);
        }
 public PairsTradeParmForm(MainWindow win)
 {
     mainWindow = win;
     InitializeComponent();
 }
 public SimpleOneTickerParmForm(MainWindow win)
 {
     mainWindow = win;
     InitializeComponent();
 }