Example #1
0
        public IFuture <HttpQueryResponse> ProcessQuery(string name,
                                                        IDictionary <string, string> options, AsyncCallback callback, object state)
        {
            QueryRequestMessage request = new QueryRequestMessage.Builder()
                                          .SetName(name)
                                          .AddRangeOptions(GetQueryOptions(options))
                                          .Build();

            RubyMessagePacket packet = GetMessagePacket(GetNextRequestId(),
                                                        request.ToByteString());

            try {
                QueryFuture future = new SettableFuture <HttpQueryResponse>(state);
                Tuple <AsyncCallback, QueryFuture> tuple = Tuple.Create(callback, future);
                futures_.Add(request_id_, tuple);

                // Send the request and wait for the response. The request should
                // follow the REQ/REP pattern, which contains the following parts:
                //   1. [EMPTY FRAME]
                //   2. [MESSAGE]
                //
                socket_.SendMore();
                socket_.Send(packet.ToByteArray());
                return(future);
            } catch (ZMQ.Exception zmqe) {
                return
                    (Futures.ImmediateFuture(
                         GetExceptionResponse(name, HttpStatusCode.InternalServerError, zmqe)));
            } catch (System.Exception e) {
                return
                    (Futures.ImmediateFuture(
                         GetExceptionResponse(name, HttpStatusCode.InternalServerError, e)));
            }
        }
 public virtual void OnSuccess(LocatedFileStatusFetcher.ProcessInputDirCallable.Result
                               result)
 {
     try
     {
         if (result.locatedFileStatuses.Count != 0)
         {
             this._enclosing.resultQueue.AddItem(result.locatedFileStatuses);
         }
         if (result.dirsNeedingRecursiveCalls.Count != 0)
         {
             foreach (FileStatus fileStatus in result.dirsNeedingRecursiveCalls)
             {
                 this._enclosing.runningTasks.IncrementAndGet();
                 ListenableFuture <LocatedFileStatusFetcher.ProcessInputDirCallable.Result> future =
                     this._enclosing.exec.Submit(new LocatedFileStatusFetcher.ProcessInputDirCallable
                                                     (result.fs, fileStatus, this._enclosing.recursive, this._enclosing.inputFilter));
                 Futures.AddCallback(future, this._enclosing.processInputDirCallback);
             }
         }
         this._enclosing.DecrementRunningAndCheckCompletion();
     }
     catch (Exception t)
     {
         // Error within the callback itself.
         this._enclosing.RegisterError(t);
     }
 }
