Exemplo n.º 1
0
 private bool CreateSystemSettingsFile(ImperaturData SystemData)
 {
     if (SerializeJSONdata.SerializeObject(SystemData, string.Format(@"{0}\{1}", SystemData.SystemDirectory, SystemDataFile)))
     {
         return(true);
     }
     else
     {
         m_oLastErrorMessage = string.Format("Could not save settings file to {0}", SystemData.SystemDirectory);
         return(false);
     }
 }
Exemplo n.º 2
0
 public void LoadImperaturMarket(ImperaturData SystemData)
 {
     //create the system based on the data
     if (!Directory.Exists(SystemData.SystemDirectory))
     {
         if (!CreateImperaturDataFromSystemData(SystemData))
         {
             int gg = 0;
         }
     }
     CreateImperaturMarket(SystemData);
 }
Exemplo n.º 3
0
        private ImperaturData ReadImperaturDataFromSystemLocation(string SystemLocation)
        {
            ImperaturData oD = new ImperaturData();

            try
            {
                oD = (ImperaturData)DeserializeJSON.DeserializeObjectFromFile(string.Format(@"{0}\{1}", SystemLocation, SystemDataFile));
            }
            catch (Exception ex)
            {
                if (Directory.Exists(SystemLocation))
                {
                    ImperaturGlobal.GetLogWithDirectory(SystemLocation).Info("Could not read the system data file!");
                    throw new Exception("SystemDataFile could not be read, major error!");
                }
                else
                {
                    throw new Exception("Systemlocation does not exists, major error!");
                }
            }
            return(oD);
        }
Exemplo n.º 4
0
 private bool CreateImperaturDataFromSystemData(ImperaturData Systemdata)
 {
     ImperaturGlobal.GetLogWithDirectory(Systemdata.SystemDirectory).Info("Creating the Imperatur Market System");
     if (
         CreateDirectory(Systemdata.SystemDirectory)
         &&
         CreateDirectory(string.Format(@"{0}\{1}", Systemdata.SystemDirectory, Systemdata.AcccountDirectory))
         &&
         CreateDirectory(string.Format(@"{0}\{1}\{2}", Systemdata.SystemDirectory, Systemdata.QuoteDirectory, Systemdata.DailyQuoteDirectory))
         &&
         CreateDirectory(string.Format(@"{0}\{1}\{2}", Systemdata.SystemDirectory, Systemdata.QuoteDirectory, Systemdata.HistoricalQuoteDirectory))
         &&
         CreateDirectory(string.Format(@"{0}\{1}", Systemdata.SystemDirectory, Systemdata.OrderDirectory))
         &&
         CreateSystemSettingsFile(Systemdata)
         )
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 5
0
 public static IImperaturMarket BuildImperaturContainer(ImperaturData NewSystemData)
 {
     CreateMarketObject();
     m_oImperaturMarket.LoadImperaturMarket(NewSystemData);
     return(m_oImperaturMarket);
 }
Exemplo n.º 6
0
        private void CreateImperaturMarket(ImperaturData SystemData)
        {
            m_oImperaturData = SystemData;

            CreateSystemNotification("Starting the initializing sequence");
            ImperaturGlobal.GetLogWithDirectory(m_oImperaturData.SystemDirectory).Info("Starting the initialize sequence");
            CreateSystemNotification("Creating cache objects");
            ImperaturGlobal.Initialize(m_oImperaturData, InitiateNinjectKernel(), null);


            List <account.AccountCacheType> BusinessAccounts = new List <account.AccountCacheType>();
            List <IAccountInterface>        oLAB             = new List <IAccountInterface>();

            CreateSystemNotification("Loading accounts");
            if (GetAccountHandler().Accounts().Where(a => a.GetAccountType().Equals(account.AccountType.Bank)).Count() == 0)
            {
                //create internalbankaccount for balance transactions
                //start by create the bankaccount
                oLAB.Add(
                    ImperaturGlobal.Kernel.Get <IAccountInterface>(
                        new Ninject.Parameters.ConstructorArgument("Customer", (object)null),
                        new Ninject.Parameters.ConstructorArgument("AccountType", AccountType.Bank),
                        new Ninject.Parameters.ConstructorArgument("AccountName", "INTERNALBANK")
                        )
                    );
            }
            if (GetAccountHandler().Accounts().Where(a => a.GetAccountType().Equals(account.AccountType.House)).Count() == 0)
            {
                //create internalbankaccount for balance transactions
                //start by create the bankaccount
                oLAB.Add(
                    ImperaturGlobal.Kernel.Get <IAccountInterface>(
                        new Ninject.Parameters.ConstructorArgument("Customer", (object)null),
                        new Ninject.Parameters.ConstructorArgument("AccountType", AccountType.House),
                        new Ninject.Parameters.ConstructorArgument("AccountName", "INTERNALHOUSE")
                        )
                    );
            }
            if (oLAB.Count() > 0)
            {
                GetAccountHandler().CreateAccount(oLAB);
            }

            //add all business accounts to cache
            BusinessAccounts = GetAccountHandler().Accounts().Where(a => !a.GetAccountType().Equals(account.AccountType.Customer)).
                               Select(b =>
                                      new account.AccountCacheType
            {
                AccountType = b.GetAccountType(),
                Identifier  = b.Identifier
            }).ToList();

            CreateSystemNotification("Initializing business accounts");
            ImperaturGlobal.InitializeBusinessAccount(BusinessAccounts);

            CreateSystemNotification("Loading instruments and qoutes");
            ImperaturGlobal.Quotes = GetTradeHandler().GetQuotes();

            CreateSystemNotification("Setting events");
            m_oQuoteTimer          = new System.Timers.Timer();
            m_oQuoteTimer.Elapsed += M_oQuoteTimer_Elapsed;
            m_oQuoteTimer.Interval = 1000 * 60 * Convert.ToInt32(m_oImperaturData.QuoteRefreshTime);
            m_oQuoteTimer.Enabled  = true;

            m_oDisplayCurrency = ImperaturGlobal.Kernel.Get <ICurrency>(new Ninject.Parameters.ConstructorArgument("CurrencyCode", m_oImperaturData.SystemCurrency));
            m_oTradeHandler.QuoteUpdateEvent += M_oTradeHandler_QuoteUpdateEvent;

            m_oOrderQueue      = null;
            m_oTradeAutomation = ImperaturGlobal.Kernel.Get <ITradeAutomation>(new Ninject.Parameters.ConstructorArgument("AccountHandler", GetAccountHandler()));

            m_oTradeAutomation.SystemNotificationEvent += M_oTradeAutomation_SystemNotificationEvent;
            OrderQueue.QueueMaintence(m_oAccountHandler);
            ImperaturGlobal.GetLog().Info("End of the initialize sequence");
            m_oAccountHandler.GetProfitPerForecast();
        }