Search This Blog

Sunday, March 20, 2022

Gapup GapDown strategy

 #!/usr/bin/env python

# coding: utf-8


# In[ ]:



# below code to get OHLC of HDFCBANK, SBIN, ICICI

import pandas as pd

import yfinance as yf

import numpy as np

import math

from mplfinance.original_flavor import candlestick_ohlc

import matplotlib.dates as mpl_dates

import matplotlib.pyplot as plt



# In[ ]:



# get stock prices using yfinance library

def get_stock_price(symbol,stDate,endDate):

    df = yf.download(symbol, start=stDate,end = endDate, threads= False)

    df['Date'] = pd.to_datetime(df.index)

#     df['Date'] = df['Date'].apply(mpl_dates.date2num)

    df = df.loc[:,['Date', 'Open', 'High', 'Low', 'Close']]

    return df



def identifyGAPUPDOWN(startDate,endDate):


    symbol = 'HDFCBANK.NS'

    df_HDFC = get_stock_price(symbol,startDate,endDate)


    symbol = 'ICICIBANK.NS'

    df_ICICI = get_stock_price(symbol,startDate,endDate)


    symbol = 'SBIN.NS'

    df_SBIN = get_stock_price(symbol,startDate,endDate)


    symbol = 'KOTAKBANK.NS'

    df_KOTAK = get_stock_price(symbol,startDate,endDate)

    strState = ""

    x = 0

    if int(df_KOTAK['Close'][0]) >= int(df_KOTAK['High'][0]):

        strState = 'GAP UP'        

        x = x+1

    

    if int(df_SBIN['Close'][0]) >= int(df_SBIN['High'][0]):

        strState = 'GAP UP'        

        x = x+1

    

    if int(df_HDFC['Close'][0]) >= int(df_HDFC['High'][0]):

        strState = 'GAP UP'        

        x = x+1

    

    if int(df_ICICI['Close'][0]) >= int(df_ICICI['High'][0]):

        strState = 'GAP UP'        

        x = x+1

    

    KOTAK_highClose_PTS = str(int(df_KOTAK['High'][0]) - int(df_KOTAK['Close'][0]))

    SBIN_highClose_PTS = str(int(df_SBIN['High'][0]) - int(df_SBIN['Close'][0]))

    HDFC_highClose_PTS = str(int(df_HDFC['High'][0]) - int(df_HDFC['Close'][0]))

    ICICI_highClose_PTS = str(int(df_ICICI['High'][0]) - int(df_ICICI['Close'][0]))

    

    KOTAK_lowClose_PTS = str(int(df_KOTAK['Close'][0]) - int(df_KOTAK['Low'][0]))

    SBIN_lowClose_PTS = str(int(df_SBIN['Close'][0]) - int(df_SBIN['Low'][0]))

    HDFC_lowClose_PTS = str(int(df_HDFC['Close'][0]) - int(df_HDFC['Low'][0]))

    ICICI_lowClose_PTS = str(int(df_ICICI['Close'][0]) - int(df_ICICI['Low'][0]))

    

    

    

    print('x===='+str(x))

    print('HDFC_highClose:'+HDFC_highClose_PTS+'---ICICI_highClose:'+ICICI_highClose_PTS+'--SBIN_highClose:'+SBIN_highClose_PTS+'--KOTAK_highClose:'+KOTAK_highClose_PTS)


#     y = 1

#     if int(df_KOTAK['Close'][0]) >= int(df_KOTAK['Low'][0]):        

#         strState = 'GAP DOWN'

#         y = y+1

    

#     if int(df_SBIN['Close'][0]) >= int(df_SBIN['Low'][0]):

#         strState = 'GAP DOWN'

#         y = y+1

    

#     if int(df_HDFC['Close'][0]) >= int(df_HDFC['Low'][0]):

#         strState = 'GAP DOWN'        

#         y = y+1

    

#     if int(df_ICICI['Close'][0]) >= int(df_ICICI['Low'][0]):

#         strState = 'GAP DOWN'        

