public ActionResult GetAll()
        {
            DealRepository repository = new DealRepository();

            ModelState.Clear();
            return(View(repository.GetAll("GetDealsJoin", true)));
        }
        // GET: TradingProgress/Edit/5
        public ActionResult Edit(int id)
        {
            TradingProgressRepository repository     = new TradingProgressRepository();
            ParticipantRepository     participantRep = new ParticipantRepository();
            DealRepository            dealRep        = new DealRepository();

            TradingProgressModel model = repository.GetById(id);

            model.Buyers = participantRep.GetAll();
            model.Deals  = dealRep.GetAll();

            return(View(model));
        }
        // GET: TradingProgress/Create
        public ActionResult Create()
        {
            ParticipantRepository participantRep = new ParticipantRepository();
            DealRepository        dealRep        = new DealRepository();

            TradingProgressModel model = new TradingProgressModel
            {
                Buyers = participantRep.GetAll(),
                Deals  = dealRep.GetAll()
            };

            return(View(model));
        }
Exemple #4
0
        public static List <string[]> Main_(string member)
        {
            List <string[]> result = new List <string[]>();

            Entity[] temp;
            switch (member)
            {
            case "Buyer":
                BuyerRepository buyer = new BuyerRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = buyer.GetAll().ToArray <Entity>();
                Buyer[] buyers = new Buyer[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    buyers[i] = (Buyer)temp[i];
                }

                for (int i = 0; i < buyers.Length; i++)
                {
                    result.Add(new string[5]);
                    result[i][0] = buyers[i].Id.ToString();
                    result[i][1] = buyers[i].CreationDate.ToString();
                    result[i][2] = buyers[i].DeletedDate.ToString();
                    result[i][3] = buyers[i].Name.ToString();
                    result[i][4] = buyers[i].Surname.ToString();
                }
                break;

            case "Deal":
                DealRepository deal = new DealRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = deal.GetAll().ToArray <Entity>();
                Deal[] deals = new Deal[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    deals[i] = (Deal)temp[i];
                }
                for (int i = 0; i < deals.Length; i++)
                {
                    result.Add(new string[7]);
                    result[i][0] = deals[i].Id.ToString();
                    result[i][1] = deals[i].CreationDate.ToString();
                    //result[i][2] = deals[i].DeletedDate.ToString();
                    result[i][3] = deals[i].IdBuyer.ToString();
                    result[i][4] = deals[i].IdSeller.ToString();
                    result[i][5] = deals[i].Summ.ToString();
                    result[i][6] = deals[i].Date.ToString();
                }
                break;

            case "Saller":
                SallerRepository saller = new SallerRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = saller.GetAll().ToArray <Entity>();
                Saller[] sallers = new Saller[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    sallers[i] = (Saller)temp[i];
                }
                for (int i = 0; i < sallers.Length; i++)
                {
                    result.Add(new string[5]);
                    result[i][0] = sallers[i].Id.ToString();
                    result[i][1] = sallers[i].CreationDate.ToString();
                    //result[i][2] = sallers[i].DeletedDate.ToString();
                    result[i][3] = sallers[i].Name.ToString();
                    result[i][4] = sallers[i].Surname.ToString();
                }
                break;
            }

            return(result);
        }
Exemple #5
0
        public TradeModel(TradeSessionRepository TradeSessionRepository,
                          CandleRepository CandleRepository,
                          OrderRepository OrderRepository,
                          PositionRepository PositionRepository,
                          DealRepository DealRepository,
                          WebApiClient client,
                          ITradeMode mode, Mode modeProperties, object token)
        {
            _token = token;
            _tradeSessionRepository = TradeSessionRepository;
            _candleRepository       = CandleRepository;
            _orderRepository        = OrderRepository;
            _positionRepository     = PositionRepository;
            _dealRepository         = DealRepository;
            _apiClient = client;

            _mode           = mode;
            _modeProperties = modeProperties;

            _candles = new Dictionary <string, IDictionary <string, IList <ICandle> > >();

            Messenger.Default.Register <InitTradeModelMessage>(this, _token, async(msg) =>
            {
                var temp_sessions = await _tradeSessionRepository.GetAll();
                _sessions         = temp_sessions.OrderBy(t => t.Date).ToList();

                _mode.SetAction("init", () =>
                {
                    foreach (string sec in msg.securities)
                    {
                        _candles[sec] = new Dictionary <string, IList <ICandle> >();
                        foreach (string frame in msg.frames)
                        {
                            string res = InitCandles(sec, frame).Result;
                        }
                    }
                });

                _mode.SetAction("initEmpty", () =>
                {
                    foreach (string sec in msg.securities)
                    {
                        _candles[sec] = new Dictionary <string, IList <ICandle> >();
                        foreach (string frame in msg.frames)
                        {
                            _candles[sec][frame] = new List <ICandle>();
                        }
                    }
                });

                _mode.SetAction("update", () =>
                {
                    IEnumerable <Candle> candles = _candleRepository.GetAll().Result;

                    _positionlist = _positionRepository.GetAll().Result;

                    foreach (string sec in msg.securities)
                    {
                        var tempData = candles.Where(c => c.Code == sec).OrderBy(c => c.begin);
                        UpdateCadles(sec, tempData, msg.frames);
                    }

                    this._positions = GetPositions(_positionlist, msg.securities);
                });

                _mode.SetAction("sendToRobo", () =>
                {
                    Messenger.Default.Send <GetCandlesResponseMessage>(new GetCandlesResponseMessage()
                    {
                        DateTime  = mode.GetDate(),
                        Сandles   = _candles,
                        Positions = _positions
                    }, _token);
                });

                _mode.SetAction("showData", () =>
                {
                    _dealRepository.GetAll().ContinueWith(t =>
                    {
                        Messenger.Default.Send <ShowDataMessage>(new ShowDataMessage()
                        {
                            Сandles   = CopyCandles(_candles),
                            Deals     = t.Result,
                            Positions = _positionlist
                        });
                    });
                });

                mode.Start();
            });

            Messenger.Default.Register <CreateOrderMessage>(this, msg =>
            {
                Order order = new Order()
                {
                    Code           = msg.Code,
                    OrderOperation = msg.OrderOperation,
                    Account        = _modeProperties.Account,
                    Price          = msg.Price,
                    Count          = msg.Count,
                    Class          = _modeProperties.Class,
                    Client         = _modeProperties.Client,
                    Comment        = _modeProperties.Client,
                    Profit         = msg.Profit,
                    StopLoss       = msg.StopLoss
                };

                string result = _orderRepository.Create(order).Result;
            });

            //Messenger.Default.Register<GetCandlesMessage>(this, (msg) =>
            //{
            //    Messenger.Default.Send<GetCandlesResponseMessage>(new GetCandlesResponseMessage()
            //    {
            //        Сandles = _candles
            //    });
            //});

            Messenger.Default.Register <ClosePositionMessage>(this, msg =>
            {
                string result = _apiClient.GetData(string.Format("{0}admin/ClosePosition?sec={1}", this.ServerURL, msg.Code)).Result;
            });
        }