Click here to Login





                                                   code to get todays date

  0

0
Gilari Decosta
2012-08-17 10:12:26


Sir,
I want ot modify following script ,downloaded from the forum of QS,such that I can APPEND the quote of today to my database.I have managed to do same but
I have to modify date of today manually.
Please give me code to get today's date in th code STRING B = "17/08/2012"

The partially modified version of code is as follow

string path = "F:\\QS-Object\\nse";

Symbol[] symbols = Symbols.GetSymbols();
String b = "01/08/2012"
for(int i=0;i < symbols.Length;i++)
{
Symbol sym = symbols[i];
HistoricalQuotes quotes = Quotes.GetHistoricalQuotes(sym.Name);
System.Text.StringBuilder builder = new System.Text.StringBuilder("");
for(int j=0;j < quotes.Close.Length;j++)
{
if (b = quotes.Date[j].ToString("ddmmyy")
string line = quotes.Date[j].ToString("ddmmyy") + ","+ quotes.Open[j] + "," + quotes.High[j] + "," + quotes.Low[j] + "," + quotes.Close[j] + "," + quotes.Volume[j];
builder.AppendLine(line);
}

System.IO.File.AppendText(path + "\\" + sym.Name + ".txt", builder.ToString());

Thanking You
Gilari



QuantShare
2012-08-17 15:48:21

  0

Hi,

Here is how to get today date:

string b = DateTime.Today.ToString("ddmmyy");

Note however that "ddmmyy" format gives the following date: 170812, not (17/08/2012).



Seeker
2015-03-21 03:05:54

  0

I have tried changing:

DateTime end = new DateTime(2015, 03, 20)

to

DateTime end = new DateTime.Today.ToString("yyyy,MM,dd");

But gives the error System.DateTime.Today' is a 'property' but is used like a 'type'.



QuantShare
2015-03-23 01:47:55

  0

You should not add the "new " in front of "DateTime.Today". "Today" is a static variable. Please check again my previous message.


Seeker
2015-03-23 02:14:22

  0

When I remove the "new", it gives the error: Cannot implicitly convert type 'string' to 'System.DateTime'.


QuantShare
2015-03-23 14:16:54

  0

Please check my first message. It should be:

string b = DateTime.Today.ToString("ddmmyy");

If you want to create a "DateTime" variable, you should remove "ToString"

DateTime end = DateTime.Today;



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
BSE historical data by date
Derivatives: Number of days until the expiration date
Year to Date Change Indicator
Year to Date Excess Return
Days To Next Date

How-to Lessons
How to get stocks for a particular index using the global script
How to get fundamental data for U.S. Stocks
How to get trading orders from a portfolio programmatically
How to run a screen or a watchlist from a script
How to plot the relative performance of several stocks/indices

Related Forum Threads
Get current simulation date
How to read date and get quote of next day.
How do I get the date of the current bar in a custom function?
How to get the last day of the month in C#
Visible Date of first and last bar on chart

Blog Posts
4 Links to Download Free Historical Stock Prices Data by Date
How to use date components in your trading rules
Step by step on how to get free realtime/delayed data for stocks,...
3 Items To Get and Trade the News In QuantShare Platform
How to get buy and sell orders for a portfolio based on a trading...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.