#         y = y+1

    

   

    # HDFC_highClose:7---ICICI_highClose:3--SBIN_highClose:2--KOTAK_highClose:14

    # HDFC_lowClose:12---ICICI_lowClose:7--SBIN_lowClose:3--KOTAK_lowClose:8

                

    print('HDFC_lowClose:'+HDFC_lowClose_PTS+'---ICICI_lowClose:'+ICICI_lowClose_PTS+'--SBIN_lowClose:'+SBIN_lowClose_PTS+'--KOTAK_lowClose:'+KOTAK_lowClose_PTS)

    

    if int(KOTAK_highClose_PTS) <= int(KOTAK_lowClose_PTS) and int(SBIN_highClose_PTS) <= int(SBIN_lowClose_PTS) and int(HDFC_highClose_PTS) <= int(HDFC_lowClose_PTS) and int(ICICI_highClose_PTS) <= int(ICICI_lowClose_PTS):

        strState = 'GAP-UP'

    

    if int(KOTAK_highClose_PTS) >= int(KOTAK_lowClose_PTS) and int(SBIN_highClose_PTS) >= int(SBIN_lowClose_PTS) and int(HDFC_highClose_PTS) >= int(HDFC_lowClose_PTS) and int(ICICI_highClose_PTS) >= int(ICICI_lowClose_PTS):

        strState = 'GAP-DOWN'

        

    if strState == '':


        if int(SBIN_highClose_PTS) <= int(SBIN_lowClose_PTS) and int(HDFC_highClose_PTS) <= int(HDFC_lowClose_PTS) and int(ICICI_highClose_PTS) <= int(ICICI_lowClose_PTS):

            strState = 'GAP-UP'


        if int(SBIN_highClose_PTS) >= int(SBIN_lowClose_PTS) and int(HDFC_highClose_PTS) >= int(HDFC_lowClose_PTS) and int(ICICI_highClose_PTS) >= int(ICICI_lowClose_PTS):

            strState = 'GAP-DOWN'


        

    return 'BANK NIFTY on DATE '+endDate  +' is ---->'+strState



# In[56]:



stock_fut = get_history(symbol="SBIN",start=date(2022,3,16),end=date(2022,3,17),futures=True, expiry_date=date(2022,3,31))

stock_fut



# In[58]:



vix = get_history(symbol="INDIAVIX",start=date(2022,3,15),end=date(2022,3,17), index=True)

vix



# In[51]:



from nsepy import get_history

from datetime import date

data = get_history(symbol="BANKNIFTY", start=date(2022,3,17), end=date(2022,3,18),index=True)

data

# data[['Close']].plot()



# In[ ]:



# high = close -----> GAPUP

# low  = close -----> GAPDOWN


# if today (startDate) is GAP DOWN and HIGH = CLOSE ----> then GAP-DOWN on NEXT DAY)

# if today (startDate) is GAP DOWN and LOW = CLOSE ----> then GAP-UP on NEXT DAY)

# if today (startDate) is FLAT and LOW = CLOSE ----> then GAP - UP on NEXT DAY)

# if today (startDate) is FLAT and HIGH = CLOSE ----> then GAP - DOWN on NEXT DAY)


# if CLOSE is symmetrical pattern to HIGH and LOW and for today if it is GAP-UP,

#                                           then for next day it should also be GAP-UP


# if CLOSE is symmetrical pattern to HIGH and LOW and for today if it is GAP-DOWN,

#                                           then for next day it should also be GAP-DOWN



# In[ ]:



rc = identifyGAPUPDOWN('2022-03-04','2022-03-05')

print(rc)

# please recheck on 01-feb-2022, 05th JAN'22 ,31 DEC '21,



# In[ ]:



calculate high close diff points and low close diff points



# In[ ]:



df_SBIN



# In[ ]:



# df_KOTAK = df_KOTAK.between_time('09:15', '15:25')

# df_KOTAK


Tuesday, May 10, 2016

Test Automation Tool Comparision Matrix

Feature QTP(UFT) Selenium Ranorex Coded UI Test Complete Sahi
Language Support VB Script Java, C#, Ruby, Python, Perl
PHP , Javascript
C#, Vb.Net C#, VB.Net VBScript, C#Script, Jscript,C++Script,DelphiScript TBD
Windows (Non-browser)
based Application support
Yes No Yes Yes Yes TBD
Browser support Google Chrome (uptill ver 23), Internet Explorer , Firefox ( ver 21)  Google Chrome , Internet Explorer , Firefox , Opera , HtmlUnit  Google Chrome , Internet Explorer , Firefox , Safari  IE (For building OR), Google Chrole, Firefox IE,Firefox,Chrome,Safari, Opera TBD
Environment Support Only Windows Windows , Linux , Solaris
OS X , Others (If brower & JVM or
Javascript support exists)
Windows Only Windows Only Windows TBD
Technologies Support a) Web based applications
b) Windows based applications
c) .Net applications
d) Swing Applications
e) SAP
f) Oracle Applications
g) Siebel
h) ActiveX applications
i) Peoplesoft
j) Mainframe terminal emulators
k) Web Services
l) Terminal Emulator
m) Delphi
n) Power Builder
o) Windows Mobile
p) SOAP
TBD
Windows Applications
a) Web based applications
b) Windows based applications
c) .Net applications
d)WPF
e)Qt
f)Java
g) Delphi
h)VB6
i)ActiveX
j)Microsoft Visual Fox Pro
k)Power Builder
l)Microsoft Office GUI
m)Microsoft Access
n)Microsoft Dynamics AX
o)Microsoft Dynamics CRM
p)Microsoft Dynamics NAV
q) AIr
r)Infragistics
s)Dev Express
t)Janus
u)Syncfunction
v)Telrik
w)Skinsoft

