public async Task RequestedSubscription(string applicationName, List <string> symbols)
        {
            AbstractExchangePlugin abstractExchangePlugin =
                _exchangePluginService.PluginExchanges.FirstOrDefault(x => x.ApplicationName == applicationName);

            if (abstractExchangePlugin == null)
            {
                return;
            }
            List <Product> products = symbols.Select(symbol => new Product {
                ID = symbol
            }).ToList();
            await abstractExchangePlugin.ChangeFeed(products);
        }
Beispiel #2
0
        public async Task RequestedCancelAllOrder(string applicationName, string symbol)
        {
            AbstractExchangePlugin abstractExchangePlugin =
                _exchangePluginService.PluginExchanges.FirstOrDefault(x => x.ApplicationName == applicationName);

            if (abstractExchangePlugin == null)
            {
                return;
            }
            Product product = new Product {
                ID = symbol
            };
            List <Order> orders = await abstractExchangePlugin.CancelAllOrdersAsync(product);

            await Clients.Caller.NotifyOrders(abstractExchangePlugin.ApplicationName, orders);
        }
Beispiel #3
0
        public async Task RequestedFillStatistics(string applicationName, string symbol)
        {
            AbstractExchangePlugin abstractExchangePlugin =
                _exchangePluginService.PluginExchanges.FirstOrDefault(x => x.ApplicationName == applicationName);

            if (abstractExchangePlugin == null)
            {
                return;
            }
            Product product = new Product {
                ID = symbol
            };
            FillStatistics fillStatistic = await abstractExchangePlugin.UpdateFillStatistics(product);

            await Clients.Caller.NotifyFillStatistics(abstractExchangePlugin.ApplicationName, fillStatistic);
        }
Beispiel #4
0
 public void AddPluginFromFolder(string folderPath)
 {
     try
     {
         foreach (string plugin in Directory.GetFiles(folderPath))
         {
             FileInfo file = new FileInfo(plugin);
             if (!file.Extension.Equals(".dll"))
             {
                 continue;
             }
             Assembly pluginAssembly = Assembly.LoadFrom(plugin); //Load assembly given its full name and path
             foreach (Type pluginType in pluginAssembly.GetTypes())
             {
                 if (!pluginType.IsPublic)
                 {
                     continue;                       //break the for each loop to next iteration if any
                 }
                 if (pluginType.IsAbstract)
                 {
                     continue;                        //break the for each loop to next iteration if any
                 }
                 //search for specified interface while ignoring case sensitivity
                 if (pluginType.BaseType?.FullName != null && (pluginType.BaseType == null ||
                                                               pluginType.BaseType.FullName.ToLower() !=
                                                               AssemblyBaseTypeFullName))
                 {
                     continue;
                 }
                 //New plug-in information setting
                 AbstractExchangePlugin pluginInterfaceInstance =
                     (AbstractExchangePlugin)Activator.CreateInstance(
                         pluginAssembly.GetType(pluginType.ToString()) !);
                 _pluginExchanges.Add(pluginInterfaceInstance);
             }
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Beispiel #5
0
        public async Task RequestedPlaceOrder(string applicationName, Order order)
        {
            AbstractExchangePlugin abstractExchangePlugin =
                _exchangePluginService.PluginExchanges.FirstOrDefault(x => x.ApplicationName == applicationName);

            if (abstractExchangePlugin == null)
            {
                return;
            }
            Product product = new Product {
                ID = order.ProductID
            };
            await abstractExchangePlugin.PostOrdersAsync(order);

            List <Order> postedOrders = abstractExchangePlugin.Orders;
            await Clients.Caller.NotifyOrders(applicationName, postedOrders);

            List <Fill> fills = await abstractExchangePlugin.UpdateFillsAsync(product);

            await Clients.Caller.NotifyFills(applicationName, fills);
        }