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
            });
        }
 public WcfDataService()
 {
     client    = new WallstreetDataServiceClient(new InstanceContext(this));
     exchanges = client.GetExchanges();
     foreach (string e in exchanges)
     {
         client.SubscribeOnNewShareInformationAvailable(e);
         client.SubscribeOnNewOrderAvailable(e);
         client.SubscribeOnNewTransactionAvailable(e);
     }
     marketCallbacks           = new List <Action <ShareInformation> >();
     orderAddedCallbacks       = new List <Action <Order> >();
     orderRemovedCallbacks     = new List <Action <Order> >();
     transactionAddedCallbacks = new List <Action <Transaction> >();
 }
示例#3
0
        static void Main(string[] args)
        {
            var wallstreetClient = new WallstreetDataServiceClient(new InstanceContext(new WallstreetHandlerDummy()));

            Console.WriteLine("Type in the name of the exchange you want to connect to. Available:");
            var exchanges = wallstreetClient.GetExchanges();

            foreach (string e in exchanges)
            {
                Console.WriteLine(e);
            }
            var exchangeId             = Console.ReadLine();
            var handler                = new BrokerHandler(wallstreetClient, exchangeId);
            BrokerServiceClient client = new BrokerServiceClient(new InstanceContext(handler));

            client.RegisterBroker(exchangeId);
            Console.WriteLine("Broker online. Press enter to exit ...");
            Console.ReadLine();
            client.UnregisterBroker(exchangeId);
            client.Close();
        }
示例#4
0
 public IEnumerable <string> LoadExchangeInformation()
 {
     return(client.GetExchanges());
 }