Web Applications

1)HTML5
2)Ajax
3)Silverlight
4)Ext Js
5)Adobe Flash/Flex/Air
6)JQuery
7)ASP.Net
8)Google Web Tool Kit
9)YUI Library
10)Java Applets
11)Sencha GXT
12)DHTMLX
13)SweetDevRia
14)MochiKit
15)MooTools
16)Pyjs
17)Rico
Web based applications
Windows Applications
Supported-Windows, Web, Mobile, Flash, .net, Java, PowerBuilder,Delphi,Flex,  Air,WebServices(SOAP)
Not Sure about ERP

TBD
Mobile (Phones & Tablets)
support
Different commercial product i.e.
HP UFT Mobile (formerly known as
MobileCloud for QTP)
Android , iPhone & iPad ,
Blackberry , Headless WebKit
Android , iOS Windows phone, windows phone apps. Android & iOS TBD
Framework Easily integrated with HP Quality Center or HP ALM (separate
commercial products)
Selenium + Eclipse + Maven / ANT
+ Jenkins / Hudson & its plugins /
Cruise Control + TestNG + SVN
Visual Studio +TFS+SVN+Jenkins Easily integrated with MTM. 1.  QAComplete & ALMComplete from SmartBear
2.  QC from HP
TBD
Continuous Integration Possible through Quality Center
/ ALM or Jenkins
Possible through Jenkins / Hudson
/ Cruise Contro
Possible through Jenkins / Hudson
/ Cruise Contro
Possible through Cruise Control Possbile through Jenkins TBD
Object Recognition
/ Storage
Inbuilt Object Repository (storing
Element Id, multiple attributes) along
with weightage that gives flexibility
on deviation acceptance in control
recognition
UI Maps and different object location
strategy such as -XPath Element ID
or attribute DOM
UI Maps and different object location
strategy such as -XPath Element ID
or attribute DOM
UI Maps and identification of objects by unique properties. Also support Xpath based object identification. Built-in Namemapping mechanism  TBD
Image based Tests Easily possible Possible but not easy Easily possible Not possible Possible TBD
Reports Quality Center has in-built awesome
dashboards
Integration with Jenkins can give
good reporting & dashboard
capabilities
Integration with Jenkins can give
good reporting & dashboard
capabilities
MSTest has built in reports. We can also create custom reports. Built-in reports Of TestComplete is informative and detailed reports also generated when integrated wth test management tools QAComplete, ALMComplete and QC TBD
Software Cost License & Annual maintenance
fees
Zero License & Annual maintenance
fees
License License & Annual maintenance
fees
TBD
Coding Experience of
Engineer
Not Much Should be very good along with
technical capabilities of integrating
different pieces of framework
Should be very good along with
technical capabilities of integrating
different pieces of framework
Should be very good at C# and object oriented concepts. Hands on scripting is madatory TBD
Script Creation Time Less High High Medium Medium TBD
Hardware resource (CPU
+ RAM) consumption during
script execution
High Low Low High High TBD
Product Support Dedicate HP support along with
support forums
Open Source Community Dedicate Ranorex support along with
support forums
Microsoft support along with forums. Smartbear support with open forums TBD

Monday, April 25, 2016

Integration of Selenium with TestComplete

Integration of Selenium with TestComplete
Selenium is a free testing tool for web applications. Using the Selenium WebDriver API, you can create web tests in any programming language.
You can include your Selenium WebDriver tests into your TestComplete test project, run them as part of your automated testing process and analyze test results
Preparing TestComplete for Integration With Selenium Tests
»      Before you run your Selenium WebDriver tests in TestComplete, you need to prepare your test computer and TestComplete for Selenium integration. 
»      The CPI Cards Automation framework must be installed and configured on your computer and have Selenium WebDriver modules installed and configured.
»       To use Maven to run Selenium tests created by using TestNG, you must have Maven modules installed and configured on your computer.
»      The PATH environment variable on your computer must specify the path to Maven modules.
»      The JAVA_HOME environment variable must specify the path to your Java Developer Kit software location.
»      For more information on how to install and configure Maven, see the Maven documentation.
»      If your Selenium tests use a specific web browser driver, that driver modules must be installed and configured on your computer.

Steps to Integrate Selenium Tests created using TestNG to TestComplete
1.       Create a New Project suite with a valid name

2.       Create a new Project folder under the newly created Project suite with a valid name

3.       Right Click on Project folder and mouse over on Add menu item and select New Item

