Exemplo n.º 1
0
        public void LoginFund(FundRegistration registration, string exchangeId)
        {
            FundDepot depot;
            var       exists = data.Exchanges[exchangeId].FundDepots.TryGetValue(registration.Id, out depot);

            if (!exists)
            {
                if (data.Exchanges[exchangeId].Brokers.Count > 0)
                {
                    FundRequestResult result = data.Exchanges[exchangeId].Brokers.First().ProcessFundRegistration(registration);
                    depot = result.FundDepot;
                    var info  = result.ShareInformation;
                    var order = result.Order;
                    data.Exchanges[exchangeId].FundDepots[depot.Id]     = depot;
                    data.Exchanges[exchangeId].InvestorDepots[depot.Id] = depot as InvestorDepot;
                    if (info != null && order != null)
                    {
                        data.Exchanges[exchangeId].Orders[order.Id] = order;
                        data.Exchanges[exchangeId].ShareInformation[info.FirmName] = info;
                        NotifySubscribers(data.Exchanges[exchangeId].OrderCallbacks, order);
                        NotifySubscribers(data.Exchanges[exchangeId].ShareInformationCallbacks, info);
                    }
                    NotifySubscribers(data.Exchanges[exchangeId].FundCallbacks, result.FundDepot);
                }
                else
                {
                    data.Exchanges[exchangeId].PendingFundRegistrationRequests.Add(registration);
                }
            }
            else
            {
                NotifySubscribers(data.Exchanges[exchangeId].FundCallbacks, data.Exchanges[exchangeId].FundDepots[registration.Id]);
            }
        }
        public FundRequestResult ProcessFundRegistration(FundRegistration request)
        {
            var fundName = request.Id;
            var depot    = new FundDepot
            {
                Id           = fundName,
                ExchangeName = exchangeId,
                Budget       = request.FundAssets,
                Shares       = new Dictionary <string, int>()
            };
            ShareInformation info  = null;
            Order            order = null;

            if (request.Shares > 0)
            {
                var exchanges = wallstreetClient.GetExchanges();
                var list      = new List <FundDepot>();
                foreach (string e in exchanges)
                {
                    var fund = wallstreetClient.GetFundDepot(fundName, e);
                    if (fund != null)
                    {
                        list.Add(fund);
                    }
                }
                var assets = list.Sum(x => x.Budget);
                assets += request.FundAssets;

                depot.Shares.Add(fundName, request.Shares);
                info = new ShareInformation
                {
                    FirmName         = fundName,
                    NoOfShares       = request.Shares,
                    PricePerShare    = assets / request.Shares,
                    PurchasingVolume = 0,
                    SalesVolume      = request.Shares,
                    IsFund           = true,
                    ExchangeName     = exchangeId
                };
                order = new Order
                {
                    Id                  = fundName + DateTime.Now.Ticks,
                    ShareName           = fundName,
                    InvestorId          = fundName,
                    Type                = OrderType.SELL,
                    TotalNoOfShares     = request.Shares,
                    NoOfOpenShares      = request.Shares,
                    NoOfProcessedShares = 0,
                    Status              = OrderStatus.OPEN,
                    Limit               = 0,
                    Prioritize          = false,
                    IsFundShare         = true
                };
            }
            return(new FundRequestResult {
                FundDepot = depot, ShareInformation = info, Order = order
            });
        }
Exemplo n.º 3
0
 public void Login(FundRegistration r, string exchangeId)
 {
     fundid = r.Id;
     client.SubscribeOnNewShareInformationAvailable(exchangeId);
     client.SubscribeOnNewOrderAvailable(exchangeId);
     client.SubscribeOnNewTransactionAvailable(exchangeId);
     client.SubscribeOnNewInvestorDepotAvailable(exchangeId);
     client.SubscribeOnNewFundDepotAvailable(exchangeId);
     client.LoginFund(r, exchangeId);
 }