Exemplo n.º 1
0
        public LeechApp(ILeechConfig config, IBotManager botManager, IBotsConfiguration botsConfig, ITickDispatcher tickDisp, IDataStorage dataStorage,
                        IInstrumTable insTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable,
                        IHoldingTable holdingTable, ICashTable positionTable, AccountTable accountTable, IInsStoreData insStoreData, ILogger logger)
        {
            _config         = config;
            _scheduler      = new Scheduler(logger);
            _botsConfig     = botsConfig;
            _tickDispatcher = tickDisp;
            _botManager     = botManager;
            _dataStorage    = dataStorage;
            _accountTable   = accountTable;
            _instrumTable   = insTable;
            _orderTable     = orderTable;
            _tradeTable     = tradeTable;
            _stopOrderTable = stopOrderTable;
            _holdingTable   = holdingTable;
            _cashTable      = positionTable;
            _insStoreData   = insStoreData;
            _logger         = logger;
            _dataProtect    = IoC.Resolve <DataProtect>();
            _lpClientApp    = new LpClientApp(_dataProtect, _instrumTable, _accountTable, _stopOrderTable, _orderTable,
                                              _tradeTable, _cashTable, _holdingTable, _tickDispatcher, _logger);

            _allTradesData = new AllTradesData(_instrumTable, _insStoreData, _logger);
            _alorTrade     = new AlorTradeWrapper(_instrumTable, _stopOrderTable, _orderTable, _tradeTable,
                                                  _holdingTable, _cashTable, _accountTable,
                                                  _tickDispatcher, _config, _logger);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if this <see cref="IAccountTable"/> contains the same values as another <see cref="IAccountTable"/>.
 /// </summary>
 /// <param name="source">The source <see cref="IAccountTable"/>.</param>
 /// <param name="otherItem">The <see cref="IAccountTable"/> to compare the values to.</param>
 /// <returns>
 /// True if this <see cref="IAccountTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
 /// </returns>
 public static Boolean HasSameValues(this IAccountTable source, IAccountTable otherItem)
 {
     return Equals(source.CreatorIp, otherItem.CreatorIp) && Equals(source.CurrentIp, otherItem.CurrentIp) &&
            Equals(source.Email, otherItem.Email) && Equals(source.ID, otherItem.ID) && Equals(source.Name, otherItem.Name) &&
            Equals(source.Password, otherItem.Password) && Equals(source.Permissions, otherItem.Permissions) &&
            Equals(source.TimeCreated, otherItem.TimeCreated) && Equals(source.TimeLastLogin, otherItem.TimeLastLogin);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if this <see cref="IAccountTable"/> contains the same values as another <see cref="IAccountTable"/>.
 /// </summary>
 /// <param name="source">The source <see cref="IAccountTable"/>.</param>
 /// <param name="otherItem">The <see cref="IAccountTable"/> to compare the values to.</param>
 /// <returns>
 /// True if this <see cref="IAccountTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
 /// </returns>
 public static Boolean HasSameValues(this IAccountTable source, IAccountTable otherItem)
 {
     return(Equals(source.CreatorIp, otherItem.CreatorIp) && Equals(source.CurrentIp, otherItem.CurrentIp) &&
            Equals(source.Email, otherItem.Email) && Equals(source.ID, otherItem.ID) && Equals(source.Name, otherItem.Name) &&
            Equals(source.Password, otherItem.Password) && Equals(source.Permissions, otherItem.Permissions) &&
            Equals(source.TimeCreated, otherItem.TimeCreated) && Equals(source.TimeLastLogin, otherItem.TimeLastLogin));
 }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The key must already exist in the DbParameterValues
/// for the value to be copied over. If any of the keys in the DbParameterValues do not
/// match one of the column names, or if there is no field for a key, then it will be
/// ignored. Because of this, it is important to be careful when using this method
/// since columns or keys can be skipped without any indication.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this IAccountTable source, NetGore.Db.DbParameterValues paramValues)
        {
            for (int i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "creator_ip":
                    paramValues[i] = (System.UInt32)source.CreatorIp;
                    break;


                case "current_ip":
                    paramValues[i] = (System.Nullable <System.UInt32>)source.CurrentIp;
                    break;


                case "email":
                    paramValues[i] = (System.String)source.Email;
                    break;


                case "friends":
                    paramValues[i] = (System.String)source.Friends;
                    break;


                case "id":
                    paramValues[i] = (System.Int32)source.ID;
                    break;


                case "name":
                    paramValues[i] = (System.String)source.Name;
                    break;


                case "password":
                    paramValues[i] = (System.String)source.Password;
                    break;


                case "permissions":
                    paramValues[i] = (System.Byte)source.Permissions;
                    break;


                case "time_created":
                    paramValues[i] = (System.DateTime)source.TimeCreated;
                    break;


                case "time_last_login":
                    paramValues[i] = (System.DateTime)source.TimeLastLogin;
                    break;
                }
            }
        }
Exemplo n.º 5
0
 public LpClientApp(DataProtect dataProtect, IInstrumTable instrumTable,
                    IAccountTable accountTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable,
                    ICashTable positionTable, IHoldingTable holdingTable, ITickDispatcher tickDisp, ILogger logger)
 {
     _dataProtect = dataProtect;
     _socket      = new LpClientSocket();
     _core        = new LpCore(_socket, false); // клиент
     _pipeFactory = new LpAppFactory(_core, instrumTable, accountTable, stopOrderTable, orderTable, tradeTable, positionTable, holdingTable, tickDisp);
     _sysPipe     = new SystemLp(_pipeFactory, _core);
     _logger      = logger;
 }
Exemplo n.º 6
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this AccountTable.
/// </summary>
/// <param name="source">The IAccountTable to copy the values from.</param>
        public void CopyValuesFrom(IAccountTable source)
        {
            this.CreatorIp     = (System.UInt32)source.CreatorIp;
            this.CurrentIp     = (System.Nullable <System.UInt32>)source.CurrentIp;
            this.Email         = (System.String)source.Email;
            this.ID            = (DemoGame.AccountID)source.ID;
            this.Name          = (System.String)source.Name;
            this.Password      = (System.String)source.Password;
            this.Permissions   = (DemoGame.UserPermissions)source.Permissions;
            this.TimeCreated   = (System.DateTime)source.TimeCreated;
            this.TimeLastLogin = (System.DateTime)source.TimeLastLogin;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(IAccountTable source, IDictionary <String, Object> dic)
 {
     dic["creator_ip"]      = source.CreatorIp;
     dic["current_ip"]      = source.CurrentIp;
     dic["email"]           = source.Email;
     dic["id"]              = source.ID;
     dic["name"]            = source.Name;
     dic["password"]        = source.Password;
     dic["permissions"]     = source.Permissions;
     dic["time_created"]    = source.TimeCreated;
     dic["time_last_login"] = source.TimeLastLogin;
 }
Exemplo n.º 8
0
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
///  this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void CopyValues(this IAccountTable source, NetGore.Db.DbParameterValues paramValues)
        {
            paramValues["creator_ip"]      = (System.UInt32)source.CreatorIp;
            paramValues["current_ip"]      = (System.Nullable <System.UInt32>)source.CurrentIp;
            paramValues["email"]           = (System.String)source.Email;
            paramValues["id"]              = (System.Int32)source.ID;
            paramValues["name"]            = (System.String)source.Name;
            paramValues["password"]        = (System.String)source.Password;
            paramValues["permissions"]     = (System.Byte)source.Permissions;
            paramValues["time_created"]    = (System.DateTime)source.TimeCreated;
            paramValues["time_last_login"] = (System.DateTime)source.TimeLastLogin;
        }
Exemplo n.º 9
0
 public SyncPipe(ILpCore core, IInstrumTable instrumTable, IAccountTable accountTable, IStopOrderTable stopOrderTable,
                 IOrderTable orderTable, ITradeTable tradeTable, ICashTable positionTable, IHoldingTable holdingTable)
 {
     _core           = core;
     _instrumTable   = instrumTable;
     _accountTable   = accountTable;
     _stopOrderTable = stopOrderTable;
     _orderTable     = orderTable;
     _tradeTable     = tradeTable;
     _cashTable      = positionTable;
     _holdingTable   = holdingTable;
 }
Exemplo n.º 10
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
        public static void CopyValues(IAccountTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic)
        {
            dic["creator_ip"]      = (System.UInt32)source.CreatorIp;
            dic["current_ip"]      = (System.Nullable <System.UInt32>)source.CurrentIp;
            dic["email"]           = (System.String)source.Email;
            dic["id"]              = (DemoGame.AccountID)source.ID;
            dic["name"]            = (System.String)source.Name;
            dic["password"]        = (System.String)source.Password;
            dic["permissions"]     = (DemoGame.UserPermissions)source.Permissions;
            dic["time_created"]    = (System.DateTime)source.TimeCreated;
            dic["time_last_login"] = (System.DateTime)source.TimeLastLogin;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this AccountTable.
 /// </summary>
 /// <param name="source">The IAccountTable to copy the values from.</param>
 public void CopyValuesFrom(IAccountTable source)
 {
     CreatorIp     = source.CreatorIp;
     CurrentIp     = source.CurrentIp;
     Email         = source.Email;
     ID            = source.ID;
     Name          = source.Name;
     Password      = source.Password;
     Permissions   = source.Permissions;
     TimeCreated   = source.TimeCreated;
     TimeLastLogin = source.TimeLastLogin;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Copies the column values into the given DbParameterValues using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
 ///  this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="paramValues">The DbParameterValues to copy the values into.</param>
 public static void CopyValues(this IAccountTable source, DbParameterValues paramValues)
 {
     paramValues["creator_ip"]      = source.CreatorIp;
     paramValues["current_ip"]      = source.CurrentIp;
     paramValues["email"]           = source.Email;
     paramValues["id"]              = (Int32)source.ID;
     paramValues["name"]            = source.Name;
     paramValues["password"]        = source.Password;
     paramValues["permissions"]     = (Byte)source.Permissions;
     paramValues["time_created"]    = source.TimeCreated;
     paramValues["time_last_login"] = source.TimeLastLogin;
 }
Exemplo n.º 13
0
 public LpAppFactory(ILpCore core, IInstrumTable instrumTable, IAccountTable accountTable, IStopOrderTable stopOrderTable,
                     IOrderTable orderTable, ITradeTable tradeTable, ICashTable positionTable, IHoldingTable holdingTable, ITickDispatcher tickDisp)
 {
     _core           = core;
     _instrumTable   = instrumTable;
     _accountTable   = accountTable;
     _stopOrderTable = stopOrderTable;
     _orderTable     = orderTable;
     _tradeTable     = tradeTable;
     _positionTable  = positionTable;
     _holdingTable   = holdingTable;
     _tickDisp       = tickDisp;
 }
Exemplo n.º 14
0
            /// <summary>
            /// Initializes a new instance of the <see cref="UserAccount"/> class.
            /// </summary>
            /// <param name="accountTable">The account table.</param>
            /// <param name="socket">The socket.</param>
            /// <param name="parent">The <see cref="UserAccountManager"/>.</param>
            /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception>
            /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception>
            internal UserAccount(IAccountTable accountTable, IIPSocket socket, UserAccountManager parent) : base(accountTable)
            {
                if (socket == null)
                {
                    throw new ArgumentNullException("socket");
                }
                if (parent == null)
                {
                    throw new ArgumentNullException("parent");
                }

                _socket = socket;
                _parent = parent;
            }
Exemplo n.º 15
0
 public LeechPlatform(ITickDispatcher tickDisp, IInstrumTable insTable, IHoldingTable holdTable, IOrderTable orderTable, IAccountTable accountTable,
                      AlorTradeWrapper alorTrade, ILogger logger, IInsStoreBL insStoreBL, ILeechConfig leechConfig)
 {
     _tickDisp     = tickDisp;
     _instrumTable = insTable;
     _holdingTable = holdTable;
     _orderTable   = orderTable;
     _accountTable = accountTable;
     _alorTrade    = alorTrade;
     _logger       = logger;
     _insStoreBL   = insStoreBL;
     _leechConfig  = leechConfig;
     _barRows      = new List <BarRow>();
     _onTimer      = null;
     _onTimerTask  = null;
     _ins_onTick   = new Dictionary <int, OnTickDelegate>();
     _insID_pm     = new Dictionary <int, IPosManager>();
 }
Exemplo n.º 16
0
        /// <summary>
        /// Copies the column values into the given DbParameterValues using the database column name
        /// with a prefixed @ as the key. The key must already exist in the DbParameterValues
        /// for the value to be copied over. If any of the keys in the DbParameterValues do not
        /// match one of the column names, or if there is no field for a key, then it will be
        /// ignored. Because of this, it is important to be careful when using this method
        /// since columns or keys can be skipped without any indication.
        /// </summary>
        /// <param name="source">The object to copy the values from.</param>
        /// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this IAccountTable source, DbParameterValues paramValues)
        {
            for (var i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "creator_ip":
                    paramValues[i] = source.CreatorIp;
                    break;

                case "current_ip":
                    paramValues[i] = source.CurrentIp;
                    break;

                case "email":
                    paramValues[i] = source.Email;
                    break;

                case "id":
                    paramValues[i] = (Int32)source.ID;
                    break;

                case "name":
                    paramValues[i] = source.Name;
                    break;

                case "password":
                    paramValues[i] = source.Password;
                    break;

                case "permissions":
                    paramValues[i] = (Byte)source.Permissions;
                    break;

                case "time_created":
                    paramValues[i] = source.TimeCreated;
                    break;

                case "time_last_login":
                    paramValues[i] = source.TimeLastLogin;
                    break;
                }
            }
        }
Exemplo n.º 17
0
 public AlorTradeWrapper(IInstrumTable insTable, IStopOrderTable stopOrderTable, IOrderTable orderTable,
                         ITradeTable tradeTable, IHoldingTable holdingTable, ICashTable positionTable,
                         IAccountTable accountTable, ITickDispatcher tickDisp, ILeechConfig config, ILogger logger)
 {
     _instrumTable        = insTable;
     _stopOrderTable      = stopOrderTable;
     _orderTable          = orderTable;
     _tradeTable          = tradeTable;
     _holdingTable        = holdingTable;
     _positionTable       = positionTable;
     _accountTable        = accountTable;
     _tickDispatcher      = tickDisp;
     _leechConfig         = config;
     _logger              = logger;
     _secBoard            = _leechConfig.SecBoard;
     _addHours            = _leechConfig.CorrectHours;
     _startSessionMskTime = _leechConfig.StartSessionMskTime;
     _endSessionMskTime   = _leechConfig.EndSessionMskTime;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountTable"/> class.
 /// </summary>
 /// <param name="source">IAccountTable to copy the initial values from.</param>
 public AccountTable(IAccountTable source)
 {
     CopyValuesFrom(source);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this AccountTable.
 /// </summary>
 /// <param name="source">The IAccountTable to copy the values from.</param>
 public void CopyValuesFrom(IAccountTable source)
 {
     CreatorIp = source.CreatorIp;
     CurrentIp = source.CurrentIp;
     Email = source.Email;
     ID = source.ID;
     Name = source.Name;
     Password = source.Password;
     Permissions = source.Permissions;
     TimeCreated = source.TimeCreated;
     TimeLastLogin = source.TimeLastLogin;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(IAccountTable source, IDictionary<String, Object> dic)
 {
     dic["creator_ip"] = source.CreatorIp;
     dic["current_ip"] = source.CurrentIp;
     dic["email"] = source.Email;
     dic["id"] = source.ID;
     dic["name"] = source.Name;
     dic["password"] = source.Password;
     dic["permissions"] = source.Permissions;
     dic["time_created"] = source.TimeCreated;
     dic["time_last_login"] = source.TimeLastLogin;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountTable"/> class.
 /// </summary>
 /// <param name="source">IAccountTable to copy the initial values from.</param>
 public AccountTable(IAccountTable source)
 {
     CopyValuesFrom(source);
 }
Exemplo n.º 22
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this AccountTable.
/// </summary>
/// <param name="source">The IAccountTable to copy the values from.</param>
public void CopyValuesFrom(IAccountTable source)
{
this.CreatorIp = (System.UInt32)source.CreatorIp;
this.CurrentIp = (System.Nullable<System.UInt32>)source.CurrentIp;
this.Email = (System.String)source.Email;
this.ID = (DemoGame.AccountID)source.ID;
this.Name = (System.String)source.Name;
this.Password = (System.String)source.Password;
this.Permissions = (DemoGame.UserPermissions)source.Permissions;
this.TimeCreated = (System.DateTime)source.TimeCreated;
this.TimeLastLogin = (System.DateTime)source.TimeLastLogin;
}
Exemplo n.º 23
0
        public PosManager(int insID, IInstrumTable instrums, IHoldingTable holdings, IOrderTable orders, IAccountTable accounts, AlorTradeWrapper alorTrade)
        {
            _holdings = holdings;
            _orders   = orders;
            _instrum  = instrums.GetInstrum(insID);
            if (_instrum == null)
            {
                throw new Exception("Инструмент не найден");
            }

            _account = accounts.GetDefaultAccount();
            if (_account == null)
            {
                throw new Exception("Не найден торговый счет");
            }

            _alorTrade = alorTrade;
        }
Exemplo n.º 24
0
            /// <summary>
            /// Initializes a new instance of the <see cref="UserAccount"/> class.
            /// </summary>
            /// <param name="accountTable">The account table.</param>
            /// <param name="socket">The socket.</param>
            /// <param name="parent">The <see cref="UserAccountManager"/>.</param>
            /// <exception cref="ArgumentNullException"><paramref name="socket" /> is <c>null</c>.</exception>
            /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception>
            internal UserAccount(IAccountTable accountTable, IIPSocket socket, UserAccountManager parent) : base(accountTable)
            {
                if (socket == null)
                    throw new ArgumentNullException("socket");
                if (parent == null)
                    throw new ArgumentNullException("parent");

                _socket = socket;
                _parent = parent;
            }
Exemplo n.º 25
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
public static void CopyValues(IAccountTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic)
{
dic["creator_ip"] = (System.UInt32)source.CreatorIp;
dic["current_ip"] = (System.Nullable<System.UInt32>)source.CurrentIp;
dic["email"] = (System.String)source.Email;
dic["id"] = (DemoGame.AccountID)source.ID;
dic["name"] = (System.String)source.Name;
dic["password"] = (System.String)source.Password;
dic["permissions"] = (DemoGame.UserPermissions)source.Permissions;
dic["time_created"] = (System.DateTime)source.TimeCreated;
dic["time_last_login"] = (System.DateTime)source.TimeLastLogin;
}