示例#1
0
 public LocalAutoTradeItem(LocalAutoTradeItem item)
 {
     this.refNo = item.refNo;
     this.stockName = item.stockName;
     this.fieldType = item.fieldType;
     this.operatorType = item.operatorType;
     this.Value = item.Value;
     this.ordSide = item.ordSide;
     this.ordVolume = item.ordVolume;
     this.ordPrice = item.ordPrice;
     this.ordCondition = item.ordCondition;
     this.status = item.status;
     this.time = item.time;
     this.mtime = item.mtime;
     this.conditionType = item.conditionType;
     this.limit = item.limit;
     this.firstBidVol = item.firstBidVol;
     this.firstOfferVol = item.firstOfferVol;
     this.secondBidVol = item.secondBidVol;
     this.secondOfferVol = item.secondOfferVol;
     this.message = item.message;
 }
示例#2
0
 private string GetLocalConditionString(LocalAutoTradeItem.AutoTradeCondition conditionType, string fieldType, int operType, decimal value)
 {
     if (LocalAutoTradeItem.AutoTradeCondition.COMMON == conditionType)
     {
         return fieldType + " " + AutoTradeConstant.GetOperatorSymbol(operType) + " " + value;
     }
     else if (LocalAutoTradeItem.AutoTradeCondition.FOLLOW_BIGLOT == conditionType)
     {
         return "Volume " + AutoTradeConstant.GetOperatorSymbol(operType) + " " + value + "(Follow Biglot)";
     }
     return null;
 }
