How to get stock market Index value (NASDAQ,S&P500) in yfinance? - yfinance

I am looking to download historical NASDAQ, S&P500 values similar to how they are pulled for single stocks.
For example, for apple stock price, this works:
apple = yf.Ticker("AAPL")
apple.history(period="Max")
This outputs a dataframe with apple stock price data
However, for stock market index (such as NASDAQ), i get the following error:
ndq=yf.Ticker('^IXIC')
ndq.history(period='Max')
'Index' object has no attribute 'tz_localize'
How can I pull historical index values (NASDAQ, S&P500, DowJones) using their tickets from Yfinance?

Related

How to print stock moves with current stock quantity

In Inventory location in module Inventory. It shows list of products in that location and the quantity of available stock. It is easy to print that out with a report.
However, if I want to show the stock moves related to each product quantity and show it under the total of each number of current stock, how can that be done?
For example:
Formatting
Also, I would want to print the data out in this format. How could it be done?
I have tried linking the stock.moves field to the stock.quant model but I am not sure how to present the data in that format with the current stock level as a summary above all related stock.moves

dax handling summary values in a matrix report

Source data columns are Store, Product, StoreSales, and ProductSales
StoreSales has duplicate values, even across different Stores.
Looking for a dax measure to handle StoreSales as described in the image.
This is the closest so far, but doesn't account for duplicates between stores.
Store Sales:=
sumx(DISTINCT(_Sales[StoreSales), _Sales[StoreSales])
screenshot of source and pivot table
To answer your question directly, this formula should give you the desired result:
Desired Result for Store Sales =
IF(ISFILTERED(_Sales[Store]), SUM(_Store[Store Sales]))
However, I recommend to revisit your data model design. It's conceptually incorrect (you are mixing detailed data with the summary of the same data), and you will have serious problems with DAX. A better way to structure your data:
Remove column "Store Sales". It's redundant and does not fit the data level of detail.
Rename column "Product Sales" into "Sale Amount". It's just sale amount, without any qualifiers.
Create a measure "Total Sales" = SUM(_Sales[Sale Amount]). It will correctly calculate total sales both on product and store levels.
If you need a special measure for store sales, use SUMX:
Store-level sales = SUMX (VALUES(_Sales[Store]), [Total Sales])
And if you need to show product contributions to store sales:
Product Contribution = `DIVIDE([Total Sales], [Store-Level Sales])

Complex "featured product" model using query-time ranking (optional filters)

I have a products index that displays filtered results on category pages.
For a given category, any amount of products may be flagged as featured, meaning it displays first.
When products are displayed for a category, only one featured product should show at a time (at random from the available products flagged as featured)
Additionally, a product should not be flagged as featured if it has date range fields and the current date is not within the range
So, my index might look something like: https://gist.github.com/1a0327d8a321dc6627e197b94f4209c9
A solution to 1. has been posted here: https://stackoverflow.com/a/40922535 using optional filters, currently in private beta: https://www.algolia.com/doc/advanced/optional-filters-scoring/. At query time I could do optionalFacetFilters: ["featuredIn.category:category1"] Update: I've since been told by Algolia reps that this feature is has a large performance cost, and therefor is only really viable for enterprise customers.
However, I'm at a loss as to how to pull of 2. and 3..
Any guidance is greatly appreciated!

OBIEE Merge two queries (join)

I need help.
I am new to obiee (recently moved from business objects and re-creating all reports in obiee).
Here is an example I need help with. I have created an analysis where I am listing all orders with their target delivery dates and number of products in each order.
Order Id......Target Delivery Date...No of products
Abc....1/1/2016.....5
I want to add to a column next to No of products called "No of prods delivered on time". I want to compare delivery date of each product within a order with the target delivery date and
Give count of products delivered within the target date.. So the output should be
Abc....1/1/2016....5.....3
Where 3 is number of products delivered on time.
I could do it in BO by running two queries and merging them however in obiee I am not able to add second query to my analysis. I did try at product level using case when target date >=delivery date then 1 else 0 and wrapped this with sum function to aggregate but it didn't work ..
Appreciate your help in this. Searching for this topics give me results for running queries from multiple subject area :(
You also have unions in OBIEE, you union the results of 2 queries which return the same structure, so you have query A with Order ID, Target Date, No Products and a Dummy column with a 0 and default agregation Sum, and a second query with Order ID, Target Date, Dummy column summing 0 and the number of products delivered.
You do all this in the criteria tab of the analysis. It's important the order in which you put your columns, because that's what OBIEE is using to do the union.
Regards

Google Spreadsheets multiple/scenario filter dropdown

I can create drop down filter options for each of the dimensions in the spreadsheet: month, description, and type. using data validation and then sum(filter in Google Sheets. I want to include an option in the drop-down to include all months, include all types, etc. The end product would sum the amount based on the filters selected. I can sum(filter based on individual selections but my question is how to sum the amounts if one of the scenarios was: all months, groceries only, all descriptions.
https://docs.google.com/spreadsheet/ccc?key=0AgKUNhffHpmZdHZ3TGNXOUplN1R5UUlUSW5tVVp5b1E#gid=0
You'd have to use a Pivot Table. Then you have all this things in one view.
Select colums A to D. Go to Data/Pivot Table.
Add Month to Rows and Description to Colums (or vise versa) and add Amout to Values.
You'll see a total for all Descriptions/month and Grand total/month and /description.

Resources