Tuesday, 12 December 2017

Vbscript:Find the sum of the digits till the sum reaches to a single digit

Find the sum of the digits till the sum reaches to a single digit


no=1234 'You can give any number you want

While no>0
    modValue=no mod 10
    result=result+modValue
    no=int(no/10)
    If no=0 and result >9 Then
        no=result
        result=0
    End If
Wend
print result

Tuesday, 5 December 2017

With statement in UFT


Below Code Can Be Reduced by using with statement:

 Browser("Sample Page All Page").Page("Sample Page All Page") .WebEdit("username").Set "sumit "
  
 Browser("Sample Page All Page").Page("Sample Page All Page") 

        .WebEdit("City").Set "Mumbai"




REM*************************************************************

With Browser("Sample Page All Page").Page("Sample Page All Page")
  
        .WebEdit("username").Set "sumit "
        .WebEdit("City").Set "Mumbai"

End With

Vbscript: Reading CSV file using ADODB

Option Explicit

Dim adoCSVConnection, adoCSVRecordSet, strPathToTextfile
Dim strCSVFile, k

' Specify path to CSV file.
strPathToTextFile = "c:\Scripts\"

' Specify CSV file name.
strCSVFile = "DomainUsers.csv"

' Open connection to the CSV file.
Set adoCSVConnection = CreateObject("ADODB.Connection")
Set adoCSVRecordSet = CreateObject("ADODB.Recordset")

' Open CSV file with header line.
adoCSVConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & strPathtoTextFile & ";" & _
    "Extended Properties=""text;HDR=NO;FMT=Delimited"""

adoCSVRecordset.Open "SELECT * FROM " & strCSVFile, adoCSVConnection

' Read the CSV file.
Do Until adoCSVRecordset.EOF
    ' Display all fields.
    For k = 0 To adoCSVRecordset.Fields.Count - 1
        Wscript.Echo adoCSVRecordset.Fields(k).Value
    Next
    adoCSVRecordset.MoveNext
Loop

' Clean up.
adoCSVRecordset.Close
adoCSVConnection.Close

UFT: Creation Time and Pop Up






Dim odic
Set odic=CreateObject("Scripting.Dictionary")

Set owt=Browser("Sample Page All Page").Page("Sample Page All Page").WebTable("EmpiId")
intemprc=Browser("Sample Page All Page").Page("Sample Page All Page").WebTable("EmpiId").RowCount
intempcc=Browser("Sample Page All Page").Page("Sample Page All Page").WebTable("EmpiId").ColumnCount(1)

For r = 2 To intemprc Step 1


    If owt.GetCellData(r,6)="Hyderabad" Then
    set objlink=owt.ChildItem(r,7,"Link",0)
  
  
                    If typename(objlink)="TextLink" Then
                  
                    text=r& " Row " &owt.GetCellData(r,2)
                  
                    odic.add text,"not present"
                      
                        objlink.Click
                         Browser("CreationTime:=1").Sync
                       
                           'Browser("CreationTime:=1").Page("title:=.*[A-Za-z0-9].*").highlight
                           Browser("CreationTime:=1").Page("title:=.*Wikipedia").highlight
                         
                           'Wikipedia
                         
                         set x= Browser("CreationTime:=1").Page("title:=.*[A-Za-z0-9].*")
                       
                         'Print isobject(x)'
                         if VerifyWebElement(x,"Hyderabad") then
                       
                         odic.item(text)="Present in pop up page"
                       
                         End if
                       
'                    
                       
                         Browser("CreationTime:=1").Close
                       
                       
                         wait 4
                    
                      End If
                      
    End If
  
  
  
Next


For each y in odic.Keys

print y &" "& odic.item(y)

Next

Function VerifyWebElement(objpage,strwebelement)

Dim owebelement
Set owebelement=Description.Create
owebelement("micclass").Value="WebElement"
owebelement("innertext").Value=strwebelement
owebelement("html tag").Value="h1"


set allwebelement=objpage.Childobjects(owebelement)
For i=0 to allwebelement.Count-1

If trim(allwebelement(i).Getroproperty("innertext"))=trim(strwebelement) Then
 
 VerifyWebElement=True
 Reporter.ReportEvent micPass,"Checkpoint for "&strwebelement," "&strwebelement&" is Present on the webpage"

 
Else

  VerifyWebElement=False

End If
 
Next
End Function


Set odic=nothing




******
3 Row 102 Present in pop up page
4 Row 102 Present in pop up page
5 Row 102 not present

Monday, 4 December 2017

Regular Expression Vbscript 2

Set oreg=New RegExp

str="sumit123raut one tarzan sumit567raut "
oreg.Pattern="sumit\d*raut"
oreg.global=True
oreg.ignorecase=True

msgbox oreg.execute(str).Count

Set oreg=nothing
 
'o/p 2

Saturday, 2 December 2017

Capital Market FAQ



What  is market and Type of market ?
A market is a medium that allows buyers and sellers of a specific good or service to interact in order to facilitate an exchange.
This type of market may either be a physical marketplace where people come together to exchange goods and services in person, as in a bazaar or shopping center, or a virtual market wherein buyers and  sellers do not interact, as in an online market