Example #3
0
        public Korea(int type)
        {
            InitializeComponent();
            dr = Choose.Show("Please Select the Button You Want to Proceed. . .", "Choose", "Trading", "BackTest", "Exit");

            if (dr == DialogResult.Yes)
            {
                Confirm.Get().Show();
                api = Futures.Get();
                new Statistics(type);
                new Temporary(type);
                api.SetAPI(axAPI);
                api.StartProgress(type);
                api.SendExit += OnReceiveExit;
            }
            else if (dr == DialogResult.No)
            {
                axAPI.Dispose();
                int i, l = type > 0 ? 50 : 100;

                for (i = type > 0 ? 1 : 10; i < l; i++)
                {
                    new Statistics(i, type);
                }

                new Storage(type);
                Box.Show("Complete. . .♬", "Notice", 3750);
                OnReceiveExit();
            }
            else
            {
                OnReceiveExit();
            }
        }
 public virtual void OnSuccess(LocatedFileStatusFetcher.ProcessInitialInputPathCallable.Result
                               result)
 {
     try
     {
         if (result.errors != null)
         {
             this._enclosing.RegisterInvalidInputError(result.errors);
         }
         if (result.matchedFileStatuses != null)
         {
             foreach (FileStatus matched in result.matchedFileStatuses)
             {
                 this._enclosing.runningTasks.IncrementAndGet();
                 ListenableFuture <LocatedFileStatusFetcher.ProcessInputDirCallable.Result> future =
                     this._enclosing.exec.Submit(new LocatedFileStatusFetcher.ProcessInputDirCallable
                                                     (result.fs, matched, this._enclosing.recursive, this._enclosing.inputFilter));
                 Futures.AddCallback(future, this._enclosing.processInputDirCallback);
             }
         }
         this._enclosing.DecrementRunningAndCheckCompletion();
     }
     catch (Exception t)
     {
         // Exception within the callback
         this._enclosing.RegisterError(t);
     }
 }
        public IFuture <T> LoadFuture(string key, CacheLoader <T> loader)
        {
            stopwatch_.Start();
            T previous_value = old_value_.Value;

            try {
                // If the T is a value type and its value is default(T) it will never
                // be reloaded and always loaded from the cache loader. We could
                // make the parameter T nullable, but this makes the code much more
                // complicated and we do not want that.
                if (typeof(T).IsValueType || (object)previous_value == null)
                {
                    T new_value = loader.Load(key);
                    return(Set(new_value) ? this : Futures.ImmediateFuture(new_value));
                }
                else
                {
                    IFuture <T> new_value_future = loader.Reload(key, previous_value);
                    return(new_value_future ?? Futures.ImmediateFuture(default(T)));
                }
            } catch (Exception exception) {
                return(SetException(exception)
          ? this
          : Futures.ImmediateFailedFuture <T>(exception));
            }
        }
Example #6
0
        /// <summary>
        /// Dispose the client
        /// </summary>
        public void Dispose()
        {
            Spot.Dispose();
            Futures.Dispose();

            GC.SuppressFinalize(this);
        }
Example #7
0
 /// <exception cref="System.Exception"/>
 public virtual ListenableFuture <T> Answer(InvocationOnMock invocation)
 {
     if (this._enclosing.r.NextFloat() < this.faultProbability)
     {
         return(Futures.ImmediateFailedFuture(new IOException("Injected fault")));
     }
     return((ListenableFuture <T>)invocation.CallRealMethod());
 }
Example #8
0
 public Temporary(int type)
 {
     memo              = new List <string>(32768);
     act               = new Action(() => Save());
     this.type         = type > 0 ? @"\TickChart\Kosdaq150\" : @"\TickChart\Kospi200\";
     api               = Futures.Get();
     api.SendMemorize += OnReceiveMemorize;
 }
Example #9
0
        public Balance()
        {
            InitializeComponent();

            gap = chart.Series["Revenue"];

            Futures.Get().SendBalance += Make;
        }
Example #10
0
        public ApplicationItem(ClassCod classCod, Futures security, TimeFrame timeFrame)
        {
            this.classCod = classCod.ToString();

            this.security = security.ToString();

            this.timeFrame = timeFrame;
        }
Example #11
0
        public ApplicationItem(ClassCod classCod, Futures security, TimeFrame timeFrame, int fractalPeriod = 0, FindPattern pattern = null)
        {
            this.classCod = classCod.ToString();

            this.security = security.ToString();

            this.timeFrame = timeFrame;

            this.fractalParam = fractalPeriod;

            this.findPattern = pattern;
        }
Example #12
0
 internal static Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall <KEY, RESULT> Create
 <Key, Result>(IDictionary <KEY, ListenableFuture <RESULT> > calls)
 {
     Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall <KEY, RESULT> qr = new Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall
                                                                          <KEY, RESULT>();
     foreach (KeyValuePair <KEY, ListenableFuture <RESULT> > e in calls)
     {
         Preconditions.CheckArgument(e.Value != null, "null future for key: " + e.Key);
         Futures.AddCallback(e.Value, new _FutureCallback_68(qr, e));
     }
     return(qr);
 }
