Exemple #1
0
 public void OnInitialize()
 {
     if (IsTrace)
     {
         Log.Trace(Strategy.FullName + ".Initialize()");
     }
     Strategy.Drawing.Color           = Color.Black;
     orders.buyMarket                 = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.buyMarket.TradeDirection  = TradeDirection.Exit;
     orders.buyMarket.Type            = OrderType.BuyMarket;
     orders.sellMarket                = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.sellMarket.TradeDirection = TradeDirection.Exit;
     orders.sellMarket.Type           = OrderType.SellMarket;
     orders.buyStop                  = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.buyStop.Type             = OrderType.BuyStop;
     orders.buyStop.TradeDirection   = TradeDirection.Exit;
     orders.sellStop                 = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.sellStop.Type            = OrderType.SellStop;
     orders.sellStop.TradeDirection  = TradeDirection.Exit;
     orders.sellStop.Tag             = "ExitCommon";
     orders.buyLimit                 = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.buyLimit.Type            = OrderType.BuyLimit;
     orders.buyLimit.TradeDirection  = TradeDirection.Exit;
     orders.sellLimit                = Factory.Engine.LogicalOrder(Strategy.Data.SymbolInfo, Strategy);
     orders.sellLimit.Type           = OrderType.SellLimit;
     orders.sellLimit.TradeDirection = TradeDirection.Exit;
     Strategy.AddOrder(orders.buyMarket);
     Strategy.AddOrder(orders.sellMarket);
     Strategy.AddOrder(orders.buyStop);
     Strategy.AddOrder(orders.sellStop);
     Strategy.AddOrder(orders.buyLimit);
     Strategy.AddOrder(orders.sellLimit);
     position = Strategy.Position;
 }
 public void OnInitialize()
 {
     if (IsTrace)
     {
         Log.Trace(Strategy.FullName + ".Initialize()");
     }
     Strategy.Drawing.Color = Color.Black;
     position = Strategy.Position;
 }
        public Tracker(ClientContext context, String path)
        {
            rollValue = pitchValue = yawValue = 0.0f;

            poseInterface        = context.GetPoseInterface(path);
            positionInterface    = context.GetPositionInterface(path);
            orientationInterface = context.GetOrientationInterface(path);

            poseInterface.StateChanged        += PoseInterface_StateChanged;
            positionInterface.StateChanged    += PositionInterface_StateChanged;
            orientationInterface.StateChanged += OrientationInterface_StateChanged;
        }
