Пример #1
0
        public ServiceResult <QuoteBasicBase> Download(string symbol, int interval, int limit = 300)
        {
            var r = ServiceResult <QuoteBasicBase> .CallAsyncFunction(() => _market.Download(symbol, interval, limit)).Result;

            return(r);
            //if (r.Result)
            //    return new ServiceResult<QuoteBasicBase> { Result = true, Data = new QuoteBasicBase(r.Data) };
            //return new ServiceResult<QuoteBasicBase> { Result = false, Data = null };
        }
Пример #2
0
        //public ServiceResult<bool> UpdateLastTimeForOrder(FZOrder order)
        //{
        //    return ServiceResult<bool>.CallAsyncFunction(() => _apiOrder.UpdateLastTimeForOrder(order)).Result;
        //}

        public ServiceResult <long> GetLastTimeForOrder(string orderId, string symbol)
        {
            try
            {
                return(ServiceResult <long> .CallAsyncFunction(() => _apiOrder.GetLastTimeForClosedOrder(orderId, symbol)).Result);
            }
            catch (Exception e)
            {
                return(new ServiceResult <long> {
                    Result = false, Message = e.ToString()
                });
            }
        }
Пример #3
0
 public ServiceResult <FZOrder> CheckOrder(string symbol, string orderId, bool isStopOrder = false)
 {
     try
     {
         //var order = new FZOrder { Exchange = _apiOrder.Exchange, Symbol = symbol, OrderId = orderId };
         return(ServiceResult <FZOrder> .CallAsyncFunction(() => _apiOrder.CheckOrder(symbol, orderId, isStopOrder)).Result);
     }
     catch (Exception e)
     {
         return(new ServiceResult <FZOrder> {
             Result = false, Message = e.ToString()
         });
     }
 }
Пример #4
0
        public ServiceResult <QuoteBasicBase> GetInMemoryQuoteBasic(string symbol, int interval)
        {
            var r = ServiceResult <QuoteBasicBase> .CallAsyncFunction(() => Task.Run(() => _qbStore.GetQuoteBasic(symbol, interval))).Result;

            return(r);
        }
Пример #5
0
        //public void ProcessCandleListQueue()
        //{
        //    lock (this)
        //    {
        //        if (_isProcessCandleListOngoing) return;
        //        _isProcessCandleListOngoing = true;
        //    }

        //    Task.Run(() =>
        //    {
        //        try
        //        {
        //            string symbol;
        //            while (_symbolToUpdate.TryDequeue(out symbol))
        //            {
        //                var d = _candles[symbol];
        //                if (_symbolsInitialized.Contains(symbol))
        //                    _qbStore.AddCandle(d.Symbol, d.Interval, d.Time, d.Open, d.Close, d.High, d.Low, d.Volume, true);
        //                else
        //                {
        //                    if (_isFillGap)
        //                        this.InitQuoteBasic(symbol);
        //                    else
        //                        this.InitQuoteBasic2(symbol);
        //                }
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            OnExceptionOccured?.Invoke(this, Exchange, ex);
        //        }
        //        finally
        //        {
        //            _isProcessCandleListOngoing = false;
        //        }
        //    });
        //}

        //private void ProcessTickerListQueue()
        //{
        //    lock (this)
        //    {
        //        if (_isProcessTickerListOngoing) return;
        //        _isProcessTickerListOngoing = true;
        //    }

        //    try
        //    {
        //        List<Ticker> ticker;
        //        while (_tickerQueue.TryDequeue(out ticker))
        //        {
        //            foreach (var t in ticker)
        //                _tickStore.AddTickers(this.Exchange, t);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        OnExceptionOccured?.Invoke(this, this.Exchange, ex);
        //    }
        //    finally
        //    {
        //        _isProcessTickerListOngoing = false;
        //    }
        //}

        //private void ProcessSaveQuoteBasicQueue()
        //{
        //    lock (this)
        //    {
        //        if (_isSaveQuoteBasicOngoing) return;
        //        _isSaveQuoteBasicOngoing = true;
        //    }

        //    Task.Run(() =>
        //    {
        //        try
        //        {
        //            string quoteId;
        //            while (_quoteIdToSave.TryDequeue(out quoteId))
        //            {
        //                //Console.WriteLine($"saving {quoteId}...");
        //                _fileStore.Save(_qbStore.Quotes[quoteId]);
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            Console.WriteLine(ex.ToString());
        //            OnExceptionOccured?.Invoke(this, this.Exchange, ex);
        //        }
        //        finally
        //        {
        //            _isSaveQuoteBasicOngoing = false;
        //        }
        //    });
        //}

        public ServiceResult <QuoteCapture> GetInMemoryQuoteCapture(string symbol)
        {
            return(ServiceResult <QuoteCapture> .CallAsyncFunction(() => Task.Run(() => (QuoteCapture)_qcStore.GetInMemoryQuoteCapture(symbol))).Result);
        }