Image result for stock market buyer seller










Type of market:
Primary Market: Company going Public and introduces stocks in the market.
Ex. Initial Public Offering(IPO)
Secondry Market:
Ex Stocks,Derivatives

Image result for primary market vs secondary market






What is derivative ?
A derivative is a security with a price that is dependent upon or derived from one or more underlying assets.
Image result for derivatives market

Explain Options ?

An options contract is an agreement between two parties to facilitate a potential transaction on the underlying security at a preset price, referred to as the strike price, prior to the expiration date. The two types of contracts are put and call options, which can be purchased to speculate on the direction of stocks or stock indices, or sold to generate income









Type of options ?
1.Call Option 2.Put Option
Image result for options market
What is call and put?
Call Option:Call options give the option to buy at certain price, so the buyer would want the stock to go up.Basically when you are Bullish(expecting price to go up) on some dervivative stock/index then you would buy the Call Option.If underlying security price goes up then value of its call option goes up.

Put Option:A put option is an option contract giving the owner the right, but not the obligation, to sell a specified amount of an underlying security at a specified price within a specified time. This is the opposite of a call option, which gives the holder the right to buy shares.
Basically when you are Bearish(expecting price to go down) on some dervivative stock/index then you would buy the PUT Option.If underlying security price goes up then value of its call option goes up.








What is limit order?
Limit order implies that buyer/seller wishes to buy/sell the security on specified price only.
Ex.If Reliance Industries is currently trending at rs 1000 per share and you wish to buy Reliance Share at Rs 998, you can place limit order at 998.
If the stocks ever touches 998 during that day, your order will get executed. If it does not your order will expire by eod
Similar things are expected for sell side when you have Reliance share and you wish to sell at rs 1002






What is  stop loss order?
A stop loss order is the opposite of a take profit order: It is left to ensure that a transaction does not take place at a price worse than the indicated target. It can be used to sell an existing instrument or to enter into a new transaction.
What is open interest  ?
Open interest is the total number of open or outstanding (not closed or delivered) options and/or futures contracts that exist on a given day, delivered on a particular day.
Open interest is commonly associated with the futures and options markets, where the number of existing contracts changes from day to day – unlike the stock market, where the outstanding shares of a company's stock remain constant once a stock issue is completed. However, the term "open interest" is also sometimes used to refer to the number of buy market orders that exist before the stock market opens.
An increase in open interest is typically interpreted as a bullish signal, while decreasing open interest figures are generally interpreted as a bearish sign.
What is open order ?
An open order is an order to buy or sell a security that remains in effect until it is either canceled by the customer, until it is executed or until it expires. Open orders commonly occur when investors place restrictions on their buy and sell transactions. A lack of liquidity in the market or for a particular security can also cause an order to remain open.











Explain Trade Life Cycle ?
Trade Execution ==>Trade Clearance==>Trade Settlement
Image result for trade life cycle in investment banking

What is margins and it's type?:
Loan provided by Broker to based on some collateral.
Ex. User has Trading account with broker  SherKhan. Balance in is account RS 10000 Broker may provide margins for some stocks based on the amount user has in trading account. So you may be able to buy shares worth 10 times( 10000*10 )because of the margin provided by broker.
What is rrm mode ?
Risk Reduction Mode. When 90% of member’s effective deposit is utilized towards margins, the trading terminal of member is placed in Risk Reduction Mode wherein all new orders are checked for sufficiency of margins



What is Intraday trading ?
Buying/Selling securities in same day. While  buying/Selling user has to explicitly specify  if what kind of trade it is. i.e Intraday(same day sell /purchase) or Delivery
Image result for intraday trading


What is market status and time?
Time varies depending on geographical location
https://www.worldtimezone.com/markets24.php



What is OTM,ATM.ATM.?
ITM: In the money
When user is holding call option of a stock/index at strike price of rs 100 and current market price goes beyond 100 then it can be said in the money.
Basic idea is if user exercises the right to sell/buy option then user would be in profit.
So if strike price of Call Option is rs 100 and currently its trending on rs 108 then it can be called ITM as user would get 108-100=8 as Profit


ATM: At the money Strike price and Current Price is same. In our example we bought it at 100 and its currently trending on 100
OTM:Out of the Money
Option that will not produce profit if exercised. So per our example if strike price for our call option was 100 and if its trending at 90 then it can be termed as OTM




What is buy and sell order
If user wants to purchase/nuy some stock/derivative and he places such order on trading terminal or via broker then it would be called Buy Order.

If user wants to Sell some stock/derivative and he places such order on trading terminal or via broker then it would be called Sell Order.

What is trade?
Buy/Sell of Securities

What is trade price
Price at which Buy/Sell Order got executes


Wht IOC and say order
IOC: Immediate or Cancel. It type of buy/sell order which is executes of the price matches with price quoted by the user
Ex. If user wants to purchase security at RS 1000 and and current market price is 1000 or less  then order will get executed. Else it will get cancelled immediately
What is spread order ?
A spread order is a combination of individual orders (legs) that work together to create a single trading strategy. Spread types include futures spreads, and  combinations of option/option, option/stock and stock/stock on the same or multiple underlyings.


Spring Boot : Exception Handler 14