Пример #1
0
        public IFSymbolExecute MarketInShort()
        {
            var l1 = ExecuteGetL1();

            if (l1.Symbol == null)
            {
                Error(String.Format("Cannot get Lv1 for {0}", Symbol));
            }

            if (GetStatus() == Fstatus.Error)
            {
                return(this);
            }

            var curOpenPos = api.GetOpenPositionForSymbol(Symbol);

            if (curOpenPos.Volume != 0 && curOpenPos.Side == "B")
            {
                api.FlattenSymbol(Symbol);
            }

            var remaining = GetRemainingShareFromOpenPos(curOpenPos);

            if (remaining > 0)
            {
                api.CancelSellOrdersForSymbol(Symbol);
                var sellPrice = l1.BidPrice;
                api.ExecuteOrder("Sell", Symbol, sellPrice, remaining);
                FLog.AddFormLogMessage(String.Format("Market In @{0}", sellPrice));
            }

            return(this);
        }
Пример #2
0
        public IFSymbolExecute OfferAtPrice(double price)
        {
            var curOpenPos = api.GetOpenPositionForSymbol(Symbol);

            if (curOpenPos.Volume != 0 && curOpenPos.Side == "B")
            {
                api.FlattenSymbol(Symbol);
            }

            var remaining = GetRemainingShareFromOpenPos(curOpenPos);

            api.CancelSellOrdersForSymbol(Symbol);
            api.ExecuteOrder("Sell", Symbol, price, remaining);
            FLog.AddFormLogMessage(String.Format("Offer In @{0}", price));

            return(this);
        }
Пример #3
0
        // Update Share Size for Exit
        public IFSymbol SetExitSharePercentage(int percent)
        {
            FLog.AddFormLogMessage(String.Format("Set the share size to {0} percent for {1}", percent, Symbol));

            var curOpenPos = api.GetOpenPositionForSymbol(Symbol);

            if (curOpenPos.Volume == 0)
            {
                return(this);
            }

            var newShare = initopenPos.Volume * percent / 100;

            ShareSize = Math.Abs(newShare);

            return(this);
        }
Пример #4
0
        public IFSymbolExecute ExitMarket()
        {
            var l1 = ExecuteGetL1();

            if (l1.Symbol == null)
            {
                Error(String.Format("Cannot get Lv1 for {0}", Symbol));
            }

            if (GetStatus() == Fstatus.Error)
            {
                return(this);
            }

            var curOpenPos = api.GetOpenPositionForSymbol(Symbol);

            var remaining = GetRemainingShareForExit(curOpenPos);

            if (remaining == 0)
            {
                return(this);
            }

            if (CurrentPositionType == FPositionType.Long)
            {
                var sellPrice = l1.BidPrice;
                api.ExecuteOrder("Sell", Symbol, sellPrice, remaining);
                FLog.AddFormLogMessage(String.Format("Market Out @{0} for {1} shares", sellPrice, remaining));
            }
            else if (CurrentPositionType == FPositionType.Short)
            {
                var buyPrice = l1.AskPrice;
                api.ExecuteOrder("Buy", Symbol, buyPrice, remaining);
                FLog.AddFormLogMessage(String.Format("Market Out @{0} for {1}", buyPrice, remaining));
            }

            return(this);
        }
Пример #5
0
        //private void Filled(string message)
        //{
        //    FLog.AddFormLogMessage(message);
        //    Result.Filled(message);
        //}

        private void Error(string message)
        {
            FLog.AddFormLogMessage(message);
            Result.Error(message);
        }
Пример #6
0
 public IFSymbolExecute FlatPosition()
 {
     FLog.AddFormLogMessage(String.Format("Executing Flat for {0},", Symbol));
     api.FlattenSymbol(Symbol);
     return(this);
 }