Пример #6
0
 public ServiceResult <List <FZOrder> > GetOpenOrdersBySymbol(string instrument_id)
 {
     return(ServiceResult <List <FZOrder> > .CallAsyncFunction(() => _apiOrder.GetOpenOrdersBySymbol(instrument_id)).Result);
 }
Пример #7
0
 public ServiceResult <List <FZOrder> > GetClosedOrdersBySymbol(string instrument_id, bool isReturnAll = false)
 {
     return(ServiceResult <List <FZOrder> > .CallAsyncFunction(() => _apiOrder.GetClosedOrdersBySymbol(instrument_id, isReturnAll)).Result);
 }
Пример #8
0
 public ServiceResult <List <FZOrder> > GetAllOpenOrders()
 {
     return(ServiceResult <List <FZOrder> > .CallAsyncFunction(() => _apiOrder.GetAllOpenOrders()).Result);
 }
Пример #9
0
 public ServiceResult <bool> CancelOrder(string symbol, string orderId, bool isStopOrder)
 {
     return(ServiceResult <bool> .CallAsyncFunction(() => _apiOrder.CancelOrder(symbol, orderId, isStopOrder)).Result);
 }
Пример #10
0
        //public ServiceResult<List<FZOrder>> GetOpenStopOrder(string symbol)
        //{
        //    return ServiceResult<List<FZOrder>>.CallAsyncFunction(() => _apiOrder.GetOpenStopOrder(symbol)).Result;
        //}

        public ServiceResult <string> ModifyOrderPrice(string symbol, string orderId, double newPrice)
        {
            return(ServiceResult <string> .CallAsyncFunction(() => _apiOrder.ModifyOrderPrice(symbol, orderId, newPrice)).Result);
        }
Пример #11
0
 public ServiceResult <FZOrder> PlaceOrder(FZOrder order)
 {
     return(ServiceResult <FZOrder> .CallAsyncFunction(() => _apiOrder.PlaceOrder(order)).Result);
 }
Пример #12
0
 public ServiceResult <Dictionary <string, Ticker> > GetTickers()
 {
     return(ServiceResult <Dictionary <string, Ticker> > .CallAsyncFunction(() => _market.GetTickers()).Result);
 }
Пример #13
0
 public ServiceResult <Ticker> GetTicker(string symbol)
 {
     return(ServiceResult <Ticker> .CallAsyncFunction(() => _market.GetTickerBySymbol(symbol)).Result);
 }
Пример #14
0
 public ServiceResult <Orderbook> GetOrderbook(string symbol)
 {
     return(ServiceResult <Orderbook> .CallAsyncFunction(() => _market.GetOrderbook(symbol)).Result);
 }
Пример #15
0
 public ServiceResult <List <OHLC> > GetOHLC(string symbol, int interval)
 {
     return(ServiceResult <List <OHLC> > .CallAsyncFunction(() => _market.GetOHLC(symbol, interval)).Result);
 }