Example #13
0
 public override Future <FileStatus> Load(Path path)
 {
     try
     {
         FileSystem fs = path.GetFileSystem(conf);
         return(Futures.ImmediateFuture(fs.GetFileStatus(path)));
     }
     catch (Exception th)
     {
         // report failures so it can be memoized
         return(Futures.ImmediateFailedFuture(th));
     }
 }
Example #14
0
        public GoblinBat()
        {
            InitializeComponent();

            api = Futures.Get();

            new Statistics();
            new Temporary();

            timer.Start();
            api.SetAPI(axAPI);
            api.StartProgress();
            api.SendExit += OnReceiveExit;
        }
Example #15
0
        private string[] CreatePosTableDataRowFromFut(Futures fut)
        {
            string[] rowData    = new string[12];
            int      indexCount = 4;

            rowData[0] = "F";
            rowData[1] = "0";
            rowData[2] = Convert.ToString(fut.Position.EnterPrice);
            rowData[3] = Convert.ToString(fut.Position.Quantity);

            foreach (double futData in dataRender.GetRenderDataFromFutures(fut))
            {
                rowData[indexCount++] = Convert.ToString(futData);
            }

            return(rowData);
        }
Example #16
0
        public GoblinBat()
        {
            InitializeComponent();

            dr = Choose.Show("Please Select the Button You Want to Proceed.", "Choose", "Invest", "BackTest", "Exit");

            if (dr == DialogResult.Yes)
            {
                api = Futures.Get();

                new Statistics();
                new Temporary();

                timer.Start();
                api.SetAPI(axAPI);
                api.StartProgress();
                api.SendExit += OnReceiveExit;
            }
            else if (dr == DialogResult.No)
            {
                axAPI.Dispose();
                timer.Dispose();

                int i, l = 100;

                for (i = 11; i < l; i++)
                {
                    new Statistics(i);
                }

                new Storage();

                Box.Show("Complete...!!", "Notice", 3750);

                Dispose();

                Environment.Exit(0);
            }
            else
            {
                Dispose();

                Environment.Exit(0);
            }
        }
Example #17
0
        public IEnumerator GetEnumerator()
        {
            string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*.csv", SearchOption.AllDirectories), arr;

            foreach (string file in Array.FindAll(files, o => o.Contains("TickChart")))
            {
                list = ReadCSV(file, new List <string>(2097152));

                foreach (string val in list)
                {
                    yield return(val);
                }

                arr = list.Last().Split(',');

                Futures.Get().Retention = arr[0];
            }
        }
Example #18
0
        private string[] CreateActualPosTableDataRowFromFut(Futures fut)
        {
            string[] rowData    = new string[10];
            int      indexCount = 4;

            rowData[0] = "F";
            rowData[1] = "0";
            rowData[2] = Convert.ToString(fut.Position.EnterPrice);
            rowData[3] = Convert.ToString(fut.Position.Quantity);
            rowData[4] = Convert.ToString(fut.Position.GetMarketPriceToClose(fut.GetTradeBlotter()));
            rowData[5] = Convert.ToString(fut.Position.CalcCurrentPnL(fut.GetTradeBlotter()));
            rowData[6] = Convert.ToString(fut.Position.CalcCurrentPnLInCurrency(fut.GetTradeBlotter(), fut.PriceStep, fut.PriceStepValue));
            rowData[7] = Convert.ToString(0.0);
            rowData[8] = Convert.ToString(0.0);
            rowData[9] = Convert.ToString(dataCollector.GetBasicFutures().MarginRequirement);

            return(rowData);
        }
Example #19
0
        public Revenue(int type)
        {
            this.type   = type;
            b           = new BollingerBands(20, 2);
            ema         = new EMA(5, 60);
            sma         = new double[b.MidPeriod];
            trend_width = new List <double>(32768);
            short_ema   = new List <double>(32768);
            long_ema    = new List <double>(32768);
            shortDay    = new List <double>(512);
            longDay     = new List <double>(512);
            Send       += Analysis;

            foreach (string rd in new Daily(type))
            {
                arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1])));
            }
            foreach (string rd in new Tick(type))
            {
                arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2])));
            }
            Send     -= Analysis;
            arr       = SetSecret(type).Split('^');
            Secret    = int.Parse(arr[0]);
            Tick      = int.Parse(arr[1]);
            api       = Futures.Get();
            api.Send += Analysis;
        }
