public TableData(TableData old) { initialize(); error = old.error; players = old.players; myPos = old.myPos; for (int i = 0; i < 10; i++) { stacks[i] = old.stacks[i]; bets[i] = old.bets[i]; } dealerPos = old.dealerPos; for (int i = 0; i < 2; i++) { handCards[i] = old.handCards[i]; } handIndex = -1; for (int i = 0; i < 5; i++) { boardCards[i] = old.boardCards[i]; } noSB = old.noSB; BBindex = old.BBindex; BBsize = old.BBsize; errorStr = old.errorStr; allinIndex = old.allinIndex; tableType = old.tableType; casinoname = old.casinoname; SelectedAction = old.SelectedAction; }
// ********************************************************************** public Transaction(string descr, OwnAction source) { this.Descr = descr; this.Source = source; this.State = States.Execute; }
public void initialize() { error = 0; players = -1; myPos = -1; stacks = new int[10] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; bets = new int[10] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; dealerPos = -1; handCards = new int[2] { -1, -1 }; handIndex = -1; boardCards = new int[5] { -1, -1, -1, -1, -1 }; noSB = false; BBindex = -1; BBsize = -1; errorStr = ""; allinIndex = 9; tableType = -1; casinoname = ""; SelectedAction = OwnAction.ENone; }
// -------------------------------------------------------------- public KbItem(Key key, bool onKeyDown, OwnAction action, int id, int priceRatio) { this.Key = key; this.OnKeyDown = onKeyDown; this.action = action; this.id = id; this.priceRatio = priceRatio; }
// -------------------------------------------------------------- public static string OpText(OwnAction action) { if (action.IsStop) { return("*" + TradeOpItem.ToString(action.Operation)); } else { return(TradeOpItem.ToString(action.Operation)); } }
// ********************************************************************** void ActivateStopOrder(Transaction t, OwnAction newAction) { // MktProvider.Log.Put("Стоп-заявка " + t.Descr + " " // + t.TId + " @" + t.Price + " активирована"); OwnOrder ownOrder = new OwnOrder(t.TId, t.Price); t.Source = newAction; t.Execute(); ProcessTList(); Position.StopOrderActivated(t); MktProvider.Receiver.PutOwnOrder(ownOrder); }
// ********************************************************************** public void MoveOrders(IList <OwnOrder> orders, int price) { if (orders != null) { lock (tlist) { foreach (OwnOrder order in orders) { Transaction t = order.Tag as Transaction; LinkedListNode <Transaction> node; if (t != null && t.State != Transaction.States.Disposed && (node = tlist.Find(t)) != null) { // MktProvider.Log.Put(">> Перенос заявки " + t.Descr + " " // + t.Source.Operation + " T" + t.TId + " на " + price); t.Cancel(); if (t.TId > 0) { tlist.AddAfter(node, new Transaction("MvOrder", new OwnAction( t.Operation, BaseQuote.Absolute, price, QtyType.Absolute, t.Volume))); } else if (t.TId < 0) { OwnAction a = t.Source; if (t.Trailing) { tlist.AddAfter(node, new Transaction("MvTrail", new OwnAction( a.Operation, BaseQuote.Absolute, price, a.QtyType, a.Quantity, a.IsStop, a.Slippage))); } else { tlist.AddAfter(node, new Transaction("MvStop", new OwnAction( a.Operation, BaseQuote.Absolute, price, a.QtyType, a.Quantity, a.IsStop, a.Slippage, a.TrailStart, a.TrailOffset))); } } } } ProcessTList(); } } }
// ********************************************************************** public Transaction ExecAction(string descr, OwnAction action) { Transaction nt = null; if (MktProvider.TraderStatus.CanTrade) { // MktProvider.Log.Put(">> " + descr + ": Торговая операция " // + (action.IsStop ? "*" : "") + action.Operation + " @" // + action.Quote.ToString().Substring(0, 1) + action.Value + " " // + action.QtyType.ToString().Substring(0, 1) + action.Quantity); lock (tlist) { if (action.Operation == TradeOp.Cancel) { if (action.Quote == BaseQuote.Absolute) { foreach (Transaction t in tlist) { if (t.Price == action.Value) { t.Cancel(); } } } else { foreach (Transaction t in tlist) { t.Cancel(); } } } else { tlist.AddLast(nt = new Transaction(descr, action)); } ProcessTList(); } } return(nt); }
// ********************************************************************** void TryTrail(Transaction t, int price, int sign) { OwnAction a = t.Source; int newStopPrice; if ((t.Trailing || (t.Trailing = sign * (t.Price - price) >= a.TrailStart)) && sign * (t.Price - (newStopPrice = price + sign * a.TrailOffset)) > 0) { MktProvider.Receiver.PutOwnOrder(new OwnOrder(t.TId, t.Price)); t.Price = newStopPrice; PutStopOwnOrder(t); // MktProvider.Log.Put("Стоп-заявка " + t.Descr + " " // + t.TId + " перемещена на " + t.Price + " по " + price); tlistUpdated = true; } }
public static string QtyText(OwnAction action) { switch (action.QtyType) { case QtyType.Absolute: return(action.Quantity.ToString("N", cfg.BaseCulture)); case QtyType.WorkSize: return("Р." + action.Quantity.ToString("N", cfg.BaseCulture) + "%"); case QtyType.Position: return("П." + action.Quantity.ToString("N", cfg.BaseCulture) + "%"); default: if (action.Operation == TradeOp.Pause) { return(action.Quantity.ToString("N", cfg.BaseCulture) + " сек."); } else { return(null); } } }
public TableData(TableData old) { initialize(); error = old.error; players = old.players; myPos = old.myPos; for (int i = 0; i < 10; i++) { stacks[i] = old.stacks[i]; bets[i] = old.bets[i]; } dealerPos = old.dealerPos; for (int i = 0; i < 2; i++) handCards[i] = old.handCards[i]; handIndex = -1; for (int i = 0; i < 5; i++) boardCards[i] = old.boardCards[i]; noSB = old.noSB; BBindex = old.BBindex; BBsize = old.BBsize; errorStr = old.errorStr; allinIndex = old.allinIndex; tableType = old.tableType; casinoname = old.casinoname; SelectedAction = old.SelectedAction; }
public void initialize() { error = 0; players = -1; myPos = -1; stacks = new int[10] {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; bets = new int[10] {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; dealerPos = -1; handCards = new int[2] { -1, -1 }; handIndex = -1; boardCards = new int[5]{-1,-1,-1,-1,-1}; noSB = false; BBindex = -1; BBsize = -1; errorStr = ""; allinIndex = 9; tableType = -1; casinoname = ""; SelectedAction = OwnAction.ENone; }
// ********************************************************************** void LastPriceHandler(int price) { if (stopOrders.Count > 0) { lock (tlist) { int i = 0; while (i < stopOrders.Count) { Transaction t = stopOrders[i]; OwnAction a = t.Source; switch (t.Operation) { case TradeOp.Buy: if (price >= t.Price) { ActivateStopOrder(t, new OwnAction(a.Operation, BaseQuote.Absolute, Price.Floor(t.Price + a.Slippage), a.QtyType, a.Quantity)); stopOrders.RemoveAt(i); } else { if (a.TrailStart > 0) { TryTrail(t, price, 1); } i++; } break; case TradeOp.Sell: if (price <= t.Price) { ActivateStopOrder(t, new OwnAction(a.Operation, BaseQuote.Absolute, Price.Ceil(t.Price - a.Slippage), a.QtyType, a.Quantity)); stopOrders.RemoveAt(i); } else { if (a.TrailStart > 0) { TryTrail(t, price, -1); } i++; } break; default: stopOrders.RemoveAt(i); MktProvider.Receiver.PutOwnOrder(new OwnOrder(t.TId, t.Price)); break; } } } } }