public Trade(Stock stock, DateTime tradeTime, decimal quantity, TradeAction action, decimal price) { Stock = stock; TradeTime = tradeTime; Quantity = quantity; Action = action; Price = price; }
public void LoadData() { if (App.BSL == null || Login.UserInfo == null) { this.Visibility = Visibility.Hidden; return; } OrderDataModel order = null; if (Action == TradeAction.Buy) { try { if ((order = App.BSL.buy(Login.UserInfo.profileID, Trade.ID, Trade.Quantity, 0)) != null) { AlertMessage("Order " + order.orderID + " to buy " + order.quantity + " shares of " + order.symbol + " has been submitted for processing."); } } catch (Exception ex) { AlertMessage("Failed to process buy order, exception: " + ex.ToString()); } } else if( Action == TradeAction.Sell ) { try { if (Trade.Quantity == 0) { order = App.BSL.sell(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), 0); } else { order = App.BSL.sellEnhanced(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), Trade.Quantity); } if (order != null) { AlertMessage("Order " + order.orderID + " to sell " + order.quantity + " shares of " + order.symbol + " has been submitted for processing."); } } catch (Exception ex) { AlertMessage("Failed to process sell order, Exception: " + ex.ToString()); } } Action = TradeAction.None; try { List<OrderDataModel> orders = App.BSL.getOrders(Login.UserInfo.profileID); Update.Text = "as of " + DateTime.Now; DataProvider data = new DataProvider(); for (int i = 0; i < orders.Count; i++) { order = orders[i]; data.Add(new RowDataProvider()); data[i].id = i; data[i].Add(new GridColumnData()); data[i][0].value = order.orderID.ToString(); data[i][0].numeric = order.orderID; data[i].Add(new GridColumnData()); data[i][1].value = order.orderStatus; data[i][1].numeric = order.orderStatus.Equals("closed") ? 0 : 1; data[i].Add(new GridColumnData()); data[i][2].value = order.openDate.ToString(); data[i][2].numeric = (int)(order.openDate.Ticks / 10000); data[i].Add(new GridColumnData()); data[i][3].value = order.completionDate.ToString(); data[i][3].numeric = (int)(order.completionDate.Ticks / 10000); data[i].Add(new GridColumnData()); data[i][4].value = string.Format("{0:C}", order.orderFee); data[i][4].numeric = (int)(order.orderFee * 100); data[i].Add(new GridColumnData()); data[i][5].value = order.orderType; data[i][5].numeric = order.orderType.Equals("buy") ? 1 : 0; data[i].Add(new GridColumnData()); data[i][6].value = order.symbol; data[i][6].numeric = (int)(order.quantity * 100); data[i].Add(new GridColumnData()); data[i][7].value = order.quantity.ToString(); data[i][7].numeric = (int)(order.quantity * 100); } OrderGrid.setData(data); } catch (Exception ex) { MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning); } this.Visibility = Visibility.Visible; }
public TradeUpdatePacket(TradeRecord trade, TradeAction action) : base(APINetworkPacketType.TradeUpdate) { this.Trade = trade; this.Action = action; }
public static OrderRequest GetOrderRequest(int accountKey, AssetType assetType, OrderDuration duration, DateTime gtdDate, decimal limitPrice, decimal stopPrice, OrderType orderType, int quantity, string symbol, TradeAction tradeAction) { OrderRequest order = new OrderRequest { AccountKey = accountKey.ToString(), AssetType = assetType, Duration = duration, GTDDate = gtdDate, LimitPrice = limitPrice, OrderId = 0, OrderType = orderType, Quantity = quantity, Route = Route.Intelligent, StopPrice = stopPrice, Symbol = symbol, TradeAction = tradeAction }; return order; }
public static OrderRequest GetMarketOrderRequest(int accountKey, AssetType assetType, int quantity, string symbol, TradeAction tradeAction) { return GetOrderRequest(accountKey, assetType, new OrderDuration(DurationCode.DAY), DateTime.MinValue, 0, 0, OrderType.Market, quantity, symbol, tradeAction); }
static void processConfirmations(SteamGuardAccount account) { Utils.Verbose("Refeshing Session..."); if (account.RefreshSession()) { Utils.Verbose("Session refreshed"); Manifest.SaveAccount(account, Manifest.Encrypted); } else { Utils.Verbose("Failed to refresh session, prompting user..."); if (!promptRefreshSession(account)) { Console.WriteLine("Failed to refresh session, aborting..."); } } Console.WriteLine("Retrieving trade confirmations..."); var tradesTask = account.FetchConfirmationsAsync(); tradesTask.Wait(); var trades = tradesTask.Result; var tradeActions = new TradeAction[trades.Length]; for (var i = 0; i < tradeActions.Length; i++) { tradeActions[i] = TradeAction.Ignore; } if (trades.Length == 0) { Console.WriteLine($"No trade confirmations for {account.AccountName}."); return; } var selected = 0; var colorAccept = ConsoleColor.Green; var colorDeny = ConsoleColor.Red; var colorIgnore = ConsoleColor.Gray; var colorSelected = ConsoleColor.Yellow; var confirm = false; do { Console.Clear(); if (selected >= trades.Length) { selected = trades.Length - 1; } else if (selected < 0) { selected = 0; } Console.ResetColor(); Console.WriteLine($"Trade confirmations for {account.AccountName}..."); Console.WriteLine("No action will be made without your confirmation."); Console.WriteLine("[a]ccept [d]eny [i]gnore [enter] Confirm [q]uit"); // accept = 1, deny = 0, ignore = -1 Console.WriteLine(); for (var t = 0; t < trades.Length; t++) { ConsoleColor itemColor; switch (tradeActions[t]) { case TradeAction.Accept: itemColor = colorAccept; break; case TradeAction.Deny: itemColor = colorDeny; break; case TradeAction.Ignore: itemColor = colorIgnore; break; default: throw new ArgumentOutOfRangeException(); } Console.ForegroundColor = t == selected ? colorSelected : itemColor; Console.WriteLine($" [{t}] [{tradeActions[t]}] {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}"); } var key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.UpArrow: case ConsoleKey.W: selected--; break; case ConsoleKey.DownArrow: case ConsoleKey.S: selected++; break; case ConsoleKey.A: tradeActions[selected] = TradeAction.Accept; break; case ConsoleKey.D: tradeActions[selected] = TradeAction.Deny; break; case ConsoleKey.I: tradeActions[selected] = TradeAction.Ignore; break; case ConsoleKey.Enter: confirm = true; break; case ConsoleKey.Escape: case ConsoleKey.Q: Console.ResetColor(); Console.WriteLine("Quitting..."); return; default: break; } } while (!confirm); Console.ResetColor(); Console.WriteLine(); Console.WriteLine("Processing..."); for (var t = 0; t < trades.Length; t++) { bool success = false; switch (tradeActions[t]) { case TradeAction.Accept: if (Verbose) { Console.Write($"Accepting {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}..."); } success = account.AcceptConfirmation(trades[t]); break; case TradeAction.Deny: if (Verbose) { Console.Write($"Denying {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}..."); } success = account.DenyConfirmation(trades[t]); break; case TradeAction.Ignore: if (Verbose) { Console.Write($"Ignoring {trades[t].ConfType} {trades[t].Creator} {trades[t].Description}..."); } success = true; break; default: throw new ArgumentOutOfRangeException(); } Utils.Verbose(success); } Console.WriteLine("Done."); }
public Tick(string symbol, DateTime date, double price, double volume, TradeAction action, long id) : this(symbol, date, price, volume, action) { this.Id = id; }
public virtual void PrePreTraded(TradeAction action, Pawn playerNegotiator, ITrader trader) { }