private void ShowTradeWindow(decimal price, TradeTypeEnum way) { ITradeRequest sellTrade = new TradeRequest { Amount = 1, Pair = CurrentPair, Rate = price, TradeType = way }; var editTradeViewModel = new EditTradeViewModel(sellTrade, tradingConfigurations, btceModels.AccountInfo); var editTradeView = new EditTrade(); editTradeView.DataContext = editTradeViewModel; editTradeViewModel.CancelCommand = new RelayCommand((parameters) => { editTradeView.Close(); }); editTradeViewModel.OkCommand = new RelayCommand((parameters) => { btceTradeApi.MakeTrade(editTradeViewModel.TradeRequest); editTradeView.Close(); }); editTradeView.ShowDialog(); }
private Boolean JQKA(StockList stock, TradeTypeEnum type) { IntPtr myIntPtr = Utils.FindWindow(null, "网上股票交易系统5.0"); Boolean flagFore = Utils.SetForegroundWindow(myIntPtr); if (flagFore) { Boolean flagShowMax = Utils.ShowWindow(myIntPtr, 3); if (flagShowMax) { if (type == TradeTypeEnum.Buy) { //Thread.Sleep(300); SendKeys.SendWait("{F1}"); Thread.Sleep(200); SendKeys.SendWait(stock.StockCode); Thread.Sleep(300); SendKeys.SendWait("{TAB}"); Thread.Sleep(200); SendKeys.SendWait(stock.CurrentPrice.ToString()); Thread.Sleep(200); SendKeys.SendWait("{TAB}"); Thread.Sleep(200); SendKeys.SendWait(stock.BuyAmount.ToString()); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); } else { SendKeys.SendWait("{F2}"); Thread.Sleep(200); SendKeys.SendWait(stock.StockCode); Thread.Sleep(300); SendKeys.SendWait("{TAB}"); Thread.Sleep(200); SendKeys.SendWait(stock.CurrentPrice.ToString()); Thread.Sleep(200); SendKeys.SendWait("{TAB}"); Thread.Sleep(200); SendKeys.SendWait(stock.SaleAmount.ToString()); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); } } } return(flagFore); }
/// <summary> /// 发送交易成功邮件 /// </summary> /// <param name="amount">数量</param> /// <param name="stock">证券model</param> /// <param name="sw">所耗时间</param> /// <param name="type">买/卖类型</param> private void SendTradeSuccessMail(int amount, StockList stock, Stopwatch sw, TradeTypeEnum type) { string subject, body; if (type == TradeTypeEnum.Buy) { subject = string.Format("成功以{0}元买入{1}({2}){3}股", stock.CurrentPrice, stock.StockName, stock.StockCode, amount); body = string.Format("用时{0}秒", sw.Elapsed.TotalSeconds); } else { subject = string.Format("成功以{0}元卖出{1}({2}){3}股", stock.CurrentPrice, stock.StockName, stock.StockCode, amount); body = string.Format("用时{0}秒", sw.Elapsed.TotalSeconds); } SendMail(subject, body); }
private void Monitoring(StockConfigModel model, TradeTypeEnum type) { foreach (StockList stock in model.StockList) { if (stock.Monitor == "监控中") { if (type == TradeTypeEnum.Buy) { reachBuyCondition(model, stock); } else { reachSaleCondition(model, stock); } } } }
public decimal CalculateAmount(BtcePairEnum pair, TradeTypeEnum tradeType, decimal CurrentHoldings) { decimal toReturn = 1; var tradeConf = DefaultTradingSizes.Find(a => a.Pair == pair && a.TradeType == tradeType); if (tradeConf == null) return toReturn; switch (tradeConf.TradeSizeType) { case DefaultTradingSizeType.FixedAmount: toReturn = tradeConf.FixedAmount; break; case DefaultTradingSizeType.PercentageOfCurrentHoldings: toReturn = ((CurrentHoldings / 100) * tradeConf.PercentageOfCurrentHoldings); break; } return toReturn; }
private Boolean ZhaoShangZhiYuanTrade(StockList stock, TradeTypeEnum type) { IntPtr myIntPtr = Utils.FindWindow("TdxW_MainFrame_Class", null); Boolean flagFore = Utils.SetForegroundWindow(myIntPtr); if (flagFore) { Boolean flagShowMax = Utils.ShowWindow(myIntPtr, 3); if (flagShowMax) { if (type == TradeTypeEnum.Buy) { System.Threading.Thread.Sleep(500); Utils.SetCursorPos(43, 62); System.Threading.Thread.Sleep(100); Utils.mouse_event(Utils.MouseEventFlag.LeftDown, 0, 0, 0, 0); //模拟鼠标按下操作 Utils.mouse_event(Utils.MouseEventFlag.LeftUp, 0, 0, 0, 0); //模拟鼠标放开操作 Thread.Sleep(200); SendKeys.SendWait(stock.StockCode); Thread.Sleep(300); SendKeys.SendWait(stock.CurrentPrice.ToString()); Thread.Sleep(200); SendKeys.SendWait("{TAB}"); Thread.Sleep(200); SendKeys.SendWait(stock.BuyAmount.ToString()); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(200); SendKeys.SendWait("{ENTER}"); Thread.Sleep(500); SendKeys.SendWait("{ENTER}"); } } } return(flagFore); }
public decimal CalculateAmount(BtcePairEnum pair, TradeTypeEnum tradeType, decimal CurrentHoldings) { decimal toReturn = 1; var tradeConf = DefaultTradingSizes.Find(a => a.Pair == pair && a.TradeType == tradeType); if (tradeConf == null) { return(toReturn); } switch (tradeConf.TradeSizeType) { case DefaultTradingSizeType.FixedAmount: toReturn = tradeConf.FixedAmount; break; case DefaultTradingSizeType.PercentageOfCurrentHoldings: toReturn = ((CurrentHoldings / 100) * tradeConf.PercentageOfCurrentHoldings); break; } return(toReturn); }
public static string ToString(TradeTypeEnum v) { return(Enum.GetName(typeof(TradeTypeEnum), v).ToLowerInvariant()); }
public static string ToString(TradeTypeEnum v) { return Enum.GetName(typeof(TradeTypeEnum), v).ToLowerInvariant(); }
public static TriggerDetail Create(bool isTriggered, DateTime triggerTime, double triggeredPrice, TradeTypeEnum tradeType) { var triggerDetail = new TriggerDetail() { IsTriggered = isTriggered, TriggerTime = triggerTime, TriggeredPrice = triggeredPrice, TradeType = tradeType }; return(triggerDetail); }
/// <summary> /// 是否能下单 /// </summary> /// <param name="model"></param> /// <param name="stock"></param> /// <returns></returns> private bool CurrentCanTrade(StockConfigModel model, StockList stock, TradeTypeEnum type) { if (type == TradeTypeEnum.Buy) { if (stock.BuyVariableTrend != 0) { if (stock.BuyVariableTrend == (int)BuyVariableTrendEnum.ReachOrDown) { return(stock.CurrentPrice <= GetBuyPriceByTactics(model, stock)); } else if (stock.BuyVariableTrend == (int)BuyVariableTrendEnum.DownThenRebound) { if (stock.BuyPrice - stock.CurrentPrice >= stock.BuyVariableAmount) { stock.BuyMarkPrice = stock.CurrentPrice; } if (stock.CurrentPrice - stock.BuyMarkPrice >= stock.BuyVariableAmount) { return(true); } } else if (stock.BuyVariableTrend == (int)BuyVariableTrendEnum.DownThenUp) { if (stock.BuyMarkPrice == 0) { if (stock.BuyPrice - stock.CurrentPrice >= stock.BuyVariableAmount) { stock.BuyMarkPrice = stock.CurrentPrice; } } else { if (stock.BuyMarkPrice - stock.CurrentPrice >= stock.BuyVariableAmount) { stock.BuyMarkPrice = stock.CurrentPrice; } } if (stock.CurrentPrice - stock.BuyMarkPrice >= stock.BuyVariableAmount) { return(true); } } else if (stock.BuyVariableTrend == (int)BuyVariableTrendEnum.ReachOrUp) { return(stock.CurrentPrice >= stock.BuyPrice); } } } else { if (stock.SaleVariableTrend != 0) { if (stock.SaleVariableTrend == (int)SaleVariableTrendEnum.ReachOrDown) { return(stock.CurrentPrice <= stock.SalePrice); } else if (stock.SaleVariableTrend == (int)SaleVariableTrendEnum.UpThenFallBack) { if (stock.CurrentPrice - stock.SalePrice >= stock.SaleVariableAmount) { stock.SaleMarkPrice = stock.CurrentPrice; } if (stock.SaleMarkPrice - stock.CurrentPrice >= stock.SaleVariableAmount) { return(true); } } else if (stock.SaleVariableTrend == (int)SaleVariableTrendEnum.UpThenDown) { if (stock.SaleMarkPrice == 0) { if (stock.CurrentPrice - stock.SalePrice >= stock.SaleVariableAmount) { stock.SaleMarkPrice = stock.CurrentPrice; } } else { if (stock.CurrentPrice - stock.SaleMarkPrice >= stock.SaleVariableAmount) { stock.SaleMarkPrice = stock.CurrentPrice; } } if (stock.SaleMarkPrice - stock.CurrentPrice >= stock.SaleVariableAmount) { return(true); } } else if (stock.SaleVariableTrend == (int)SaleVariableTrendEnum.ReachOrUp) { return(stock.CurrentPrice >= stock.SalePrice); } } } return(false); }