4.       In the Create Project Item window, select Selenium or Unit Testing as the Item type and provide a valid name

5.       Right click on newly created Item and mouse over on Add menu item and select Nes              s

6.       In the create Project Item window, select TESTNG as the Item type as the current CPI cards Selenium scripts are built using Java with TESTNG and provide a valid name

7.       Select the newly created Project Item(TESTNG) and a new tab is opened in the Workspace requesting for Maven Project and Classpath details

8.       Download latest Maven file from maven.apache.org and click on mvn windows command file located in bin folder under maven x.x.x folder

9.       Since the Project is built on Maven, select the option Use Maven Project and provide the valid path of the project created say …\…\pom.xml

10.    Select the option Run all tests in the opened tab and save it

11.    Ensure Java is installed on the machine and configured in Environment variables with JAVA_HOME as Environment variable name

12.    Click on Tools menu and select Options menu Item

13.   On selection, Options window is opened. Select Engines folder and select Selenium Item which is located under it and provide the java.exe path

14.   Now right click on TESTNG Item located under Selenium unit Tests and select Run

15.    Now TestComplete engine compiles, builds and starts executing the Maven project

16.    Once on execution  find the execution results in results folder located under Selenium Framework as TestComplete only provides details about maven build success



Mobile Tool Comparision Matrix

Mobile Tool Comparision Matrix
Criteria SeeTest Jamo Solutions UFT+PerfectoMobile Eggplant Appium Selenium WebDriver Ranorex Xcode UIA
Native Object Recognition Yes Yes Yes No Yes No Yes Yes
Image Based Recognition Yes No Yes Yes No No No No
OCR Text Based Recognition Yes No Yes Yes No No No No
Web Object Recognition Yes No Yes No Yes Yes No Yes (Simulator)
Object Spy Yes Yes Yes Yes Yes No No Yes (Simulator)
Browser Support                
    Safari Browser Yes Yes Yes Yes (Limited) Yes Yes No Yes
    Firefox Browser Yes Yes   Yes (Limited) No No No No
    Chrome Browser Yes Yes   Yes (Limited) No No No No
    Android Browser Yes Yes Yes Yes (Limited) Yes Yes No No
    Opera Browser Yes Yes   Yes (Limited) No No No No
    Internet Explorer Browser Yes Yes Yes Yes (Limited) No No No No
Hybrid Application Support Yes Yes Yes Yes (Limited) Yes No No No
Record and Playback capability Yes Yes Yes Yes No No Yes Yes (Limited)
Device OS Support                
   Android <4 .1="" td=""> Yes Yes Yes Yes No Yes Yes No
Android >=4.1 Yes Yes Yes Yes Yes Yes Yes No
iOS <7 .0="" td=""> Yes Yes Yes Yes Yes Yes Yes (Limited) Yes
iOS 7.0 Yes (Limited) Yes Yes (Limited) Yes Yes (Limited) Yes Yes Yes
Windows 6.5 Yes Yes Yes Yes No No No No
Windows 7.0 Yes Yes Yes Yes No No No No
Windows 8.0 Yes Yes Yes Yes No No No No
Symbian Yes No Yes Yes No No No No
Blackberry RIM Yes Yes Yes Yes No No No No
Orientation Support Yes Yes Yes Yes Yes No Yes Yes
Hardware Control support Yes (Limited) Yes (Limited) Yes (Limited) No Yes (Limited) No No Yes
Gesture support(Swipe, Pinch, Scroll) Yes (Limited) Yes (Limited) Yes (Limited) No Yes (Limited) Yes (Limited) Yes Yes
Cloud Based Solution Yes No Yes No Yes** Yes** No No
Interrupt Testing Yes Yes Limited No No No No Yes
Multi Language Support Yes Yes No No Yes Yes Yes (Limited) No
Functional Tool Integration Support Yes Yes Yes (Limited) No Yes (Limited) No Yes (Limited) No
App Instrumentation requirement No No No No No No Yes Yes
Capture Device Monitors Yes (Limited) Yes No No No No No Yes
Access to Device Logs Yes (Limited) Yes (Limited) No No No No No Yes
Support to PC OS                
Windows XP and above Yes Yes Yes Yes Yes Yes Yes No
Mac OSX No Yes No No Yes Yes No Yes
Linux No Yes No No Yes Yes No Yes
Parallel Execution on Multiple Devices Yes* No No No Yes Yes Yes Yes
Remote Device Execution Yes* Yes Yes No Yes Yes No No
Real Device Execution Yes Yes No Yes Yes Yes Yes Yes
Support for CI Yes No No No No Yes Yes No

Total Score - Yes 
36 31 26 23 21 17 15 18
Legend
Yes* - Additional Licence Cost
Yes** - External Vendors Service
Yes (Limited) - Limited Support