public pullSnapshotDataResponse pullSnapshotData(pullSnapshotDataRequest request)
        {
            DataManager dataManager           = new DataManager();
            pullSnapshotDataResponse response = null;
            MessageContainer         msg      = dataManager.GetData();

            if (msg != null)
            {
                response = new pullSnapshotDataResponse();
                msg.exchangeInformation.exchangeContext.supplierOrCisRequester.internationalIdentifier.nationalIdentifier = "DEMO";
                msg.exchangeInformation.exchangeContext.supplierOrCisRequester.internationalIdentifier.country            = "SE";
                msg.exchangeInformation.dynamicInformation.messageGenerationTimestamp = DateTime.UtcNow;
                response.pullSnapshotDataOutput = msg;
            }
            else
            {
                #region Return fail message

                response = new pullSnapshotDataResponse();
                response.pullSnapshotDataOutput = new MessageContainer();
                response.pullSnapshotDataOutput.modelBaseVersion = "3";

                ExchangeInformation exchangeInfo    = new ExchangeInformation();
                ExchangeContext     exchangeContext = new ExchangeContext();

                exchangeContext.codedExchangeProtocol = new _ProtocolTypeEnum()
                {
                    Value = ProtocolTypeEnum.snapshotPull
                };
                exchangeContext.exchangeSpecificationVersion = "3";

                Agent agent = new Agent();
                InternationalIdentifier identifier = new InternationalIdentifier {
                    nationalIdentifier = "DEMO", country = "SE"
                };

                agent.internationalIdentifier          = identifier;
                exchangeContext.supplierOrCisRequester = agent;
                exchangeInfo.exchangeContext           = exchangeContext;

                DynamicInformation  dynamicInformation = new DynamicInformation();
                _ExchangeStatusEnum exchangeStatusEnum = new _ExchangeStatusEnum {
                    Value = ExchangeStatusEnum.undefined
                };
                dynamicInformation.messageGenerationTimestamp = DateTime.UtcNow;
                dynamicInformation.exchangeStatus             = exchangeStatusEnum;
                exchangeInfo.dynamicInformation = dynamicInformation;

                dynamicInformation.returnInformation = new ReturnInformation();
                dynamicInformation.returnInformation.returnStatus       = new _ExchangeReturnEnum();
                dynamicInformation.returnInformation.returnStatus.Value = ExchangeReturnEnum.fail;
                #endregion
            }
            return(response);
        }
Beispiel #2
0
        static int Lookup(string szSelectedCoin, decimal hashrate, bool bIncomeInBTC, long interval, string exchange, RegistrySettings rs)
        {
            Profitability       p   = new Profitability();
            CoinInformation     ci  = new CoinInformation();
            ExchangeInformation ei  = new ExchangeInformation();
            CoinInfo            inf = rs.Coins[szSelectedCoin];
            double diff             = 0;

            try { diff = ci.GetDifficulty(inf.ExplorerType, inf.ExplorerBaseURL, inf.ExplorerChain, inf.Abbreviation); }
            catch { Console.WriteLine("Unable to fetch difficulty"); return(-1); }
            decimal reward = 0;

            try { reward = ci.GetReward(inf.ExplorerType, inf.ExplorerBaseURL, inf.ExplorerChain, inf.Abbreviation); }
            catch { Console.WriteLine("Unable to fetch reward"); return(-1); }
            if (hashrate == 0)
            {
                switch (inf.DefaultHashRateUnit)
                {
                case "H/s":
                    hashrate = Convert.ToDecimal(inf.DefaultHashRate);
                    break;

                case "kH/s":
                    hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 1000;
                    break;

                case "MH/s":
                    hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 1000000;
                    break;

                case "GH/s":
                    hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 100000000;
                    break;

                default:
                    throw new ArgumentException("invalid hashrate unit");
                }
            }
            if (!bIncomeInBTC)
            {
                Console.WriteLine(p.ProfitOnInterval(interval, hashrate, reward, (decimal)diff).ToString("F8"));
            }
            else
            {
                decimal exchrate = 0;
                try { exchrate = (szSelectedCoin.ToLower() != "bitcoin") ? ei.GetExchangeRate((exchange != "") ? exchange : inf.Exchange, inf.Abbreviation) : 1; }
                catch { Console.WriteLine("Unable to fetch exchange rate"); return(-1); }
                Console.WriteLine(p.ProfitOnIntervalBTC(interval, hashrate, reward, (decimal)diff, exchrate).ToString("F8"));
            }
            return(0);
        }
