Example #1
0
        // Basic: Set Action (Entry or Exit)
        public IFSymbol SetFActionType(FActionType t)
        {
            FActionType = t;
            if (t == FActionType.Exit)
            {
                initopenPos = api.GetOpenPositionForSymbol(Symbol);
            }

            return(this);
        }
Example #2
0
        public void ExecuteSellStop(string symbol, double inPrice)
        {
            Global.StopEntryTime     = 90000;
            Global.StopCheckInterval = 3000;
            api.RegisterL1(symbol);
            long elapsedMs = 0;
            var  watch     = Stopwatch.StartNew();

            FormHelper.FormSetText(String.Format("Execute SellStop {0} @ {1}", symbol, inPrice));

            while (elapsedMs < Global.StopEntryTime)
            {
                var l1 = ExecuteGetL1(symbol);
                if (l1.AskPrice < inPrice)
                {
                    var sellPrice = l1.BidPrice - 0.1;
                    // only try once
                    api.ExecuteOrder("Sell", symbol, sellPrice, Global.ShareSize);
                    log.AddFormLogMessage(String.Format("Price reached. Market In"));
                    break;
                }

                elapsedMs = watch.ElapsedMilliseconds;
                Thread.Sleep(Global.StopCheckInterval);
            }
            watch.Stop();

            var       position = api.GetOpenPositionForSymbol(symbol);
            const int stopLoss = 0;

            if (position.Volume != 0)
            {
                Global.UpdateSymbol(symbol, inPrice, stopLoss, position.Side, position.Volume);
                log.AddFormLogMessage(String.Format("Filled {0} for {1}", position.Symbol, position.Volume));
            }
            else
            {
                FormHelper.FormSetText(String.Format("Did not get fill"));
                log.Updatelog(String.Format("Did not get fill"));
            }

            api.CancelBuyOrdersForSymbol(symbol);
        }