Example #20
0
        public IAsyncResult BeginProcessRequest(HttpContext context,
                                                AsyncCallback callback, object state)
        {
            string name = context.Request.QueryString["name"];

            if (string.IsNullOrEmpty(name))
            {
                return(Futures.ImmediateFuture(
                           new HttpQueryResponse {
                    Name = string.Empty,
                    Response = string.Empty,
                    StatusCode = HttpStatusCode.NotFound
                }));
            }

            IDictionary <string, string> parameters = GetParameters(context);
            var app = context
                      .Application[Strings.kApplicationKey] as HttpQueryApplication;
            var async_state = new AsyncState(context.GetHashCode(), context);
            IFuture <HttpQueryResponse> result = app.ProcessQuery(name, parameters,
                                                                  callback, async_state);


            // Waits the processing to finish. NOTE that we cannot finish the
            // request synchrnously, because that is no way to tell ASP.NET
            // that the request has been completed. If we do this a null reference
            // exception will be raised when OnAsyncHandlerCompletion runs, because
            // the HttpContext associated with the request is already released.
            HttpQueryResponse response;

            if (result.TryGet(0, TimeUnit.Seconds, out response))
            {
                callback(result);
                return(Futures.ImmediateFuture(0));
            }

            pending_request_[async_state.ID] = name;
            ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle,
                                                   (o, @out) => Timeout(@out, callback, result), null,
                                                   app.Settings.ResponseTimeout, true);
            return(result);
        }
Example #21
0
        public double[] GetRenderDataFromFutures(Futures futures)
        {
            if (futures == null)
            {
                throw new RenderingDerivativesException("instrument is null, can't render it.");
            }

            double[] result = new double[]
            {
                futures.Position.GetMarketPriceToClose(futures.GetTradeBlotter()),
                0.0,
                Math.Round(futures.Position.CalcCurrentPnL(futures.GetTradeBlotter()), 2),
                Math.Round(futures.Position.CalcCurrentPnLInCurrency(futures.GetTradeBlotter(), futures.PriceStep, futures.PriceStepValue), 0),
                futures.Position.Quantity,
                0.0,
                0.0,
                0.0,
            };

            return(result);
        }
Example #22
0
        public override ListenableFuture <Void> SendEdits(long segmentTxId, long firstTxnId
                                                          , int numTxns, byte[] data)
        {
            try
            {
                ReserveQueueSpace(data.Length);
            }
            catch (LoggerTooFarBehindException e)
            {
                return(Futures.ImmediateFailedFuture(e));
            }
            // When this batch is acked, we use its submission time in order
            // to calculate how far we are lagging.
            long submitNanos            = Runtime.NanoTime();
            ListenableFuture <Void> ret = null;

            try
            {
                ret = singleThreadExecutor.Submit(new _Callable_378(this, segmentTxId, firstTxnId
                                                                    , numTxns, data, submitNanos));
            }
            finally
            {
                if (ret == null)
                {
                    // it didn't successfully get submitted,
                    // so adjust the queue size back down.
                    UnreserveQueueSpace(data.Length);
                }
                else
                {
                    // It was submitted to the queue, so adjust the length
                    // once the call completes, regardless of whether it
                    // succeeds or fails.
                    Futures.AddCallback(ret, new _FutureCallback_428(this, data));
                }
            }
            return(ret);
        }