Beispiel #3
0
        // load data into form

        private void cbCoinType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExchangeInformation ei = new ExchangeInformation();
            CoinInformation     ci = new CoinInformation();

            lblUpdating.Visible = true;
            this.Refresh();
            string   szCoinType = cbCoinType.Items[cbCoinType.SelectedIndex].ToString();
            CoinInfo i          = rs.Coins[szCoinType];

            lblAbbrev.Text = lblRewardCurrency.Text = i.Abbreviation;
            lblExchangeRateCurrency.Text = "BTC/" + i.Abbreviation;
            try { tbDifficulty.Text = ci.GetDifficulty(i.ExplorerType, i.ExplorerBaseURL, i.ExplorerChain, i.Abbreviation).ToString(); }
            catch { tbDifficulty.Text = "Unavailable"; }
            try { tbReward.Text = ci.GetReward(i.ExplorerType, i.ExplorerBaseURL, i.ExplorerChain, i.Abbreviation).ToString(); }
            catch { tbReward.Text = "Unavailable"; }
            for (int c = 0; c < cbHashrateUnit.Items.Count; c++)
            {
                if (((Item)cbHashrateUnit.Items[c]).Name == i.DefaultHashRateUnit)
                {
                    cbHashrateUnit.SelectedIndex = c;
                }
            }
            try
            {
                if (i.Exchange != null)
                {
                    tbExchangeRate.Text = ei.GetExchangeRate(i.Exchange, i.Abbreviation).ToString();
                }
                else
                {
                    tbExchangeRate.Text = "";
                }
            }
            catch { tbExchangeRate.Text = "Unavailable"; }
            if (cbCoinType.Items[cbCoinType.SelectedIndex].ToString().ToLower() == "bitcoin") // case-insensitive for Mono compatibility
            {
                tbExchangeRate.Text = "1";
            }
            tbHashrate.Text     = i.DefaultHashRate;
            lblUpdating.Visible = false;
            this.Refresh();
            OnChanged();
        }
        //##############################################

        #region -Constructor-
        public FactoryCharts(ExchangeInformation _exchangeInf)
        {
            #region -ЦЕНА ВСЕХ СДЕЛОК-
            // I
            childrenPanel          = new List <TapeTradesDrawing>();
            TapeTradesEveryVolume  = new TapeTradesEveryVolumeDraving();
            TapeTradesSumOperation = new TapeTradesSumOperationDrawing();
            childrenPanel.Add(TapeTradesEveryVolume);
            childrenPanel.Add(TapeTradesSumOperation);
            //---------------------------------------

            // II
            MultiDependetPanelTrades = new MultiDependetPanelTrades(childrenPanel, MainWindow.SizeTapeTradesClobal);
            //---------------------------------------

            // III
            ListMultiDependet = new List <MultiDependetPanelTrades>();
            ListMultiDependet.Add(MultiDependetPanelTrades);

            ListPartiallyDependet = new List <PartiallyDependentPanel>();
            BidPanel   = new PartiallyDependentPanel(new System.Windows.Thickness(40, -20, 0, 0));
            OfferPanel = new PartiallyDependentPanel(new System.Windows.Thickness(40, 0, 0, 0));
            ListPartiallyDependet.Add(BidPanel);
            ListPartiallyDependet.Add(OfferPanel);
            //---------------------------------------

            // IV
            PriceChart = new ChartPanelMain(ListMultiDependet, ListPartiallyDependet, MainWindow.SizePriceChartClobal, ChartTypeEnum.Point);
            //---------------------------------------
            #endregion

            #region - СКОРОСТЬ СДЕЛОК -
            SpeedPriceChart = new ChartPanelMain(MainWindow.SizeSpeedTradesChartClobal, ChartTypeEnum.Gistogramm);
            #endregion

            #region - СКОРОСТЬ ТИКОВ -
            SpeedTickBuyChart = new ChartPanelMain(MainWindow.SizeSpeedTickBuyChartsClobal, ChartTypeEnum.Gistogramm);
            #endregion

            #region -СКОРОСТЬ СДЕЛОК В ТИКE-
            SpeedTradeTickChart = new ChartPanelMain(MainWindow.SizeSpeedTradesChartClobal, ChartTypeEnum.Gistogramm);
            #endregion

            #region - СРЕДНЯЯ СКОРОСТЬ СДЕЛОК ЗА ДЕНЬ -
            SpeedTradesDayAvChart = new DependentYScalePanel(SpeedTradeTickChart);
            #endregion

            #region - СРЕДНЯЯ СКОРОСТЬ СДЕЛОК ЗА ПЕРИОД -
            SpeedTradesPerAvChart = new DependentYScalePanel(SpeedTradeTickChart);
            #endregion

            #region - РЫНОЧНЫЙ ТРЕНД -
            MarketTrendChart        = new ChartYPlusMinusMain(MainWindow.SizeTrendMarketChartsGlobal);
            MarketTrendGisgramChart = new ChartYPlusMinusMain(MainWindow.SizeTrendGistogramChartsGlobal);
            #endregion

            #region - ЦЕНА ПОЗИЦИИ -
            PriceCurrentPosition = new DependentYScalePanel(PriceChart);
            #endregion

            AnalyticalScalperModel.ExchangeInfomationGLOBAL.DataTradesExchengeUpdate  += ExchangeInfomationGLOBAL_DataTradesExchengeUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.DataMarketParametrUpdate  += ExchangeInfomationGLOBAL_DataCurrentParametrUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.SpeedTradesUpdate         += ExchangeInfomationGLOBAL_SpeedTradesUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.SpeedTickBuyUpdate        += ExchangeInfomationGLOBAL_SpeedTickBuyUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.SpeedTradesTickUpdate     += ExchangeInfomationGLOBAL_SpeedTradesTickUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.SpeedTradesAvgDayliUpdate += ExchangeInfomationGLOBAL_SpeedTradesAvgDayliUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.SpeedTradesAvgUpdate      += ExchangeInfomationGLOBAL_SpeedTradesAvgUpdate;
            AnalyticalScalperModel.ExchangeInfomationGLOBAL.Market_TrendUpdate        += ExchangeInfomationGLOBAL_Market_TrendUpdate;
            AnalyticalScalperModel.AccountInformationGLOBAL.PricePositionUpdate       += AccountInformationGGLOBAL_PricePositionUpdate;
        }