internal BindingSource GetBindingSource(ZoneRecoveryAccount acc) { BindingSource bs = new BindingSource(); bs.DataSource = _posList[acc]; return(bs); }
internal void HandleUpdatePosition(Position newPos, ZoneRecoveryAccount acc) { List <string> removeList = new List <string>() { newPos.Symbol }; if (_posList[acc].Where(p => p.Symbol == newPos.Symbol).Count() == 0 || (DontKeepEmptyPositions && newPos.CurrentQty == 0)) { HandleNewPosition(newPos, acc); } else { Position oldPos = _posList[acc].Where(p => p.Symbol == newPos.Symbol).First(); var posType = typeof(Position); var properties = posType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(prop => prop.CanRead && prop.CanWrite); foreach (var property in properties) { if (property.Name != "Account" && property.Name != "Symbol" && property.Name != "Currency" && property.Name.IndexOf("Simple") == -1) { var value = property.GetValue(newPos, null); if (value != null) { property.SetValue(oldPos, value, null); } } } } }
public ZoneRecoveryBatchOrder(ZoneRecoveryAccount acc, OrderPOSTRequestParams postParams, ZoneRecoveryOrderType orderType) { PostParams = postParams; Account = acc; CurrentStatus = ZoneRecoveryOrderStatus.Undefined; OrderType = orderType; }
public void CheckStatusses(ZoneRecoveryAccount acc, List <Order> orderList) { foreach (Order o in orderList) { ZROrdersList.Where(x => x.PostParams.ClOrdID == o.ClOrdId).Single().SetLastStatus(o); } CheckBatchStatus(); }
internal void HandleDeletePosition(Position newPos, ZoneRecoveryAccount acc) { List <string> removeList = new List <string>() { newPos.Symbol }; _posList[acc].RemoveAll(r => removeList.Any(a => a == r.Symbol)); }
internal void HandleDeleteOrder(Order newOrder, ZoneRecoveryAccount acc) { List <string> removeList = new List <string>() { newOrder.OrderId }; _orderList[acc].RemoveAll(r => removeList.Any(a => a == r.OrderId)); }
internal bool HandleUpdateOrder(Order newOrder, ZoneRecoveryAccount acc) { bool statusChanged = false; List <string> removeList = new List <string>() { newOrder.OrderId }; if (!_orderList.ContainsKey(acc) || _orderList[acc] == null || _orderList[acc].Where(p => p.OrderId == newOrder.OrderId).Count() == 0) { HandleNewOrder(newOrder, acc); statusChanged = true; } else { Order oldOrd = _orderList[acc].Where(p => p.OrderId == newOrder.OrderId).First(); // Update the existing order with the new property values. var posType = typeof(Order); var properties = posType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(prop => prop.CanRead && prop.CanWrite); foreach (var property in properties) { if (property.Name != "OrderId" && property.Name != "ClOrdID" && property.Name != "Account" && property.Name != "Symbol" && property.Name.IndexOf("Simple") == -1) { var value = property.GetValue(newOrder, null); if (value != null) { if (property.Name == "OrdStatus") { if (value is OrderStatus && (OrderStatus)value != OrderStatus.Undefined) { statusChanged = true; property.SetValue(oldOrd, value, null); } } else { property.SetValue(oldOrd, value, null); } } } } } return(statusChanged); }
public void UpdateBalances(ZoneRecoveryAccount acc, long?walletBalance = null, long?marginBalance = null, long?availableBalance = null) { if (walletBalance != null) { WalletBalance[acc] = (long)walletBalance; } if (marginBalance != null) { MarginBalance[acc] = (long)marginBalance; } if (availableBalance != null) { AvailableMargin[acc] = (long)availableBalance; } }
internal void HandleNewOrder(Order newOrder, ZoneRecoveryAccount acc) { List <string> removeList = new List <string>() { newOrder.OrderId }; // If the there is already an entry, remove the entry. if (_orderList[acc].Where(o => o.OrderId == newOrder.OrderId).Count() > 0) { _orderList[acc].RemoveAll(r => removeList.Any(a => a == r.OrderId)); } // Add the new entry _orderList[acc].Add(newOrder); }
internal void HandleNewPosition(Position newPos, ZoneRecoveryAccount acc) { List <string> removeList = new List <string>() { newPos.Symbol }; // If there is already an entry in the list for the given symbol and account, remove the entry. if (_posList[acc].Where(o => o.Symbol == newPos.Symbol).Count() > 0 || (DontKeepEmptyPositions && newPos.CurrentQty == 0)) { _posList[acc].RemoveAll(r => removeList.Any(a => a == r.Symbol)); } // Add the new position to the list if (!(DontKeepEmptyPositions && newPos.CurrentQty == 0)) { _posList[acc].Add(newPos); } }
public int GetDisconnections(ZoneRecoveryAccount acc) { return(Disconnections[acc]); }
public int GetErrorCnt(ZoneRecoveryAccount acc) { return(ErrorCount[acc]); }
public void Add2Disconnections(int errCnt, ZoneRecoveryAccount acc) { Disconnections[acc] = Disconnections[acc] + errCnt; }
public void Add2ErrorCnt(int errCnt, ZoneRecoveryAccount acc) { ErrorCount[acc] = ErrorCount[acc] + errCnt; }
private void Clear(ZoneRecoveryAccount acc) { _view.Bid = string.Empty; _view.Ask = string.Empty; _view.BidAmount = string.Empty; _view.AskAmount = string.Empty; _view.Trades1Min(string.Empty, Side.Buy); _view.Trades5Min(string.Empty, Side.Buy); _view.Trades15Min(string.Empty, Side.Buy); _view.Trades1Hour(string.Empty, Side.Buy); _view.Trades24Hours(string.Empty, Side.Buy); _view.TimeConnected = string.Empty; _view.ErrorsCounterTotal = string.Empty; _view.CashImbalance = string.Empty; _view.Direction = string.Empty; _view.UnitSize = string.Empty; _view.ZRStatus = string.Empty; _view.ZRIndex = string.Empty; _view.Leverage = 1; _view.MaxDepth = 3; _view.ZoneSize = 20; _view.MaxExposure = (decimal)0.05; _view.MinProfit = (decimal)0.05; if (acc == ZoneRecoveryAccount.A) { _view.AccountAID = string.Empty; _view.AvailableFundsA = string.Empty; _view.ConnStartA = string.Empty; _view.ConnStatusA = string.Empty; _view.PingL = string.Empty; _view.TabOrdersATitle = "Orders [0]"; _view.TabPosATitle = "Positions [0]"; _view.TotalFundsA = string.Empty; _view.MarginBalanceA = string.Empty; _view.bSRCOrdersA = new BindingSource(); _view.bSRCPosA = new BindingSource(); _view.DisconnectionsA = string.Empty; _view.ReconnectionsA = string.Empty; _view.ErrorsCounterA = string.Empty; _view.TotalCostA = string.Empty; _view.PNLA = string.Empty; } else { _view.AccountBID = string.Empty; _view.AvailableFundsB = string.Empty; _view.ConnStartB = string.Empty; _view.ConnStatusB = string.Empty; _view.PingS = string.Empty; _view.TabOrdersBTitle = "Orders [0]"; _view.TabPosBTitle = "Positions [0]"; _view.TotalFundsB = string.Empty; _view.MarginBalanceB = string.Empty; _view.bSRCOrdersB = new BindingSource(); _view.bSRCPosB = new BindingSource(); _view.DisconnectionsB = string.Empty; _view.ReconnectionsB = string.Empty; _view.ErrorsCounterB = string.Empty; _view.TotalCostB = string.Empty; _view.PNLB = string.Empty; } }
public MarginStats GetMarginBalances(ZoneRecoveryAccount acc) { return(new MarginStats(WalletBalance[acc], MarginBalance[acc], AvailableMargin[acc])); }