static void Main(string[] args)
        {
            DateTime FinalTime;
            string   DateFormat    = "dd-MM-yyyy";
            var      DateString    = Console.ReadLine();
            var      ConvertedTime = DateTime.ParseExact(DateString, DateFormat, new CultureInfo("bg-BG"), DateTimeStyles.None);

            FinalTime = ConvertedTime.AddDays(999);
            Console.WriteLine(FinalTime.ToString("dd-MM-yyyy"));
        }
示例#2
0
        /*
         * Caveat: if order-placing failed, it won't send again
         *
         */
        public async void Run(float curPrice)
        {
            if (EntryPrice > 0)
            {
                string   wd       = DateTime.Now.DayOfWeek.ToString().Substring(0, 3);
                DateTime lmt_time = DateTime.Parse(DateTime.Now.ToLongDateString() + " " +
                                                   FinalTime.AddSeconds(LmtOrderTime * -1).ToShortTimeString());
                DateTime final_time = DateTime.Parse(DateTime.Now.ToLongDateString() + " " +
                                                     FinalTime.ToShortTimeString());
                if (Days.Select(x => x.Name).ToList().Contains(wd))
                {
                    TypeAccessor accessor = BaseOrderTypeAccessor.GetAccessor(OT_pre);
                    double       i        = (DateTime.Now - lmt_time).TotalMinutes;
                    if ((DateTime.Now - lmt_time).TotalMinutes < 5 && lmt_time > pre_sent_dt && lmt_time <= DateTime.Now)
                    {
                        if (ActionType == ActionType.Long)
                        {
                            accessor[OT_pre, "LmtPrice"] = (curPrice - (float)Strategy.Symbol.MinTick * Slippage).ToString();
                            bool r = await Controllers.OrderManager.ProcessSignal(Strategy.Script, Strategy, OrderAction.PreForceExitLong, DateTime.Now, OT_pre, curPrice);

                            if (r)
                            {
                                pre_sent_dt = DateTime.Now;
                            }
                        }
                        if (ActionType == ActionType.Short)
                        {
                            accessor[OT_pre, "LmtPrice"] = (curPrice + (float)Strategy.Symbol.MinTick * Slippage).ToString();
                            bool r = await Controllers.OrderManager.ProcessSignal(Strategy.Script, Strategy, OrderAction.PreForceExitShort, DateTime.Now, OT_pre, curPrice);

                            if (r)
                            {
                                pre_sent_dt = DateTime.Now;
                            }
                        }
                    }

                    if ((DateTime.Now - final_time).TotalMinutes < 5 && final_time > final_sent_dt && final_time <= DateTime.Now)
                    {
                        if (ActionType == ActionType.Long)
                        {
                            bool r = await Controllers.OrderManager.ProcessSignal(Strategy.Script, Strategy, OrderAction.FinalForceExitLong, DateTime.Now, OT_final, curPrice);

                            if (r)
                            {
                                final_sent_dt = DateTime.Now;
                            }
                        }
                        if (ActionType == ActionType.Short)
                        {
                            bool r = await Controllers.OrderManager.ProcessSignal(Strategy.Script, Strategy, OrderAction.FinalForceExitShort, DateTime.Now, OT_final, curPrice);

                            if (r)
                            {
                                final_sent_dt = DateTime.Now;
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        //Main Function for getting data on any coin for the home page.
        public static void GETINFO(string CRYPTO, string customCoin, Label xCv, Label xBTCv, Label xUSDc, Label xUSD24c, Label xUSD7c, Label xUSDp, Label xUSD24p, Label xUSD7p, Label xC, Label xBTC, Label xTimev, GroupBox Number)
        {
            if (PublicCurrencyIndex == 0)       //0 is the index for USD.
            {
                CURRENCY = "USD";
            }
            else if (PublicCurrencyIndex == 1)      //1 is the index for AUD.
            {
                CURRENCY = "AUD";
            }

            if (CRYPTO == "" || customCoin == "")       //If the coin is empty set labels to NO DATA.
            {
                if (PublicCurrencyIndex == 0)
                {
                    xC.Text = "XXX/USD";
                }
                else if (PublicCurrencyIndex == 1)
                {
                    xC.Text = "XXX/AUD";
                }
                xBTC.Text    = "XXX/BTC";
                xCv.Text     = "No Data";
                xBTCv.Text   = "No Data";
                xUSDp.Text   = "No Data";
                xUSD24p.Text = "No Data";
                xUSD7p.Text  = "No Data";
                xUSDc.Text   = "";
                xUSD24c.Text = "";
                xUSD7c.Text  = "";
                Number.Text  = "      " + "XXX";
                xTimev.Text  = "No Data";

                //Reset Label Forcolor to Black.
                xCv.ForeColor     = Color.Black;
                xBTCv.ForeColor   = Color.Black;
                xUSDp.ForeColor   = Color.Black;
                xUSD24p.ForeColor = Color.Black;
                xUSD7p.ForeColor  = Color.Black;
            }
            else
            {
                //Deserialize API into jsonString.


                //Set CoinsDetailed to the new jsonString from above API.
                CoinsDetailed = JsonConvert.DeserializeObject <List <MarketCap> >(EaseMethods.API(@"https://api.coinmarketcap.com/v1/ticker/" + CRYPTO + @"/?convert=" + CURRENCY));

                //Default Labelling based on first data.
                xBTC.Text   = customCoin + "/BTC";
                Number.Text = "";
                Number.Text = "      " + customCoin;

                //Calculating Coin Price Against USD or AUD.
                if (PublicCurrencyIndex == 0)
                {
                    xC.Text = customCoin + "/USD";
                    foreach (var data in CoinsDetailed)             //Coin Against USD
                    {
                        string  price_usd;
                        string  percent;
                        decimal Dpercent = 0;
                        decimal newprice;
                        price_usd = data.price_usd;                   //Set varaible price usd to the value found from the CoinsDetailed data.
                        price_usd = EaseMethods.RemoveExtraText(price_usd);
                        newprice  = Convert.ToDecimal(price_usd);     //Converting to decimal for more accurate financial calculations.
                        if (CRYPTO == "bitcoin")
                        {
                            Crypto.UniversalBTCPrice = Convert.ToDouble(newprice); //Setting Universal BTC Price for Mining Page.
                        }
                        price_usd = string.Format("{0:#,0.00##}", newprice);       //Format the price to include commas and up to 4 decimal points.
                        price_usd = "$" + price_usd;
                        percent   = data.percent_change_1h;
                        CalculateCoinAgainstFiatPercentage(price_usd, percent, Dpercent, xCv);          //Checking if it is increasing or decreasing for the triangle arrow and forecolor.
                        break;
                    }
                }
                else if (PublicCurrencyIndex == 1)
                {
                    xC.Text = customCoin + "/AUD";
                    foreach (var data in CoinsDetailed)             //Coin Against AUD
                    {
                        string  price_aud;
                        string  percent;
                        decimal Dpercent = 0;
                        decimal newprice;
                        price_aud = data.price_aud;                          //Set varaible price usd to the value found from the CoinsDetailed data.
                        price_aud = EaseMethods.RemoveExtraText(price_aud);
                        newprice  = Convert.ToDecimal(price_aud);            //Converting to decimal for more accurate financial calculations.
                        price_aud = string.Format("{0:#,0.00##}", newprice); //Format the price to include commas and up to 4 decimal points.
                        price_aud = "$" + price_aud;
                        percent   = data.percent_change_1h;
                        CalculateCoinAgainstFiatPercentage(price_aud, percent, Dpercent, xCv);      //Checking if it is increasing or decreasing for the triangle arrow and forecolor.
                        break;
                    }
                }
                foreach (var data in CoinsDetailed)         //Calculate Last Updated Time.
                {
                    string Time;
                    string FinalTime;
                    double DTime;
                    Time  = data.last_updated;
                    Time  = EaseMethods.RemoveExtraText(Time);
                    DTime = Convert.ToDouble(Time);
                    DateTime UniversalTime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(DTime);        //Converting UNIX time to DateTime.
                    DateTime LocalTime     = UniversalTime.ToLocalTime();                                   //Converting DateTime to LocatTime.
                    if (TimeZoneNumber == 0)
                    {
                        FinalTime   = UniversalTime.ToString("r");                  //'r' is a format of DateTime display.
                        FinalTime   = FinalTime.Substring(0, FinalTime.Length - 4); //Remove Extra Text Caused by 'r'.
                        xTimev.Text = FinalTime + " UTC";
                    }
                    else if (TimeZoneNumber == 1)
                    {
                        FinalTime   = LocalTime.ToString("r");                      //'r' is a format of DateTime display.
                        FinalTime   = FinalTime.Substring(0, FinalTime.Length - 4); //Remove Extra Text Caused by 'r'.
                        xTimev.Text = FinalTime + " LOCAL";
                    }
                    break;
                }
                foreach (var data in CoinsDetailed)         //Coin Against BTC
                {
                    string  percent_change_1h;
                    decimal Dchange;
                    percent_change_1h = data.percent_change_1h;
                    percent_change_1h = EaseMethods.RemoveExtraText(percent_change_1h);
                    Dchange           = Convert.ToDecimal(percent_change_1h);
                    percent_change_1h = percent_change_1h + "%";
                    if (Dchange > 0)                                                //No Change is seen when BTC is compared against BTC.
                    {
                        if (data.symbol == "BTC")
                        {
                            xBTCv.ForeColor = Color.Black;
                        }
                        else
                        {
                            xBTCv.ForeColor = Color.Green;
                        }
                    }
                    else if (Dchange < 0)
                    {
                        if (data.symbol == "BTC")
                        {
                            xBTCv.ForeColor = Color.Black;
                        }
                        else
                        {
                            xBTCv.ForeColor = Color.Red;
                        }
                    }
                    else if (Dchange == 0)
                    {
                        if (data.symbol == "BTC")
                        {
                            xBTCv.ForeColor = Color.Black;
                        }
                        else
                        {
                            xBTCv.ForeColor = Color.Black;
                        }
                    }
                    string  price_btc;
                    decimal dprice_btc;
                    price_btc  = data.price_btc;
                    price_btc  = EaseMethods.RemoveExtraText(price_btc);
                    dprice_btc = Convert.ToDecimal(price_btc);
                    if (data.symbol == "BTC")
                    {
                        price_btc = String.Format("{0:0.0}", dprice_btc);
                    }
                    else
                    {
                        price_btc = String.Format("{0:0.00000000}", dprice_btc);
                    }
                    price_btc  = price_btc + " BTC";
                    xBTCv.Text = price_btc;
                    break;
                }
                foreach (var data in CoinsDetailed)         //Calculating all things related to percentages for ANY COIN.
                {
                    string  value_changed    = null;
                    string  convertedPercent = null;
                    string  StartingPercent;
                    string  price_usd;
                    decimal Dprice_usd = 0;
                    string  price_aud;
                    decimal Dprice_aud = 0;
                    decimal DChange    = 0;
                    string  price_btc;
                    decimal Dprice_btc = 0;

                    double Dchange = 0;
                    string Data    = null;
                    string StartingPercentP;

                    price_usd = data.price_usd;
                    price_aud = data.price_aud;
                    price_btc = data.price_btc;

                    StartingPercent = data.percent_change_1h;
                    CalculatePercentageValue(value_changed, convertedPercent, StartingPercent, price_usd, Dprice_usd, price_aud, Dprice_aud, price_btc, Dprice_btc, DChange, xUSDc);
                    StartingPercent = data.percent_change_24h;
                    CalculatePercentageValue(value_changed, convertedPercent, StartingPercent, price_usd, Dprice_usd, price_aud, Dprice_aud, price_btc, Dprice_btc, DChange, xUSD24c);
                    StartingPercent = data.percent_change_7d;
                    CalculatePercentageValue(value_changed, convertedPercent, StartingPercent, price_usd, Dprice_usd, price_aud, Dprice_aud, price_btc, Dprice_btc, DChange, xUSD7c);

                    StartingPercentP = data.percent_change_1h;
                    CalculatePercentage(Dchange, Data, StartingPercentP, xUSDp);
                    StartingPercentP = data.percent_change_24h;
                    CalculatePercentage(Dchange, Data, StartingPercentP, xUSD24p);
                    StartingPercentP = data.percent_change_7d;
                    CalculatePercentage(Dchange, Data, StartingPercentP, xUSD7p);
                    break;
                }
            }
        }