private void button2_Click(object sender, EventArgs e) { // subscribe l1quote streaming here List <string> symbols = txtSymbols.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); TDANET.Subscribe(symbols, StreamingServiceType.L1QuoteStreaming); }
private void button8_Click(object sender, EventArgs e) { if (TDANET.client.AssociatedAccount.AccountAuthorizations.StreamingNews) { List <string> symbols = textBox7.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); TDANET.Subscribe(symbols, StreamingServiceType.News); } else { textBox6.Text = "You don't have streaming news subscription"; } }
private async void button1_Click(object sender, EventArgs e) { if (TDANET.IsLoggedIn == false) { TDANET.AppSource = txtAppSource.Text; var result = await TDANET.LogIn(txtUsername.Text, txtPassword.Text); } else { TDANET.LogOut(); } }
private async void button11_Click(object sender, EventArgs e) { Balances balance = await TDANET.GetBalancesAsync(); var sb = new StringBuilder(); var results = balance.GetProperties(); foreach (var result in results) { sb.AppendFormat("{0,30}{1,20}\r\n", result.Key, result.Value); } txtBalance.Text = sb.ToString(); }
private async void button5_Click(object sender, EventArgs e) { List <string> symbols = textBox4.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); var result = await TDANET.GetSnapshotAsync(symbols, RequestSourceType.Manual); var sb = new StringBuilder(); foreach (var l1quote in result.Results) { sb.Append(string.Format("Symbol: {0}\tLast: {1}\tChange(%): {2:+0.00%;-0.00%;0.00%}\t Volume: {3:N0}\t LastTrade: {4,25:yyyy/MM/dd HH:mm:ss}\r\n", l1quote.Symbol, l1quote.Last, l1quote.ChangePercent, l1quote.Volume, l1quote.LastTradeDate)); } textBox1.Text = sb.ToString(); }
private async void button12_Click(object sender, EventArgs e) { var positions = await TDANET.GetPositionsAsync(); var sb = new StringBuilder(); foreach (var stock in positions.Stocks) { if (!string.IsNullOrEmpty(stock.Symbol)) { sb.AppendFormat("{0,10}{1,15}{2,15}{3,15}\r\n", stock.Symbol, stock.Quantity, stock.AveragePrice, stock.PositionType); } } txtPositions.Text = sb.ToString(); }
private async void button10_Click(object sender, EventArgs e) { var orderHistories = await TDANET.GetOrderHistoryAsync(1); var sb = new StringBuilder(); foreach (var oh in orderHistories) { if (!string.IsNullOrEmpty(oh.OrderNumber)) { sb.AppendFormat("[{0,15:yyyy/MM/dd HH:mm tt}] {1,10} {2,15} {3,15:N0} {4,15} {5,15}\r\n", oh.OrderDateTime, oh.Symbol, oh.Price, oh.Quantity, oh.OrderNumber, oh.BuySellCode); } } txtOrderHistory.Text = sb.ToString(); }
private async Task refreshOrderStatus() { int days = !string.IsNullOrEmpty(txtLastDays.Text) ? Convert.ToInt32(txtLastDays.Text) : 5; var statuses = await TDANET.GetOrderStatusAsync(days, "all"); var sb = new StringBuilder(); foreach (var status in statuses) { if (!string.IsNullOrEmpty(status.Symbol)) { sb.AppendFormat("[{0,25:yyyy/MM/dd HH:mm:ss}]{1,10}{2,15}{3,15}{4,10}\tOrder#: {5,10}\r\n", status.OrderReceivedDateTime, status.Symbol, status.Quantity, status.DisplayStatus, status.OrderType, status.OrderNumber); } } txtOrderStatus.Text = sb.ToString(); }
public static async Task <EquityOrderResponse> SubmitOrder() { if (_orders.Count > 0) { string accountIdStr = string.Format("accountid={0}", TDANET.client.AssociatedAccountId); string orderString = accountIdStr; if (ConditionalyOrderType == ConditionalOrderTypes.single && _orders.Count == 1) { orderString += _orders[0].GetOrderString(); } else { // this is for conditional orders orderString += "~ordticket=" + ConditionalyOrderType.ToString("g"); orderString += "~totlegs=" + _orders.Count; var orders = _orders.OrderBy(o => o.LegId).ToList(); foreach (var order in orders) { orderString += order.GetOrderString(); } } Debug.Print("Order String: {0}", orderString); EquityOrderResponse response = await TDANET.SubmitOrder(orderString); if (response.Result.ToUpper() == "OK") { ConditionalyOrderType = ConditionalOrderTypes.single; ClearOrders(); } return(response); } return(new EquityOrderResponse() { Error = "Order queue is empty" }); }
private async void button6_Click(object sender, EventArgs e) { textBox2.Text = string.Empty; StringBuilder sb = new StringBuilder(); List <string> symbols = txtSymbols2.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); List <PriceHistory> result = await TDANET.GetPriceHistoryAsync(symbols, DateTime.Today.AddYears(-1), DateTime.Today, true, false); foreach (PriceHistory history in result) { sb.AppendLine("\r\n==============================================="); sb.AppendLine(history.Symbol); sb.AppendLine("-----------------------------------------------"); int i = history.Count; for (int j = 0; j < i; j++) { sb.AppendLine(string.Format("{0:M/dd/yyyy H:mm:ss} {1:0.00##} {2:0.00##} {3:0.00##} {4:0.00##} {5:N0}", DateTime.FromOADate(history.TimeStamps[j]), history.Opens[j], history.Highs[j], history.Lows[j], history.Closes[j], history.Volumes[j])); } } textBox2.Text = sb.ToString(); }
private async void button9_Click(object sender, EventArgs e) { if (TDANET.client.AssociatedAccount.AccountAuthorizations.StreamingNews) { StringBuilder sb = new StringBuilder(); List <string> symbols = textBox7.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); foreach (var symbol in symbols) { List <StreamingNews> newsCollection = await TDANET.GetNewsHistory(symbol, 7); foreach (StreamingNews news in newsCollection) { sb.AppendLine(string.Format("[{0}] [{1}] {2}", news.Symbol, news.NewsTimeStamp, news.Headline)); } } textBox6.Text = sb.ToString(); } else { textBox6.Text = "You don't have streaming news subscription"; } }
private async void button15_Click(object sender, EventArgs e) { var result = await TDANET.CancelOrder(txtOrderNumber.Text); MessageBox.Show(result.OrderId + ": " + result.Message); }
private void button13_Click(object sender, EventArgs e) { List <string> symbols = textBox9.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); TDANET.Subscribe(symbols, StreamingServiceType.TimeSales); }
private async void button7_Click(object sender, EventArgs e) { List <string> symbols = txtSymbols3.Text.Split(new char[] { ',', ' ', ';', '+' }).ToList(); TDANET.Subscribe(symbols, StreamingServiceType.NASDAQ_Chart); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { TDANET.LogOut(); }