public TradeBotBase(String stockid, string brokerid, string account, ushort BuyQty, Intelligence.QuoteCom quotecom, Smart.TaiFexCom taifexcom, int amountthreshold, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode) { this.stockid = stockid; this.quotecom = quotecom; this.taifexcom = taifexcom; this.brokerid = brokerid; this.account = account; this.BuyQty = BuyQty; //this.StopLossRatio = stoplossratio; //this.LockGainPrice = lockgainprice; this.AmountThreshold = amountthreshold; this.buy_mode = buymode; this.stoplossmode = stoplossmode; this.lockgainmode = lockgainmode; this.trade_status = TradeStatus.StandBy; OnStatusChange(this.trade_status, stockid + ":待命中"); //初始化成交明細下載目錄 this.MatchLogFolder = Path.Combine(Directory.GetCurrentDirectory(), DateTime.Now.ToString("yyyyMMdd")); //建立目錄 if (!Directory.Exists(this.MatchLogFolder)) { Directory.CreateDirectory(this.MatchLogFolder); } }
public TradeBotBase(String stockid, string brokerid, string account, ushort BuyQty, Intelligence.QuoteCom quotecom, Smart.TaiFexCom taifexcom, double stoplossratio, double lockgainprice, int amountthreshold, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode) { this.stockid = stockid; this.quotecom = quotecom; this.taifexcom = taifexcom; this.brokerid = brokerid; this.account = account; this.BuyQty = BuyQty; this.StopLossRatio = stoplossratio; this.LockGainPrice = lockgainprice; this.buy_mode = buymode; this.stoplossmode = stoplossmode; this.lockgainmode = lockgainmode; }
private void AddStock(string stockid, int AmountThreshold, ushort buyqty, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode) { DataRow row = StockTable.NewRow(); row["StockID"] = stockid; row["AmountThreshold"] = AmountThreshold; row["BuyQty"] = buyqty; row["BuyMode"] = buymode; row["StopLossMode"] = stoplossmode; row["LockGainMode"] = lockgainmode; TradeBotBase tb = new TradeBotLongQA(stockid, brokerid, account, buyqty, quotecom, tfcom, AmountThreshold, buymode, stoplossmode, lockgainmode); row["Status"] = tb.trade_status; row["TradeBot"] = tb; StockTable.Rows.Add(row); }
private void btn_LoadHistoryData_Click(object sender, EventArgs e) { if (File.Exists(StockHistoryFile)) { string[] lines = File.ReadAllLines(StockHistoryFile); foreach (string line in lines) { string[] data = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string stockid = data[0]; int AmountThreshold = Convert.ToInt32(data[1]); BuyMode buymode = data[2] == "Auto" ? BuyMode.Auto : BuyMode.Notify; StopLossMode stoplossmode = data[3] == "Auto" ? StopLossMode.Auto : StopLossMode.Manual; LockGainMode lockgainmode = data[4] == "Auto" ? LockGainMode.Auto : LockGainMode.Manual; ushort buyqty = Convert.ToUInt16(data[5]); AddStock(stockid, AmountThreshold, buyqty, buymode, stoplossmode, lockgainmode); } } }
private void btn_AddStock_Click(object sender, EventArgs e) { string stockid = tb_StockID.Text; if (!StockTable.Rows.Contains(stockid)) { ushort buyqty = (ushort)nud_BuyQty.Value; //decimal stoplossratio = (decimal)nud_stoplossratio.Value; //decimal lockgainprice = (decimal)nud_LockGainPrice.Value; int AmountThreshold = (Int32)nud_AmountThreshold.Value; BuyMode buymode = cb_BuyMode.SelectedIndex == 0 ? BuyMode.Auto : BuyMode.Notify; StopLossMode stoplossmode = cb_StopLossMode.SelectedIndex == 0 ? StopLossMode.Auto : StopLossMode.Manual; LockGainMode lockgainmode = cb_LockGainMode.SelectedIndex == 0 ? LockGainMode.Auto : LockGainMode.Manual; AddStock(stockid, AmountThreshold, buyqty, buymode, stoplossmode, lockgainmode); } else { MessageBox.Show("該檔股票已存在"); } }
public TradeBotLong(string stockid, string brokerid, string account, ushort BuyQty, QuoteCom quotecom, TaiFexCom taifexcom, int amountthreshold, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode) : base(stockid, brokerid, account, BuyQty, quotecom, taifexcom, amountthreshold, buymode, stoplossmode, lockgainmode) { }
private string MatchLogFolder = ""; //買入賣出成交紀錄 public TradeBotQA(string stockid, string brokerid, string account, ushort BuyQty, QuoteCom quotecom, TaiFexCom taifexcom, int amountthreshold, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode) : base(stockid, brokerid, account, BuyQty, quotecom, taifexcom, amountthreshold, buymode, stoplossmode, lockgainmode) { //初始化成交明細下載目錄 this.MatchLogFolder = Path.Combine(Directory.GetCurrentDirectory(), DateTime.Now.ToString("yyyyMMdd")); //建立目錄 if (!Directory.Exists(this.MatchLogFolder)) { Directory.CreateDirectory(this.MatchLogFolder); } Console.WriteLine(MatchLog); }