As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm trying to put together a simple RSS widget (for my wordpress blog) that will show a list of stocks, or markets, and their current prices.
I cant seem to find an API for this data anywhere - can anyone suggest such a thing (perhaps as an RSS feed?)
Yahoo have an (undocumented) Stock Quotes API as part of their Finance API
Basically, http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=ll will return the price for GOOG stock in CVS format
The s parameter is the stock symbol. You can specify multiple by separating them with +
quotes.csv?s=GOOG+YHOO
The f parameter is the data format code, which I found documented from this Python script (which is also how I discovered the API..):
code description
l1 price
c1 change
v volume
a2 avg_daily_volume
x stock_exchange
j1 market_cap
b4 book_value
j4 ebitda
d dividend_per_share
y dividend_yield
e earnings_per_share
k 52_week_high
j 52_week_low
m3 50day_moving_avg
m4 200day_moving_avg
r price_earnings_ratio
r5 price_earnings_growth_ratio
p5 price_sales_ratio
p6 price_book_ratio
s7 short_ratio
They are all documented on this page
The data is returned as a comma separated file, which should be utterly trivial to parse in any language
You can also use Google's Finance API to get Stock Quotes in a slightly round-a-bout way
Basically you create a Google Spreadsheet, and use the GoogleFinance function:
=GoogleFinance("GOOG"; "price")
..then use the Spreadsheet API to access that value
I found this via ["Introducing the Google Finance API"](http://googlified.com/introducing-the-google-finance-api/
), and "How to get a real-time stock quote using Google API" describes this is more detail, including a simple bash shell-script to access the data (I think it could be simplified by making the spreadsheet publicly accessible)
There are already a few Wordpress plugins; among others:
http://wordpress.org/extend/plugins/stock-quote-sidebar/
http://andy.hillhome.org/blog/code/stockquotesidebar/
http://wordpress.org/extend/plugins/stocks-watchlist/
Related
I am working with the Chicago-taxi-trips dataset and I want to find the average fare per pick up location S2_ID at level 16 for the given date, based on the pickup
time of the trip
S2_ID
Chicago-taxi-trips dataset
Update:
There is now a native BigQuery function,
S2_CELLIDFROMPOINT(point_geography[, level => cell_level])
https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#s2_cellidfrompoint
Carto provides a set of UDF functions for geospatial projects, including working with S2. See their introduction here:
https://carto.com/blog/spatial-functions-bigquery-uber/
The UDFs are available in a public jslibs project. To compute S2 cellid from a point use code like
SELECT jslibs.s2.ST_S2(
ST_GeogPoint(<longitude>, <latitude>),
<cell_level>);
Note that you might need to replace s2 dataset with a regional version, depending on where you want to run the queries.
That said, it would be great if you could describe the use case for S2 cells in BigQuery? BigQuery team is interested in how these are used and might consider adding native S2 functionality in the future.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm using this code to buy NEO:
if I'll run this code, I'll buy 0.05 NEO with market price,
but I want to buy some amount of Neo with 0.05 BTC.
for example:
if NEO price is 0.01 so I'll buy 5 NEO, if NEO price is 0.025 so I'll buy 2 NEO.
Anyone knows how to do it?
Thanks,
From the context, I see that you're using binance-api-node package.
Unfortunately this package doesn't support the "quote order quantity" (quoteOrderQty defined in the official REST API docs). This parameter would allow you to define the amount in the quote currency (in case of NEO/BTC that would be BTC).
I don't recommend getting the current market price and submitting order afterwards (as the comment to your question and the other answer suggest), because it's not going to be very precise and it's going to bring some unexepected consequences.
If the market price drops (between when Binance generates the market price info as response to your request and when they receive your order), you'd simply buy for higher price than you could have. And if the market prices rises, you'd be buying less of the base currency than you could have.
Instead, I'd recommend calling the POST /api/v3/order endpoint directly and using the quoteOrderQty param. Or using a different NPM package that supports the param, such as ccxt.
Use field quoteOrderQty (denominated in BTC) instead of quantity (denominated in NEO).
https://dev.binance.vision/t/beginners-guide-to-quoteorderqty-market-orders/404
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I need to create a column in SQL Server database. Entries for that column will contain messages from chat. Previously such messages has been stored as comments.
My main quetion is:
What is typical text length for chat message and comment?
By the way:
What would happen if I used varchar(max)? How would it impact database size and performance? Is better to use powers of 2 or powers of 10 (e.g. 128 instead of 100) while considering text lengths?
Using VARCHAR(MAX) has a disadvantage: you can not define an index over this column.
Generally, your application should impose a maximum length for a chat message. How big that limit is depends very much on what the application is used for. But anything more than 1000 byte is probably less a legitimate message but an attempt to disrupt your service.
If your maximum value is a power of 2, or a power of ten or any other value has no influence on the performance as long as the row fits in one (8KB) page.
Short answer - it doesn't matter.
From MSDN:
The storage size is the actual length of the data entered + 2 bytes.
So VARCHAR(10) and VARCHAR(10000) will consume the same amount of data if the values don't exceed 10 characters.
Definitely use N/VARCHAR(MAX), it can grow to be 2GB (if I remember correctly). It will grow as required though, so it is very efficient with regards to space unless you are only storing very small amounts of data.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm not a fan of complex passwords as I have a hard time remembering them. Because of that I like the message of this comic.
However typing the sentence "correct horse battery staple" into this calculator yields "12.41 trillion trillion trillion centuries" as opposed to the comic's "550 years".
How can they differ so much, which one is correct if any and how would I know?
How do I create a strong enough password without making it difficult to remember?
The reason for this difference is basically given on the linked side itself:
IMPORTANT!!! What this calculator is NOT . . .
It is NOT a “Password Strength Meter.”
Since it could be easily confused for one, it is very important for you to understand what it is, and what it isn't:
The #1 most commonly used password is “123456”, and the 4th most common is “Password.” So any password attacker and cracker would try those two passwords immediately. Yet the Search Space Calculator above shows the time to search for those two passwords online (assuming a very fast online rate of 1,000 guesses per second) as 18.52 minutes and 17.33 centuries respectively! If “123456” is the first password that's guessed, that wouldn't take 18.52 minutes. And no password cracker would wait 17.33 centuries before checking to see whether “Password” is the magic phrase.
The caclulator basically only considers brute force attempts, while an actual attack would probably be a dictionary arrack. Since most combinations of letters are not actual words a dictionary attack will try a lot less combinations, thous getting a result much faster
IMPORTANT!!! What this calculator is NOT . . .
It is NOT a “Password Strength Meter.”
The calculator assumes that cracker uses exhaustive search. xkcd assumes that cracker may know (or guess) your method of generating password and needs to check only the passwords which you can choose. xkcd method is far safer.
Not any strong password is 100% safe, few websites can really protect user's password. You'd better not to use only one password everywhere. What you do is to keep the straw on fire away from others.
What I do is:
a unforgettable password: A;
the website asking for a password, "www.example.com", as B;
get C = md5(A) + md5(B), and use the leading 8 characters of C as the password;
write a simple script for this, and of course, you may adjust the algorithm, and do keep the script on cloud.
the browser will save password for us, if it asks you for re-enter the password, you can get it back at once.
The operator '+' is not as strcat. It means:
I get the md5 in low letters, and saying that the '0' values 0, ..., 'a' values 10, ..., 'A' is 36, ..., and as so on.Then calculate the result at every character with their values, discarding the carry, and do "mod(62)".
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
here is two samples with two different approaches to naming variables:
decimal amountDue = 1000;
decimal amountPaid = 800;
vs.
decimal dueAmount = 1000;
decimal paidAmount = 800;
Which one would you usually prefer and why?
You should use which ever one reads better as an english sentence. Such as the amount due to the customer is 1000 dollars. In my opinion #1 is better. Because if you write the customer is due the amount of 1000 dollars, it breaks up the wording of the actual variable.
Whatever is most readable in the given context. I could see this ranging from either of your options to simply "paid" and "due".
For example:
public decimal RemainingAmount( Invoice invoice, int quantity, Coupon[] coupons )
{
decimal paid = coupons.Sum( c => c.Value );
decimal due = invoice.Price * quantity;
return due - paid;
}
The first one (amountDue) means typing seven characters before getting useful intellisense. I'd opt for number two.
"Paid" has several attributes: paidAmount, paidDate, paidBy, paidTo, etc.
"Amount" is the data type (essentially currency or BigDecimal or whatever your language uses) and doesn't mean much.
To stir the pot a little (and there's no fun if everyone agrees), I would choose option 1.
it indicates to me they are related
it's the natural way of saying it.
As others said, option #1 is better as naming follows how one would use those concepts in a sentence without sounding weird. However, I think you should also pay attention the business domain that you're modeling to name your variables. A concept may be referred to with a very unique name or terminology in a particular business domain that would not sound right when used in a sentence out of that business domain. If this is the case, then I would go with the terminology that the business domain is using so that the code is expressed in business domain terminology. This helps developers getting familiar with the business domain and also makes communications with clients easier as everyone speaks the same language.
For example, in this particular case, if I notice that the business documents and cliens are using due amount instead of amount due in referring to a payment expected, I would go with due amount.