Example #23
0
        public Statistics()
        {
            b           = new BollingerBands(20, 2);
            ema         = new EMA(5, 60);
            sma         = new double[b.MidPeriod];
            trend_width = new List <double>(32768);
            short_ema   = new List <double>(32768);
            long_ema    = new List <double>(32768);
            shortDay    = new List <double>(512);
            longDay     = new List <double>(512);
            Send       += Analysis;

            foreach (string rd in new Daily())
            {
                string[] arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1])));
            }
            foreach (string rd in new Tick())
            {
                string[] arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2])));
            }
            Send     -= Analysis;
            api       = Futures.Get();
            api.Send += Analysis;
        }
Example #24
0
        public Scalping(int type, int se, int le)
        {
            this.type = type;
            ema       = new EMA(se, le);
            short_ema = new List <double>(32768);
            long_ema  = new List <double>(32768);
            Send     += Analysis;

            foreach (string rd in new Daily(type))
            {
                arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1])));
            }
            foreach (string rd in new Tick(type))
            {
                arr = rd.Split(',');

                if (arr[1].Contains("-"))
                {
                    arr[1] = arr[1].Substring(1);
                }

                Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2])));
            }
            Send     -= Analysis;
            arr       = SetSecret(type).Split('^');
            Secret    = int.Parse(arr[0]);
            api       = Futures.Get();
            api.Send += Analysis;
        }
 /// <summary>Start executing and return FileStatuses based on the parameters specified
 ///     </summary>
 /// <returns>fetched file statuses</returns>
 /// <exception cref="System.Exception"/>
 /// <exception cref="System.IO.IOException"/>
 public virtual IEnumerable <FileStatus> GetFileStatuses()
 {
     // Increment to make sure a race between the first thread completing and the
     // rest being scheduled does not lead to a termination.
     runningTasks.IncrementAndGet();
     foreach (Path p in inputDirs)
     {
         runningTasks.IncrementAndGet();
         ListenableFuture <LocatedFileStatusFetcher.ProcessInitialInputPathCallable.Result>
         future = exec.Submit(new LocatedFileStatusFetcher.ProcessInitialInputPathCallable
                                  (p, conf, inputFilter));
         Futures.AddCallback(future, processInitialInputPathCallback);
     }
     runningTasks.DecrementAndGet();
     Lock.Lock();
     try
     {
         while (runningTasks.Get() != 0 && unknownError == null)
         {
             condition.Await();
         }
     }
     finally
     {
         Lock.Unlock();
     }
     this.exec.ShutdownNow();
     if (this.unknownError != null)
     {
         if (this.unknownError is Error)
         {
             throw (Error)this.unknownError;
         }
         else
         {
             if (this.unknownError is RuntimeException)
             {
                 throw (RuntimeException)this.unknownError;
             }
             else
             {
                 if (this.unknownError is IOException)
                 {
                     throw (IOException)this.unknownError;
                 }
                 else
                 {
                     if (this.unknownError is Exception)
                     {
                         throw (Exception)this.unknownError;
                     }
                     else
                     {
                         throw new IOException(this.unknownError);
                     }
                 }
             }
         }
     }
     if (this.invalidInputErrors.Count != 0)
     {
         if (this.newApi)
         {
             throw new InvalidInputException(invalidInputErrors);
         }
         else
         {
             throw new InvalidInputException(invalidInputErrors);
         }
     }
     return(Iterables.Concat(resultQueue));
 }
        private void CollectAndSortServerDataByMaps(string topic, string[] data)
        {
            LOGGER.Debug("Starting process of colleting and sorting data. Topic: {0}, data array: {1} ", topic, String.Join(" ", data));
            if (futRecievedDataFlag == false || optRecievedDataFlag == false)
            {
                CheckConnectionFlags();
            }

            //DDE ORDER IS: futures -> options -> pos
            if (topic.Equals(FUTURES_DESK))
            {
                if (GetBasicFutures() == null)
                {
                    LOGGER.Debug("Initializing basic futures.");
                    string   ticker            = data[0];
                    DateTime maturity          = DateTime.Parse(data[1]);
                    double   commission        = Convert.ToDouble(data[2]);
                    double   marginRequirement = Convert.ToDouble(data[3]);
                    double   priceStep         = Convert.ToDouble(data[4]);
                    double   priceStepValue    = Convert.ToDouble(data[5]);


                    TradeBlotter futuresBlotter = new TradeBlotter();
                    futuresBlotter.BidPrice = Convert.ToDouble(data[6]);
                    futuresBlotter.BidSize  = Convert.ToDouble(data[7]);
                    futuresBlotter.AskPrice = Convert.ToDouble(data[8]);
                    futuresBlotter.AskSize  = Convert.ToDouble(data[9]);

                    string baseContract = data[10];

                    basicFutures = new Futures(ticker, maturity, commission, marginRequirement, priceStep,
                                               priceStepValue);
                    basicFutures.BaseContract = baseContract;
                    basicFutures.AssignTradeBlotter(futuresBlotter);
                    basicFutures.MinPriceLimit = Convert.ToDouble(data[11]);
                    basicFutures.MaxPriceLimit = Convert.ToDouble(data[12]);

                    LOGGER.Debug("Initializing completed. Futures instance: {0}", basicFutures);
                }
                else
                {
                    LOGGER.Debug("Updating basic futures.");

                    TradeBlotter futuresBlotter = basicFutures.GetTradeBlotter();
                    futuresBlotter.BidPrice = Convert.ToDouble(data[6]);
                    futuresBlotter.BidSize  = Convert.ToDouble(data[7]);
                    futuresBlotter.AskPrice = Convert.ToDouble(data[8]);
                    futuresBlotter.AskSize  = Convert.ToDouble(data[9]);

                    basicFutures.MinPriceLimit = Convert.ToDouble(data[11]);
                    basicFutures.MaxPriceLimit = Convert.ToDouble(data[12]);

                    LOGGER.Debug("Updating completed.");
                }

                if (OnSpotPriceChanged != null && infoOption != null && futRecievedDataFlag == true)
                {
                    OnSpotPriceChanged(this, new OptionEventArgs(infoOption));
                }
            }
            else if (topic.Equals(OPTIONS_DESK))
            {
                OptionType optionType = (OptionType)Enum.Parse(typeof(OptionType), data[0]);
                double     strike     = Convert.ToDouble(data[1]);
                SortedDictionary <double, Option> suitOptionsMap = GetSuitableOptionsMap(optionType);
                Option tempOption;

                if (suitOptionsMap.ContainsKey(strike))
                {
                    LOGGER.Debug("Initializing option: {0}, {1}", optionType, strike);

                    tempOption = suitOptionsMap[strike];
                    tempOption.MarginRequirementNotCover = Convert.ToDouble(data[2]);
                    tempOption.MarginRequirementCover    = Convert.ToDouble(data[3]);
                    tempOption.MarginRequirementBuyer    = Convert.ToDouble(data[4]);

                    TradeBlotter optionsBlotter = tempOption.GetTradeBlotter();
                    optionsBlotter.BidPrice = Convert.ToDouble(data[10]);
                    optionsBlotter.BidSize  = Convert.ToDouble(data[11]);
                    optionsBlotter.AskPrice = Convert.ToDouble(data[12]);
                    optionsBlotter.AskSize  = Convert.ToDouble(data[13]);

                    LOGGER.Debug("Initializing completed. Option instance: {0}", tempOption);
                }
                else
                {
                    LOGGER.Debug("Updating option: {0}, {1}", optionType, strike);

                    double   marginRequirementCover    = Convert.ToDouble(data[2]);;
                    double   marginRequirementNotCover = Convert.ToDouble(data[3]);;
                    double   marginRequirementBuyer    = Convert.ToDouble(data[4]);;
                    string   ticker         = data[5];
                    double   priceStep      = Convert.ToDouble(data[6]);
                    double   priceStepValue = Convert.ToDouble(data[7]);
                    DateTime expirationDate = DateTime.Parse(data[8]);
                    int      remainingDays  = Convert.ToInt32(data[9]);


                    tempOption = new Option(basicFutures, optionType, strike, marginRequirementCover, marginRequirementNotCover, marginRequirementBuyer,
                                            ticker, priceStep, priceStepValue, expirationDate, remainingDays);

                    TradeBlotter optionsBlotter = new TradeBlotter();
                    optionsBlotter.BidPrice = Convert.ToDouble(data[10]);
                    optionsBlotter.BidSize  = Convert.ToDouble(data[11]);
                    optionsBlotter.AskPrice = Convert.ToDouble(data[12]);
                    optionsBlotter.AskSize  = Convert.ToDouble(data[13]);

                    tempOption.AssignTradeBlotter(optionsBlotter);

                    suitOptionsMap.Add(strike, tempOption);
                    tickerMap.Add(ticker, tempOption);

                    LOGGER.Debug("Updating completed.");
                }


                if (infoOption == null)
                {
                    //just for access to general options field
                    infoOption = suitOptionsMap[strike];
                    LOGGER.Debug("info option created: {0}", infoOption);
                }

                if (OnOptionsDeskChanged != null &&
                    optRecievedDataFlag == true &&
                    tempOption.Strike <= CalculateMaxImportantStrike() &&
                    tempOption.Strike >= CalculateMinImportantStrike())
                {
                    OnOptionsDeskChanged(this, new OptionEventArgs(tempOption));
                }
            }
            else if (topic.Equals(POS_TABLE))
            {
                string             account = data[0]; // ?
                string             ticker  = data[1];
                int                pos     = Convert.ToInt32(data[2]);
                DerivativesClasses cls;

                if (ticker.Equals(basicFutures.Ticker))
                {
                    cls = DerivativesClasses.FUTURES;
                }
                else
                {
                    cls = DerivativesClasses.OPTIONS;
                }

                if (OnActualPosChanged != null)
                {
                    OnActualPosChanged(this, new TerminalPosEventArgs(cls, ticker, pos));
                }
            }
            else
            {
                throw new QuikDdeException("table with a such name wasn't mapped: " + String.Join(" ", TOPICS_AND_ROWS_LENGTH_MAP.Keys));
            }
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Futures obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Example #28
0
 /// <summary>
 /// Computes or retrieves a replacement value corresponding to an
 /// already-cached <paramref name="key"/>.
 /// </summary>
 /// <param name="key">
 /// The non-null key whose value should be loaded.
 /// </param>
 /// <param name="old_value">
 /// The non-null old value corresponding to <see cref="key"/>.
 /// </param>
 /// <returns>The future new value associated with <see cref="key"/>;
 /// must not be or return null(for reference types).</returns>
 /// <remarks>
 /// This method is called when an existing cache entry is refreshed by
 /// <see cref="CacheBuilder{T}.RefreshAfterWrite"/>, or through a call to
 /// cache refresh method.
 /// <para>
 /// This implementation synchronously delegates to <see cref="Load"/>. It
 /// is recommended that it be overridden with an asynchronous
 /// implementation when using
 /// <see cref="CacheBuilder{T}.RefreshAfterWrite"/>.
 /// </para>
 /// </remarks>
 public virtual IFuture <T> Reload(string key, T old_value)
 {
     return(Futures.ImmediateFuture(Load(key)));
 }
Example #29
0
 public static string GetCommandString(Futures security, TimeFrame timeFrame)
 {
     return("SPBFUT" + ';' + security.ToString() + ';' + (int)timeFrame + ';' + 0);
 }
Example #30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void awaitEnd(Iterable<java.util.concurrent.Future<?>> completions) throws InterruptedException, java.util.concurrent.TimeoutException, java.util.concurrent.ExecutionException
        public virtual void AwaitEnd <T1>(IEnumerable <T1> completions)
        {
            Futures.combine(completions).get(_totalDurationMinutes, MINUTES);
        }