PnL calculation on R/Quantmod - r

I am very new to R as well as to this community, hope all of you are doing well.
I am trying to make a shortcut calculating PnL for 2-3 stocks; say if I use getQuote() to extract the last traded price. From here, may I ask how do I insert my entry price, so I can get subtract the last traded price with my entry price to get the PnL?
I think I need to insert my entry price somehow, and compare entry price to column 3 on the attached result?
Update:
Right now I have the below codes, if I ask, if I wanna subtract last done price to my entry price, how should I code it out?
Again. Thanks a lot.SOXL
Anyway, many thanks for helping. Any thoughts are well appreciated.
getQuote("SOXL")

Related

PowerBI: Getting count of customer that are

I'm new to PowerBI. Please help me get the total count of recurring customers. I need to put the figure in a CARD.
Please see sample data.
The value that will be displayed on the card must be 3.
Customer R000563113 will not be included in the count since the customer is not on the prior month.
sample data
Thanks
just drag and drop your required column and in the card,

mdx SSAS - how to - change calculation depending on dimensions viewed

i am hoping you can improve the 'love' side of my love-hate relationship with MDX.
so, say i have a cube of sales with dimensions customer, year, month, week, product. i have calculated measure based on certain customer values. that is, the calculation is based on sales for customer X in month Y, and then other customers (same calc, maybe different month, etc), added together. basically, these are 'key' customers that have been identified as leading indicators, and the calculated measure is needed for other comparisons as a measure.
now, when i do analysis by year, month, or customer, all is great. the numbers look good and the calculation is doing what i want it to.
however, when i do analysis by week or product, this calculation presents numbers that, at first, don't look sane. i have researched the math, and I understand why it's showing what it is. not all products sell every month to all customers, or each week, etc.
so, what i would like to do in the case of say, analysis first by month, then by week or product, is show the month value as if there were no further breakout by product (or week), just the same calculation value as if the analysis "stopped" at the month level.
i have researched the mdx function reference and found some ideas, but testing has thus far provided nothing useful, so i'm not even sure i'm conceptualizing the problem correctly. i'm hoping someone can point me to the correct function or syntax, and give me an example as a starting point.
if there is any info missing, let me know and I will be happy to clarify or add to my question.
Danylo was correct. i was looking for an All() (function) when i needed the All member.
here is what worked:
sum(
(
[Time].[Week].[All],
[Product].[Product Number].[All],
[Time].[Month].[All].[Y],
[Customers].[Customers].[All].[X]
),Measures.[Sales]
)
+ ... repeat ....
Thanks for the help!!

Pentaho: Get System info - get previous month

As the title suggest, I would like to get the previous month using the given month from Get System Info. I used Get System Info step to get todays month and year, and from there I would like to get the previous month. This is so it would be dynamic and I can ran this any day and still get the correct filter rather than making a hard coded year and month. Is this possible? If so, how do I do that?
Here is how I did it. This is the overview
Here is the calculator:
And concatenate fields:
There is still a few loop hole on getting the previous month during January. But, that is how I did it.

Infopath 2010 How to get the total of fields with a Time Data Type in a repeating table

Please help... I am noob to Infopath coding and I am having a hard time with finishing a project. I have setup a repeating table where it should count the time spent for each activity. Below is the screenshot
I want to be able to get the total time for the column "Activity Time" and place it on the Footer of the repeating table. I already tried Googling for some answers but can't find one for a Time Data Type.
Thank you in advance.
Infopath cannot add time values into a total like that. You need to convert the time values into numbers, then sum the numbers and convert the result back into a time value.
Step by step instructions are on the InfoPath blog from Microsoft here:
http://blogs.msdn.com/b/infopath/archive/2007/02/21/calculating-elapsed-time-without-code.aspx

SharePoint list column calculation based on the last entry (previous row)

I am trying to add a column to my SharePoint list to caculate the change in tonnage from the last entry.
For example, assume that the last entry was made about two weeks ago (1/15) and I am making new entry today (2/1). How can I add a column that will caculate the difference between the tonnage entered on 1/15 and the tonnage being entered on 2/1?
I understand that this may be difficult to do, but please let me know if there is any possilbity. Or if there is another tool in SharePoint that will help me cacluate the change over time.
Please help.
Thanks.
I can't think of a way to do it with SharePoint Designer. But if you implemented an ItemAdding Event Receiver, you could look up the value of the previous entry, perform the calculation, and store the value in your column.

Resources