示例#3
0
        private void btnSendLocalOrder_Click(object sender, EventArgs e)
        {
            _localAutoTradeItem = new LocalAutoTradeItem();
            _localAutoTradeItem.StockName = this.cb1Stock.Text.Trim();

            if (this.cb1Condition.Text.ToLower().IndexOf("last") > -1)
            {
                _localAutoTradeItem.FieldType = "LAST";
            }

            if (this.cb1Condition.Text.IndexOf(">=") > 0)
            {
                _localAutoTradeItem.OperatorType = AutoTradeConstant.OPERATOR_GREATER_EQUAL;
            }
            else if (this.cb1Condition.Text.IndexOf("<=") > 0)
            {
                _localAutoTradeItem.OperatorType = AutoTradeConstant.OPERATOR_LESSER_EQUAL;
            }
            else if (this.cb1Condition.Text.IndexOf(">") > 0)
            {
                _localAutoTradeItem.OperatorType = AutoTradeConstant.OPERATOR_GREATER;
            }
            else if (this.cb1Condition.Text.IndexOf("<") > 0)
            {
                _localAutoTradeItem.OperatorType = AutoTradeConstant.OPERATOR_LESSER;
            }

            if (this.cb1Condition.Text.ToLower().IndexOf("sma") > 0)
            {
                _localAutoTradeItem.ConditionType = LocalAutoTradeItem.AutoTradeCondition.SMA;
            }
            else if (this.cb1Condition.Text.ToLower().IndexOf("biglot") > 0)
            {
                _localAutoTradeItem.ConditionType = LocalAutoTradeItem.AutoTradeCondition.FOLLOW_BIGLOT;
            }
            else
            {
                _localAutoTradeItem.ConditionType = LocalAutoTradeItem.AutoTradeCondition.COMMON;
            }

            decimal comparePrice;
            decimal.TryParse(this.cb1Value.Text, out comparePrice);
            _localAutoTradeItem.Value = comparePrice;

            _localAutoTradeItem.OrdPrice = this.cb1Price.Text.Trim();
            if (!this.IsValidPrice(_localAutoTradeItem.OrdPrice, true, this.cb1Price))
            {
                return;
            }

            long volumn = 0L;
            long.TryParse(this.tb1Volume.Text.Replace(",", ""), out volumn);
            _localAutoTradeItem.OrdVolume = volumn;

            _localAutoTradeItem.OrdSide = this._ordSide;

            _localAutoTradeItem.Time = DateTime.Now;

            string orderParam = string.Empty ;

            if (this.cb1Condition.Text.ToLower().IndexOf("biglot") > 0)
            {
                orderParam = string.Concat(new string[]
                                        {
                                            "Auto Trade :",
                                            " Account : ",
                                            ApplicationInfo.AccInfo.CurrentAccount,
                                            "\n",
                                            Utilities.GetOrderSideName(this._ordSide),
                                            "  ‘",
                                            _localAutoTradeItem.StockName,
                                            "’",
                                            "  Volume ",
                                            FormatUtil.VolumeFormat(_localAutoTradeItem.OrdVolume, true),
                                           "\n",
                                           "Follow Biglot with volume ",
                                            this.cb1Value.Text
                                        });
            }
            else
            {
                orderParam = string.Concat(new string[]
                                        {
                                            "Auto Trade :",
                                            " Account : ",
                                            ApplicationInfo.AccInfo.CurrentAccount,
                                            "\n",
                                            Utilities.GetOrderSideName(this._ordSide),
                                            "  ‘",
                                            _localAutoTradeItem.StockName,
                                            "’",
                                            "  Volume ",
                                            FormatUtil.VolumeFormat(_localAutoTradeItem.OrdVolume, true),
                                            "  Price ",
                                            _localAutoTradeItem.OrdPrice,
                                            "\nCondition : ",
                                            _localAutoTradeItem.FieldType + " " + AutoTradeConstant.GetOperatorSymbol(_localAutoTradeItem.OperatorType) + " " + _localAutoTradeItem.Value
                                        });
            }
            this.ShowOrderFormConfirm("Confirm to send?", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmSendNew);
        }
        public void UpdateItemList(LocalAutoTradeItem itemArg)
        {
            if (_itemList == null)
            {
                _itemList = new List<LocalAutoTradeItem>();
            }
            itemArg.RefNo = _refCount;
            itemArg.Status = AutoTradeConstant.STATUS_WAIT;

            try
            {
                StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[itemArg.StockName];
                string returnPage = ApplicationInfo.WebService.StockByPricePage(stockInformation.Number, 1);
                DataSet stockPageInfo = new DataSet();
                MyDataHelper.StringToDataSet(returnPage, stockPageInfo);
                DataRow dataRow = stockPageInfo.Tables["security_stat"].Rows[0];
                itemArg.FirstBidVol = Convert.ToDecimal(dataRow["bid_volume1"]);
                itemArg.SecondBidVol = Convert.ToDecimal(dataRow["bid_volume2"]);
                itemArg.FirstOfferVol = Convert.ToDecimal(dataRow["offer_volume1"]);
                itemArg.SecondOfferVol = Convert.ToDecimal(dataRow["offer_volume2"]);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            _itemList.Add(itemArg);
            ++_refCount;
        }
 public bool IsConditionMeet(LSAccumulate msgLS, LocalAutoTradeItem autoItem, StockList.StockInformation realtimeStockInfo)
 {
     switch (autoItem.ConditionType)
     {
         case LocalAutoTradeItem.AutoTradeCondition.COMMON :
             return CheckCommonCondition(msgLS, autoItem, realtimeStockInfo);
         case LocalAutoTradeItem.AutoTradeCondition.FOLLOW_BIGLOT :
             return CheckBiglotCondition(msgLS, autoItem, realtimeStockInfo);
     }
     return false;
 }
        public void Execute(LSAccumulate msgLS, StockList.StockInformation realtimeStockInfo)
        {
            foreach (LocalAutoTradeItem item in this._itemList)
            {
                if (item.StockName == realtimeStockInfo.Symbol &&
                    item.Status == AutoTradeConstant.STATUS_WAIT)
                {

                    if (IsConditionMeet(msgLS, item, realtimeStockInfo))
                    {
                        if (!this.bgwAutoSendOrder.IsBusy)
                        {
                            if (item.ConditionType == LocalAutoTradeItem.AutoTradeCondition.FOLLOW_BIGLOT)
                            {
                                item.OrdPrice = msgLS.LastPrice.ToString();
                            }
                            _currentAutoItem = item;
                            this.bgwAutoSendOrder.RunWorkerAsync();
                        }
                    }
                }
            }
        }
        public bool CheckCommonCondition(LSAccumulate msgLS, LocalAutoTradeItem autoItem, StockList.StockInformation realtimeStockInfo)
        {
            switch (autoItem.OperatorType)
            {
                case AutoTradeConstant.OPERATOR_LESSER_EQUAL:
                    {
                        if (autoItem.OrdSide == "S")
                        {
                            if (msgLS.Side == "S")
                            {
                                decimal priceToCompare = autoItem.Value;

                                if (msgLS.LastPrice == priceToCompare)
                                {
                                    autoItem.FirstBidVol -= msgLS.Volume;
                                    if ((autoItem.FirstBidVol / 5) <= (autoItem.OrdVolume / realtimeStockInfo.BoardLot))
                                    {
                                        return true;
                                    }

                                }

                                decimal bidPrice1;
                                Decimal.TryParse(realtimeStockInfo.BidPrice1, out bidPrice1);
                                if (bidPrice1 < priceToCompare)
                                {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
            }
            return false;
        }
 public bool CheckBiglotCondition(LSAccumulate msgLS, LocalAutoTradeItem autoItem, StockList.StockInformation realtimeStockInfo)
 {
     if (autoItem.OrdSide == "S")
     {
         if ((msgLS.Side == "S") && (autoItem.Value < (msgLS.Volume * realtimeStockInfo.BoardLot) ))
         {
             return true;
         }
     }
     else
     {
         if ((msgLS.Side == "B") && (autoItem.Value < (msgLS.Volume * realtimeStockInfo.BoardLot)))
         {
             return true;
         }
     }
     return false;
 }