Exemple #1
0
        private void AsyncReportPrice(PriceAction act, int screenPrice, int targetPrice, DateTime screenTime, DateTime occurTime, string memo, int usedDelayMills = 0)
        {
            ThreadUtils.StartNewTaskSafe(() => {
                string actionText = null;
                if (act == PriceAction.PRICE_OFFER)
                {
                    priceActionService.ReportPriceOffered(screenPrice, targetPrice, screenTime, occurTime, memo);
                    actionText = screenTime.ToLongTimeString() + " - 出价: " + targetPrice;
                }
                else if (act == PriceAction.PRICE_SUBMIT)
                {
                    priceActionService.ReportPriceSubbmitted(screenPrice, targetPrice, screenTime, usedDelayMills, occurTime, memo);
                    actionText = screenTime + " - 提交";
                }
                else if (act == PriceAction.PRICE_SHOW)
                {
                    priceActionService.ReportPriceShowed(screenPrice, screenTime, occurTime, memo);
                }

                if (actionText != null)
                {
                    SetStrategyText();

                    lastActions.Add(actionText);
                    SetLastAcionText();
                }
            });
        }
Exemple #2
0
        public PriceAction Dep_GetPriceAction(DateTime dt)
        {
            PriceAction pa = new PriceAction(PriceActionType.UnKnown, new Volatility(-1, -1, -1, -1));

            //int key_date = GetDateByDateTime(dt);
            string        key_date = GetDateStrByDateTime(dt);
            int           t        = dt.Hour * 100 + dt.Minute;
            MarketContext mkt_ctxs = null;

//			Dictionary<int,PriceAction> mkt_ctxs = null;
//			if(Dict_SpvPR != null)
//				Dict_SpvPR.TryGetValue(key_date, out mkt_ctxs);
//			if(Dict_SpvPR2 != null)
//				Dict_SpvPR2.TryGetValue(key_date, out mkt_ctxs);

//			Print("key_date, time, Dict_SpvPR, mkt_ctxs=" + key_date
//			+ "," + t.ToString() + "," + Dict_SpvPR2.Count + "," + mkt_ctxs);
            if (mkt_ctxs != null)
            {
//				foreach(var mkt_ctx in mkt_ctxs) {
//					Print("time, start, end, mkt_ctx=" + t + "," +
//					mkt_ctx.Key + "," + mkt_ctx.Value);
//					int start = mkt_ctx.Key/10000;
//					int end = mkt_ctx.Key % 10000;

//					if(t >= start && t <= end) {
//						pa = mkt_ctx.Value;
//						break;
//					}
//				}
            }
            return(pa);
        }
