コード例 #1
0
        internal BindingSource GetBindingSource(ZoneRecoveryAccount acc)
        {
            BindingSource bs = new BindingSource();

            bs.DataSource = _posList[acc];
            return(bs);
        }
コード例 #2
0
        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);
                        }
                    }
                }
            }
        }
コード例 #3
0
 public ZoneRecoveryBatchOrder(ZoneRecoveryAccount acc, OrderPOSTRequestParams postParams, ZoneRecoveryOrderType orderType)
 {
     PostParams    = postParams;
     Account       = acc;
     CurrentStatus = ZoneRecoveryOrderStatus.Undefined;
     OrderType     = orderType;
 }
コード例 #4
0
 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();
 }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 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;
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
 public int GetDisconnections(ZoneRecoveryAccount acc)
 {
     return(Disconnections[acc]);
 }
コード例 #12
0
 public int GetErrorCnt(ZoneRecoveryAccount acc)
 {
     return(ErrorCount[acc]);
 }
コード例 #13
0
 public void Add2Disconnections(int errCnt, ZoneRecoveryAccount acc)
 {
     Disconnections[acc] = Disconnections[acc] + errCnt;
 }
コード例 #14
0
 public void Add2ErrorCnt(int errCnt, ZoneRecoveryAccount acc)
 {
     ErrorCount[acc] = ErrorCount[acc] + errCnt;
 }
コード例 #15
0
ファイル: MTMainPresenter.cs プロジェクト: Paulito123/BitMEX
        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;
            }
        }
コード例 #16
0
 public MarginStats GetMarginBalances(ZoneRecoveryAccount acc)
 {
     return(new MarginStats(WalletBalance[acc], MarginBalance[acc], AvailableMargin[acc]));
 }