Пример #1
0
        public Uc_Strategy(IOrderMaker orderMaker, TradeSettings settings, ITimeManager timeManager, ILogger logger)
        {
            this._orderMaker    = orderMaker;
            this._tradeSettings = settings;
            this._timeManager   = timeManager;
            this._logger        = logger;

            InitializeComponent();

            if (!File.Exists(_tradeSettings.FileName))
            {
                File.Create(_tradeSettings.FileName).Close();
            }
            _positionFile    = new PositionFile();
            _positionManager = ServiceFactory.CreatePositionManager(_orderMaker, _tradeSettings, logger);

            this.timer.Interval = _tradeSettings.Interval;
            this.timer.Enabled  = true;

            #region  UI
            var lbl = UIHelpers.CreateLabel(_tradeSettings.Name);
            lbl.Font = new System.Drawing.Font("新細明體", 11.25F);
            this.tpTop.Controls.Add(lbl, 0, 0);


            this.tpTop.Controls.Add(UIHelpers.CreateLabel("即時部位:"), 2, 0);
            lblPosition = UIHelpers.CreateLabel("");
            this.tpTop.Controls.Add(lblPosition, 3, 0);


            lblTime = UIHelpers.CreateLabel("");
            this.tpTop.Controls.Add(lblTime, 4, 0);


            for (int i = 0; i < _tradeSettings.Accounts.Count; i++)
            {
                var item = _tradeSettings.Accounts[i];

                var uc_Account = new Uc_Account();
                uc_Account.BindData(item);

                this.uc_AccountList.Add(uc_Account);


                fpanelAccounts.Height += uc_Account.Height;
                this.fpanelAccounts.Controls.Add(uc_Account);
                fpanelAccounts.Controls.SetChildIndex(uc_Account, 0);


                this.Height += uc_Account.Height;
            }
            #endregion
        }
Пример #2
0
        void OnRound()
        {
            try
            {
                var file = ReadPositionFile();
                if (file == null)
                {
                    return;
                }

                _positionManager.SyncPosition(file);

                this._positionFile = file;
                RenderPositionInfo();
            }
            catch (Exception ex)
            {
                _logger.LogException(ex);
            }
        }