Exemple #3
0
        private void DoPriceAction(PriceAction action, int screenPrice, int targetPrice, DateTime screenTime, int usedDelayMills, DateTime occurTime, string memo = "")
        {
            PriceActionRequest req = new PriceActionRequest();

            req.MachineCode    = clientService.GetMachineCode();
            req.OccurTime      = occurTime == null ? DateTime.Now : occurTime;
            req.ScreenTime     = screenTime;
            req.UsedDelayMills = usedDelayMills;
            req.Action         = action;
            req.ScreenPrice    = screenPrice;
            req.TargetPrice    = targetPrice;

            JsonCommand comm = JsonCommands.OK(CommandDirective.PRICE_TELL, req.ToLine());

            RawMessage msg = MessageUtils.BuildJsonMessage(ClientService.AssignedClientNo, comm);

            socketClient.Send(msg);

            logger.InfoFormat("report price#{0}#{1}action#{2} at screenTime#{3} occurTime{4}, usedDelayMills#{5}", screenPrice, targetPrice, action, screenTime, req.OccurTime, usedDelayMills);
        }
        protected virtual void SetTradeContext(PriceAction pa)
        {
            switch (pa.paType)
            {
            case PriceActionType.UpTight:                     //
                TM_TradingStyle     = TradingStyle.TrendFollowing;
                TM_TradingDirection = TradingDirection.Long;
                break;

            case PriceActionType.UpWide:                     //wide up channel
                TM_TradingStyle     = TradingStyle.CounterTrend;
                TM_TradingDirection = TradingDirection.Long;
                break;

            case PriceActionType.DnTight:                     //
                TM_TradingStyle     = TradingStyle.TrendFollowing;
                TM_TradingDirection = TradingDirection.Short;
                break;

            case PriceActionType.DnWide:                     //wide dn channel
                TM_TradingStyle     = TradingStyle.CounterTrend;
                TM_TradingDirection = TradingDirection.Short;
                break;

            case PriceActionType.RngTight:                     //
                TM_TradingStyle     = TradingStyle.Ranging;    //-1;
                TM_TradingDirection = TradingDirection.Both;
                break;

            case PriceActionType.RngWide:                     //
                TM_TradingStyle     = TradingStyle.CounterTrend;
                TM_TradingDirection = TradingDirection.Both;
                break;

            default:
                TM_TradingStyle     = TradingStyle.TrendFollowing;
                TM_TradingDirection = TradingDirection.Both;
                break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Get Price Action by datetime from the Spv list
        /// </summary>
        /// <param name="dt">Datetime of the bar</param>
        /// <returns></returns>
        public PriceAction GetPriceAction(DateTime dt)
        {
            PriceAction pa = new PriceAction(PriceActionType.UnKnown, new Volatility(-1, -1, -1, -1));

            //int key_date = GetDateByDateTime(dt);
            string key_date = GetDateStrByDateTime(dt);
            int    t        = dt.Hour * 100 + dt.Minute;
            List <MarketContext> mkt_ctxs = null;

//			Dictionary<int,PriceAction> mkt_ctxs = null;
//			if(Dict_SpvPR != null)
//				Dict_SpvPR.TryGetValue(key_date, out mkt_ctxs);
            TraceMessage(this.Name, prt_lev);
            if (Dict_SpvPR != null)
            {
                Dict_SpvPR.TryGetValue(key_date, out mkt_ctxs);
            }
            TraceMessage(this.Name, prt_lev);
            Print("key_date, time, Dict_SpvPR, mkt_ctxs=" + key_date
                  + "," + t.ToString() + "," + Dict_SpvPR.Count + "," + mkt_ctxs);
            TraceMessage(this.Name, prt_lev);
            if (mkt_ctxs != null)
            {
                foreach (var mkt_ctx in mkt_ctxs)
                {
                    Print("time, mkt_ctx.Time, mkt_ctx.Price_Ation=" + t + "," +
                          mkt_ctx.Time + "," + mkt_ctx.Price_Ation);
                    int start = mkt_ctx.Time / 10000;
                    int end   = mkt_ctx.Time % 10000;
                    TraceMessage(this.Name, prt_lev);
                    if (t >= start && t <= end)
                    {
                        pa = mkt_ctx.Price_Ation;
                        break;
                    }
                }
            }
            return(pa);
        }
Exemple #6
0
 public ProductCommand(Product product, PriceAction priceAction, int amount)
 {
     _product     = product;
     _priceAction = priceAction;
     _amount      = amount;
 }
Exemple #7
0
 public ProductCommand(Product product, PriceAction priceAction, int amount)
 {
     this.product     = product;
     this.priceAction = priceAction;
     this.amount      = amount;
 }
//		private int time;
//		private PriceAction priceAction;

        public MarketContext(int t, PriceAction pa)
        {
            Time        = t;
            Price_Ation = pa;
        }
Exemple #9
0
 public void Calculate(PriceAction priceAction)
 {
     this._buffer.Add(new SingleValueIndicator(priceAction.Sum(barCount), priceAction.FirstToLast.Time));
 }
Exemple #10
0
 public void Calculate(PriceAction priceAction)
 {
     this._buffer.Add(new MultiValueIndicator(priceAction.FirstToLast.Time, priceAction.Average(barCount)));
 }
 public TireCommand(Tire tire, PriceAction priceAction, int amount)
 {
     _tire        = tire;
     _priceAction = priceAction;
     _amount      = amount;
 }
 public ProductCommand(Product product, PriceAction priceAction)
 {
     _product     = product;
     _priceAction = priceAction;
 }
Exemple #13
0
 public PriceCommand(NewPriceModel model, PriceAction priceAction)
 {
     this.priceAction = priceAction;
     this.PriceModel  = model;
     priceService     = new PriceService();
 }
Exemple #14
0
 public ProductCommand(Product aProduct, PriceAction aPriceAction, int anAmount)
 {
     product     = aProduct;
     priceAction = aPriceAction;
     amount      = anAmount;
 }