Exemple #4
0
        public Strategy()
        {
            var logName = this.GetType().FullName;

            if (this.GetType().Name != Name)
            {
                logName += "." + Name;
            }
            instanceLog = Factory.SysLog.GetLogger(logName);
            debug       = instanceLog.IsDebugEnabled;
            trace       = instanceLog.IsTraceEnabled;
            position    = new PositionCommon(this);
            if (trace)
            {
                instanceLog.Trace("Constructor");
            }
            Chain.Dependencies.Clear();
            isStrategy = true;
            result     = new Result(this);

            exitActiveNow            = new ExitCommon(this);
            enterActiveNow           = new EnterCommon(this);
            reverseActiveNow         = new ReverseCommon(this);
            changeActiveNow          = new ChangeCommon(this);
            changeNextBar            = new ChangeCommon(this);
            changeNextBar.Orders     = changeActiveNow.Orders;
            changeNextBar.IsNextBar  = true;
            reverseNextBar           = new ReverseCommon(this);
            reverseNextBar.Orders    = reverseActiveNow.Orders;
            reverseNextBar.IsNextBar = true;
            exitNextBar            = new ExitCommon(this);
            exitNextBar.Orders     = exitActiveNow.Orders;
            exitNextBar.IsNextBar  = true;
            enterNextBar           = new EnterCommon(this);
            enterNextBar.Orders    = enterActiveNow.Orders;
            enterNextBar.IsNextBar = true;
            orders = new OrderHandlers(enterActiveNow, enterNextBar,
                                       exitActiveNow, exitNextBar,
                                       reverseActiveNow, reverseNextBar,
                                       changeActiveNow, changeNextBar);

            // Interceptors.
            performance  = new Performance(this);
            exitStrategy = new ExitStrategy(this);

            preFillManager                       = new FillManager(this);
            postFillManager                      = new FillManager(this);
            postFillManager.PostProcess          = true;
            postFillManager.ChangePosition       = exitStrategy.Position.Change;
            postFillManager.DoStrategyOrders     = false;
            postFillManager.DoStrategyOrders     = false;
            postFillManager.DoExitStrategyOrders = true;
        }
        public Tracker(ClientContext context, String path)
        {
            rollValue = pitchValue = yawValue = 0.0f;

            poseInterface = context.GetPoseInterface(path);
            positionInterface = context.GetPositionInterface(path);
            orientationInterface = context.GetOrientationInterface(path);

            poseInterface.StateChanged += PoseInterface_StateChanged;
            positionInterface.StateChanged += PositionInterface_StateChanged;
            orientationInterface.StateChanged += OrientationInterface_StateChanged;
        }
        public StrategyTest()
        {
            position  = new PositionCommon(this);
            drawing   = new DrawingCommon(this);
            indicator = Doubles();

            if (trace)
            {
                log.Trace(GetType().Name + ".new");
            }
            name  = GetType().Name;
            chain = Factory.Engine.Chain(this);
        }
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
			using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
            {
                // This is just one of the paths. You can also use:
                // /me/hands/right
                // /me/head
                using (Interface lefthand = context.getInterface("/me/hands/left"))
                {

                    TrackerCallbacks callbacks = new TrackerCallbacks();
                    // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                    var poseInterface = new PoseInterface(lefthand);
                    poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                    // If you just want orientation
                    var orientationInterface = new OrientationInterface(lefthand);
                    orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                    // or position
                    var positionInterface = new PositionInterface(lefthand);
                    positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                    bool resetYawMode = false;
                    // Pretend that this is your application's main loop
                    for (int i = 0; i < 1000000; ++i)
                    {
                        // toggle between reset yaw mode and normal mode
                        // every 5000 iterations.
                        if (i % 5000 == 0)
                        {
                            resetYawMode = !resetYawMode;
                            if(resetYawMode)
                            {
                                context.SetRoomRotationUsingHead();
                            }
                            else
                            {
                                context.ClearRoomToWorldTransform();
                            }
                        }
                        context.update();
                    }

                    Console.WriteLine("Library shut down; exiting.");
                }
            }
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
            using (ServerAutoStarter serverAutoStarter = new ServerAutoStarter())
                using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
                {
                    // This is just one of the paths. You can also use:
                    // /me/hands/right
                    // /me/head
                    using (Interface lefthand = context.getInterface("/me/hands/left"))
                    {
                        TrackerCallbacks callbacks = new TrackerCallbacks();
                        // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                        var poseInterface = new PoseInterface(lefthand);
                        poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                        // If you just want orientation
                        var orientationInterface = new OrientationInterface(lefthand);
                        orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                        // or position
                        var positionInterface = new PositionInterface(lefthand);
                        positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                        bool resetYawMode = false;
                        // Pretend that this is your application's main loop
                        for (int i = 0; i < 1000000; ++i)
                        {
                            // toggle between reset yaw mode and normal mode
                            // every 5000 iterations.
                            if (i % 5000 == 0)
                            {
                                resetYawMode = !resetYawMode;
                                if (resetYawMode)
                                {
                                    context.SetRoomRotationUsingHead();
                                }
                                else
                                {
                                    context.ClearRoomToWorldTransform();
                                }
                            }
                            context.update();
                        }

                        Console.WriteLine("Library shut down; exiting.");
                    }
                }
        }
        public void Copy(PositionInterface _other)
        {
            PositionCommon other = _other as PositionCommon;

            if (other != null)
            {
                if (current != other.Current)
                {
                    Change(other.current, other.price, other.time);
                }
            }
            else
            {
                throw new ApplicationException("Expected concrete class " + typeof(PositionCommon).Name);
            }
        }
Exemple #10
0
    public Action Start()
    {
        //OSVR clients need an identifier
        context = new ClientContext("com.osvr.freepieClient");

        //OSVR interface for the head
        Interface head = context.getInterface("/me/head");

        //If you just want orientation
        orientationInterface = new OrientationInterface(head);
        positionInterface    = new PositionInterface(head);
        //add orientation callback
        orientationInterface.StateChanged += OrientationInterface_StateChanged;
        positionInterface.StateChanged    += PositionInterface_StateChanged;
        context.SetRoomRotationUsingHead(); //recenters the hmd position to the current position
        return(null);
    }
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
            using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
            {
                // This is just one of the paths. You can also use:
                // /me/hands/right
                // /me/head
                using (Interface lefthand = context.getInterface("/me/hands/left"))
                {

                    TrackerCallbacks callbacks = new TrackerCallbacks();
                    // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                    var poseInterface = new PoseInterface(lefthand);
                    poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                    // If you just want orientation
                    var orientationInterface = new OrientationInterface(lefthand);
                    orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                    // or position
                    var positionInterface = new PositionInterface(lefthand);
                    positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                    // Pretend that this is your application's main loop
                    for (int i = 0; i < 1000000; ++i)
                    {
                        context.update();
                    }

                    Console.WriteLine("Library shut down; exiting.");
                }
            }
        }
Exemple #12
0
        // note: in .net > 2, the preferred way is to create an extension method instead.
        public static Vector3fPositionInterface GetVector3fPositionInterface(ClientContext context, string path)
        {
            var positionInterface = PositionInterface.GetInterface(context, path);

            return(new Vector3fPositionInterface(positionInterface));
        }
Exemple #13
0
 public StrategyWatcher(StrategyInterface strategy)
 {
     this.strategy = strategy;
     this.position = strategy.Result.Position;
 }