Пример #1
0
 public Transmitter(TradeeBotModel model, string sym, TransmitterSettings settings)
 {
     Settings             = settings;
     Model                = model;
     Data                 = new Dictionary <TimeFrame, MarketSeriesData>();
     HistoricDataRequests = new List <HistoricDataRequest>();
     SymbolCode           = sym;
     Enabled              = true;
     StatusMsg            = "Active";
     AverageSpread        = new ExpMovingAvr(50);
 }
Пример #2
0
        /// <summary>Request a series from the server in a background thread</summary>
        private void AcquireSeries(TimeFrame time_frame, TradeeBotModel model)         // worker thread context
        {
            var symbol = (Symbol)null;
            var series = (MarketSeries)null;
            var error  = (Exception)null;

            try
            {
                // Get the symbol
                symbol = model.GetSymbol(SymbolCode);
                if (symbol == null)
                {
                    throw new Exception("Symbol {0} not available".Fmt(SymbolCode));
                }

                // Get the data series
                series = model.GetSeries(symbol, time_frame);
            }
            catch (Exception ex)
            {
                error = ex;
            }
            finally
            {
                // Add the received series to the collection
                model.RunOnMainThread(() =>
                {
                    // If the symbol was unavailable, then flag the transmitter for deletion
                    if (symbol == null)
                    {
                        Invalid = true;
                    }

                    // If the series is unavailable, remove it from the desired list
                    else if (series == null)
                    {
                        TimeFrames = TimeFrames.Except(time_frame.ToTradeeTimeframe()).ToArray();
                    }

                    // Otherwise add the acquired series to the available data
                    else
                    {
                        Data.Add(m_pending, new MarketSeriesData(series));
                    }

                    // Clear the pending flags
                    m_pending            = null;
                    RequestingSeriesData = false;
                    StatusMsg            = error != null ? error.Message : "Active";
                });
            }
        }
Пример #3
0
        public TradeeBotUI(Robot robot)
        {
            InitializeComponent();
            DoubleBuffered = true;
            StartPosition  = FormStartPosition.Manual;
            Location       = Cursor.Position;

            var settings_path = Util.ResolveAppDataPath("Rylogic", "Tradee", "tradeebot_settings.xml");

            Model = new TradeeBotModel(robot, new Settings(settings_path)
            {
                AutoSaveOnChanges = true
            });

            SetupUI();
            UpdateUI();

            m_timer.Interval = 500;
            m_timer.Tick    += (s, a) => Model.Step();
            m_timer.Enabled  = true;
        }