コード例 #1
0
ファイル: StrategyProc.cs プロジェクト: axs/ezspreader
        private void checkSpreadLevel( SpreadOrder so )
        {
            double[] mktprices = findPrices(so.buySell);
            double mktlevel = mktprices[2];

            Order[] o = so.getLegs();
            double[] wkprices = so.workPrices();

            //the sell leg is off mkt
            if (so.buySell == "Buy" && o[1].Price > market.ask(o[1].IPROC.Product) )
            {
                if (log.IsDebugEnabled)
                    log.Debug("BUY: sell leg is off mkt shift spread lower");

                //lower sell leg
                CancelReplace( o[1].buySell
                              ,o[1].SOK
                              ,o[1].IPROC
                              ,o[1].WkQty
                              ,1 );

                //lower the buy leg
                CancelReplace( o[0].buySell
                              ,o[0].SOK
                              ,o[0].IPROC
                              ,o[0].WkQty
                              ,-1 );

                o[1].Price = market.ask(o[1].IPROC.Product) - o[1].IPROC.TickPrice;
                o[0].Price = market.bid(o[0].IPROC.Product) - o[0].IPROC.TickPrice;
            }

                //the buy leg is off mkt
            else if (so.buySell == "Buy" && o[0].Price < market.bid(o[0].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                    log.Debug("BUY: buy leg is off mkt shift spread higher");

                //higher sell leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , -1);

                //higher the buy leg
                CancelReplace(o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , 1);

                o[1].Price = market.ask(o[1].IPROC.Product) + o[1].IPROC.TickPrice;
                o[0].Price = market.bid(o[0].IPROC.Product) + o[0].IPROC.TickPrice;
            }

            //the sell leg is off mkt
            else if (so.buySell == "Sell" && o[0].Price > market.ask(o[0].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                    log.Debug("SELL: sell leg is off mkt shift spread lower");

                //lower sell leg
                CancelReplace( o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , 1);

                //lower the buy leg
                CancelReplace( o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , -1);

                o[0].Price = market.ask(o[0].IPROC.Product) - o[0].IPROC.TickPrice;
                o[1].Price = market.bid(o[1].IPROC.Product) - o[1].IPROC.TickPrice;
            }

            //the buy leg is off mkt
            else if (so.buySell == "Sell" && o[1].Price < market.bid(o[1].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                    log.Debug("SELL: buy leg is off mkt shift spread higher");

                //higher sell leg
                CancelReplace( o[0].buySell
                              ,o[0].SOK
                              ,o[0].IPROC
                              ,o[0].WkQty
                              ,-1);

                //higher the buy leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , 1);

                o[0].Price = market.ask(o[0].IPROC.Product) + o[0].IPROC.TickPrice;
                o[1].Price = market.bid(o[1].IPROC.Product) + o[1].IPROC.TickPrice;
            }
        }
コード例 #2
0
        private void checkSpreadLevel(SpreadOrder so)
        {
            double[] mktprices = findPrices(so.buySell);
            double   mktlevel  = mktprices[2];

            Order[]  o        = so.getLegs();
            double[] wkprices = so.workPrices();

            //the sell leg is off mkt
            if (so.buySell == "Buy" && o[1].Price > market.ask(o[1].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("BUY: sell leg is off mkt shift spread lower");
                }

                //lower sell leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , 1);

                //lower the buy leg
                CancelReplace(o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , -1);

                o[1].Price = market.ask(o[1].IPROC.Product) - o[1].IPROC.TickPrice;
                o[0].Price = market.bid(o[0].IPROC.Product) - o[0].IPROC.TickPrice;
            }

            //the buy leg is off mkt
            else if (so.buySell == "Buy" && o[0].Price < market.bid(o[0].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("BUY: buy leg is off mkt shift spread higher");
                }

                //higher sell leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , -1);

                //higher the buy leg
                CancelReplace(o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , 1);

                o[1].Price = market.ask(o[1].IPROC.Product) + o[1].IPROC.TickPrice;
                o[0].Price = market.bid(o[0].IPROC.Product) + o[0].IPROC.TickPrice;
            }

            //the sell leg is off mkt
            else if (so.buySell == "Sell" && o[0].Price > market.ask(o[0].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("SELL: sell leg is off mkt shift spread lower");
                }


                //lower sell leg
                CancelReplace(o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , 1);

                //lower the buy leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , -1);

                o[0].Price = market.ask(o[0].IPROC.Product) - o[0].IPROC.TickPrice;
                o[1].Price = market.bid(o[1].IPROC.Product) - o[1].IPROC.TickPrice;
            }

            //the buy leg is off mkt
            else if (so.buySell == "Sell" && o[1].Price < market.bid(o[1].IPROC.Product))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("SELL: buy leg is off mkt shift spread higher");
                }

                //higher sell leg
                CancelReplace(o[0].buySell
                              , o[0].SOK
                              , o[0].IPROC
                              , o[0].WkQty
                              , -1);

                //higher the buy leg
                CancelReplace(o[1].buySell
                              , o[1].SOK
                              , o[1].IPROC
                              , o[1].WkQty
                              , 1);

                o[0].Price = market.ask(o[0].IPROC.Product) + o[0].IPROC.TickPrice;
                o[1].Price = market.bid(o[1].IPROC.Product) + o[1].IPROC.TickPrice;
            }
        }