Sign inSign up

pkjmesra/fbprophet_debian_gnu_linux

By pkjmesra

Updated about 5 years ago

dbprophet 0.7.1 on Debian GNU Linux

Image
0

1.9K

pkjmesra/fbprophet_debian_gnu_linux repository overview

nseta :nerd_face:

Build Status CI/CD Ubuntu macOS Windows License: MIT Downloads Python PyPI Codacy Badge Codacy Badge Total alerts Language grade: Python codecov Test Coverage Requirements Status Linter: Prospector Maintainability Donate PayPal

Python Library (and console/CLI application) to

  • Get publicly available data from NSE India website NSE India ie. stock live-quotes and historical data[ EQUITY ONLY AT THIS TIME. No support for Futures/Options/Derivatives yet.]
  • Plot various technical indicators
  • Pattern recognition and fitment using candlestick charts
  • Backtest trading strategies
  • Scan for test trading strategies for all stocks in one go that will tell you how much you'd have made following a strategy
  • Forecasting with standard as well as custom strategies
  • Get price action, PE-historical data and live-quotes for stocks
  • Create scanners and generate signals for various technical indicators or for BUY/SELL
    • Scan for live, swing, intraday and volume trading strategies
    • Scan for all stocks for which RSI shows oversold/overbought condition or define your own cut-offs in config.txt
    • Scan for all stocks that show high volume growth from yesterday or 7-day average volume
    • Get notified on-console when a stock has crossed a critical support/resistance level
    • Scan based on bbands or any other technical indicator based filter criteria
    • Keep the scans running in the background for the entire duration of market hours
    • Get custom top-picks recommendations for stocks for intraday trades based on 1-min and 5-min MACD alignment
  • Create and build your own trading strategy
  • Scan for latest news/headlines related to stocks

Disclaimer

  • The recommendations that you receive when you run the scan for intraday or swing trading is only for academic research purposes.
  • Though, you are free to take the recommended BUY/SELL positions, any loss you make from those are entirely at your own risk.
  • The author of this library/console cannot be held responsible and is deemed free from any legal liability.

Donate

It takes a lot of time/effort to develop, implement, test and maintain the codebase. When possible, please donate and buy me a coffee :-) Otechie Donate PayPal

Tech Disclaimer

This has been built and tested only on macOS Big Sur (v11+). You may wish to check the .travis.yml or the python-publish.yml file to understand how to build from source. If you test it on a platform other than macOS and find issues, please do report those in the issues tab above.

Libraries Required

  • You need to install TA-LIB, fastquant and fbprophet aside from other libraries noted in requirements.txt. TA-LIB will need to be installed not just as a python package but separately as a library as well. See https://github.com/mrjbq7/ta-lib

  • (See requirements.txt file for more)

For Windows systems you can install Anaconda, this will cover many dependancies (You'll have to install requests and beautifulsoup additionally though)

Installation

  • From code

    python3 setup.py clean build install
    
  • Python pip

    pip3 install nseta
    
  • Installing specific version

    pip3 install nseta==0.6.202
    

    You can also directly install specific versions from pypi.org:

    pip install --index-url https://pypi.org/simple/ --extra-index-url https://pypi.org/simple nseta==<Specific_Version>
    
  • Python shell

    python3 -m pip install --upgrade nseta
    
  • Wheel (.whl) file from PyPi.org

    Just go ahead and download the .whl file from https://pypi.org/project/nseta/#files and install from the downloaded directory:

    pip3 install ./nseta-0.6.202-py3-none-any.whl
    

    where 0.6.202 is the version of the library.

  • Specific test versions(under development) can be installed from test.pypi.org

    pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple nseta==<Specific_Version>
    

After installation you can check what version you got installed

python3 -c "import nseta; print(nseta.__version__)"
  • Docker

    docker run -it pkjmesra/nseta:latest sh
    

    When in doubt or when you encounter an error on Windows/macOS or Ubuntu/Linux, please see the github workflows under Github actions. If you follow those steps, you won't have any trouble installing all dependencies without fail.

Usage

  • Top level command options that provide you with various features

    
    #Usage Commands (You can use nsetacli or nseta - either is good.)
    $ $ nseta
    Usage: nseta [OPTIONS] COMMAND [ARGS]...
    
    Options:
      --debug / --no-debug  --debug to turn debugging on. Default is off
      --version             Shows the version of this library
      --trace / --no-trace  --trace to turn tracing on (works only with --debug).
                            Default is off.
      -f, --filter TEXT     --filter <TEXT> to show only logs that match the
                            filter text. Works only with --debug
      --help                Show this message and exit.
    
    Commands:
      clear                  Force clears log files, downloaded contents etc.
      create-cdl-model       Create candlestick model.Plot uncovered patterns
      forecast-strategy      Forecast & measure performance of a trading model
      history                Get price history of a security for given dates
      live-quote             Get live price quote of a security
      news                   Scans for news for the given tickers or all
                             tickers from stocks.txt
      pe-history             Get PE history of a security for given dates
      plot-ta                Plot various technical analysis indicators
      scan                   Scan live and intraday for prices and signals.
      scan-trading-strategy  Test/Measure the performance of your trading...
      test-trading-strategy  Measure the performance of your trading strategy
      top-picks              Scans for price action and signals for intraday or swing trading recommendations.
    
  • Sample commands

    
      Example:
      nseta clear -d
      nseta create-cdl-model -S bandhanbnk -s 2019-07-30 -e 2020-11-20
      nseta forecast-strategy -S bandhanbnk -s 2019-07-30 -e 2020-11-20 --strategy rsi -c
      nseta history -S bandhanbnk -s 2019-07-30 -e 2020-11-20
      nseta live-quote -S bandhanbnk -gowvb
      nseta news
      nseta news -S HDFCBANK,BANDHANBNK
      nseta pe-history -S bandhanbnk -s 2019-07-30 -e 2020-11-20
      nseta plot-ta -S bandhanbnk -s 2019-07-30 -e 2020-11-20
      nseta scan -S HDFC,ABB -s -c -a 
      nseta scan -i -c
      nseta scan -l -c
      nseta scan -s -c -a
      nseta scan -v -c -a
      nseta scan-trading-strategy -S bandhanbnk -s 2019-07-30 -e 2020-11-20 --strategy rsi -c
      nseta scan-trading-strategy -s 2019-07-30 -e 2020-11-20 --strategy rsi -c
      nseta scan-trading-strategy -s 2019-07-30 -e 2020-11-20 -c
      nseta scan-trading-strategy -i -c
      nseta test-trading-strategy -S bandhanbnk -s 2019-07-30 -e 2020-11-20 --strategy rsi -c
      nseta top-picks -i -c
      nseta top-picks -s -c
      nseta top-picks -S HDFCBANK,BANDHANBNK -i -c 
    
  • Test your trading strategies

    nseta test-trading-strategy
    Please provide start and end date in format yyyy-mm-dd
    Usage:  [OPTIONS]
    
      Measure the performance of your trading strategy
    
    Options:
      -S, --symbol TEXT               Security code
      -s, --start TEXT                Start date in yyyy-mm-dd format
      -e, --end TEXT                  End date in yyyy-mm-dd format
      --strategy [rsi|smac|macd|emac|bbands|multi|custom]
                                      rsi, smac, macd, emac, bbands, multi,
                                      custom. Choose one.
      -u, --upper TEXT                Used as upper limit, for example, for RSI.
                                      Only when strategy is "custom", we buy the
                                      security when the predicted next day return
                                      is > +{upper} %
      -l, --lower TEXT                Used as lower limit, for example, for RSI.
                                      Only when strategy is "custom", we sell the
                                      security when the predicted next day return
                                      is < -{lower} %
      --autosearch / --no-autosearch  --auto for allowing to automatically measure
                                      the performance of your trading strategy on
                                      multiple combinations of parameters.
      -i, --intraday                  Test trading strategy for the current
                                      intraday price history (Optional)
      --help                          Show this message and exit.
    
  • Test your trading strategies (for example, using RSI as technical indicator)

    $ nseta test-trading-strategy -S bandhanbnk -s 2020-01-01 -e 2020-10-03 --strategy rsi
    
    Time used (seconds): 0.13728976249694824
    Optimal parameters: {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'commission': 0.0075, 'execution_type': 'close', 'channel': None, 'symbol': None, 'rsi_period': 14, 'rsi_upper': 70, 'rsi_lower': 15}
    Optimal metrics: {'rtot': 0.4850052910757702, 'ravg': 0.00255265942671458, 'rnorm': 0.9026928562651005, 'rnorm100': 90.26928562651005, 'sharperatio': None, 'pnl': 62418.36, 'final_value': 162418.36025}
       rsi_period  rsi_upper  rsi_lower  init_cash    final_value       pnl
    0          14         70         15     100000  162418.360250  62418.36
    1          11         70         15     100000  154007.773625  54007.77
    2           7         70         15     100000   96213.602375  -3786.40
    3          14         70         30     100000   83074.073000 -16925.93
    4          11         70         30     100000   78397.304875 -21602.70
    

  • Check historical data and export to csv file

    $ nseta history -S bandhanbnk -s 2019-01-01 -e 2020-09-30
           Symbol Series        Date  Prev Close    Open   High     Low    Last   Close    VWAP   Volume      Turnover  Trades  Deliverable Volume  %Deliverable
    0  BANDHANBNK     EQ  2019-01-01      550.15  552.50  560.0  544.10  558.00  556.70  552.21   589317  3.254256e+13   16658              175430        0.2977
    1  BANDHANBNK     EQ  2019-01-02      556.70  553.00  563.7  549.60  551.40  552.15  556.91   834846  4.649319e+13   32119              250782        0.3004
    2  BANDHANBNK     EQ  2019-01-03      552.15  551.00  554.0  530.00  532.05  533.80  540.61   620161  3.352631e+13   18616              282037        0.4548
    3  BANDHANBNK     EQ  2019-01-04      533.80  534.25  541.7  527.05  528.05  528.90  533.42   579027  3.088645e+13   22405              186702        0.3224
    4  BANDHANBNK     EQ  2019-01-07      528.90  540.00  542.0  495.55  495.55  498.05  509.49  2684675  1.367813e+14   76816             1160901        0.4324
    Saved to: bandhanbnk.csv
    
  • Create candlestick model

    nseta create-cdl-model
    Usage:  [OPTIONS]
    
      Create candlestick model.Plot uncovered patterns
    
    Options:
      -S, --symbol TEXT       Security code
      -s, --start TEXT        Start date in yyyy-mm-dd format
      -e, --end TEXT          End date in yyyy-mm-dd format
      -o, --file TEXT         Output file name. Default is {symbol}.csv
      --steps / --no-steps    --steps for saving intermediate steps in output file
      -f, --format [csv|pkl]  Output format, pkl - to save as Pickel and csv - to
                              save as csv
      --help                  Show this message and exit.
    
  • Create candlestick models with pattern recognition

    $ nseta create-cdl-model -S bandhanbnk -s 2019-01-01 -e 2020-09-30 --steps
                    Symbol Series  Prev Close    Open   High  ...  CDLUNIQUE3RIVER  CDLUPSIDEGAP2CROWS  CDLXSIDEGAP3METHODS  candlestick_pattern  candlestick_match_count
    Date                                                      ...                                                                                                        
    2019-01-01  BANDHANBNK     EQ      550.15  552.50  560.0  ...                0                   0                    0           CDLHARAMI_Bull                      0.0
    2019-01-02  BANDHANBNK     EQ      556.70  553.00  563.7  ...                0                   0                    0           CDLHARAMI_Bull                      0.0
    2019-01-03  BANDHANBNK     EQ      552.15  551.00  554.0  ...                0                   0                    0           CDLMATCHINGLOW_Bull                      0.0
    2019-01-04  BANDHANBNK     EQ      533.80  534.25  541.7  ...                0                   0                    0           CDLBELTHOLD_Bull                      0.0
    2019-01-07  BANDHANBNK     EQ      528.90  540.00  542.0  ...                0                   0                    0           CDLTHRUSTING_Bear                      0.0
    
    [5 rows x 72 columns]
    Model saved to: bandhanbnk.csv
    Candlestick pattern model plot saved to: bandhanbnk_candles.html
    

  • Create various plots for analysis with technical indicators

    $ nseta plot-ta -S bandhanbnk -s 2019-01-01 -e 2020-09-30
    

  • Forecast strategies

    nseta forecast-strategy
    Usage:  [OPTIONS]
    
      Forecast & measure performance of a trading model
    
    Options:
      -S, --symbol TEXT               Security code
      -s, --start TEXT                Start date in yyyy-mm-dd format
      -e, --end TEXT                  End date in yyyy-mm-dd format
      --strategy [rsi|smac|macd|emac|bbands|multi|custom]
                                      rsi, smac, macd, emac, bbands, multi,
                                      custom. Choose one.
      -u, --upper FLOAT               Only when strategy is "custom". We buy the
                                      security when the predicted next day return
                                      is > +{upper} %
      -l, --lower FLOAT               Only when strategy is "custom". We sell the
                                      security when the predicted next day return
                                      is < -{lower} %
      --help                          Show this message and exit.
    
  • Create forecast strategies and verify them

    $ nseta forecast-strategy -S bandhanbnk -s 2019-01-01 -e 2020-09-30 --upper 1.5 --lower 1.5
       init_cash   final_value       pnl
    0     100000  137220.87825  37220.88
    

  • Get live quotes for a security

nseta live-quote
Please provide security/index code
Usage:  [OPTIONS]

  Get live price quote of a security along with other (Optional) parameters

Options:
  -S, --symbol TEXT  Security code
  --series TEXT      Default series - EQ (Equity) (Optional)
  -g, --general      Get the general (Name, ISIN) details also (Optional)
  -o, --ohlc         Get the OHLC values also (Optional)
  -w, --wk52         Get the 52 week high/low values also (Optional)
  -v, --volume       Get the traded volume details also (Optional)
  -b, --orderbook    Get the current bid/offer details also (Optional)
  -p, --plot         Plot the "Close" values (Optional)
  -r, --background   Keep running the process in the background (Optional)
  --help             Show this message and exit.
  • Get live quotes with multiple options along with intraday history
nseta live-quote -S bandhanbnk -gowvb
------------------------------------------
                                           
Name                |  Bandhan Bank Limited
ISIN                |          INE545U01014
Last Updated        |  29-DEC-2020 16:00:00
Prev Close          |                406.15
Last Trade Price    |                413.50
Change              |                  7.35
% Change            |                  1.81
Avg. Price          |                414.43
Upper Band          |                437.95
Lower Band          |                358.35
Open                |                408.00
High                |                419.25
Low                 |                407.45
Close               |                413.20
52 Wk High          |                526.00
52 Wk Low           |                152.20
Quantity Traded     |             82,37,480
Total Traded Volume |             82,37,480
Total Traded Value  |             34,138.59
Delivery Volume     |             17,43,202
% Delivery          |                 21.16


             Bid Price Offer Quantity Offer Price
Bid Quantity                                     
2,981           302.80            472      302.90
200             302.70          1,739      302.95
391             302.65         13,936      303.00
4,368           302.60          3,471      303.05
5,469           302.55            767      303.10
  • Scan live quotes of securities

    nseta scan -S HDFC,ABB
                  Updated Symbol     Close       LTP
     30-DEC-2020 16:00:00   HDFC  2,518.95  2,521.70
     30-DEC-2020 16:00:00    ABB  1,203.05  1,205.30
    
  • Scan live quotes of a bunch of securities listed in a resource file(stocks.txt under scanner folder)

    nseta scan -l
     All Stocks LTP and Signals:
                  Updated      Symbol      Close        LTP  % Delivery  Buy - Sell TotalTradedVolume
     13-JAN-2021 15:30:02        ATUL   6,597.90   6,640.95       86.12     -7069.0          1,27,120
     13-JAN-2021 15:30:02   TEAMLEASE   2,774.05   2,822.00       74.94     -3491.0            39,713
     13-JAN-2021 15:30:02     MPHASIS   1,657.35   1,655.00       72.53     -8819.0          5,04,007
     13-JAN-2021 15:30:02   KOTAKBANK   1,903.45   1,880.00       71.40    -14945.0         55,82,559
     13-JAN-2021 15:30:02         FCL      64.50      62.10       71.16   -168378.0          5,86,217
     13-JAN-2021 15:30:02         FSL      99.05      97.65       67.68   -391015.0         23,45,958
     13-JAN-2021 15:30:02         MCX   1,686.50   1,696.00       66.67    -20385.0          1,90,965
     13-JAN-2021 15:30:02       GLAND   2,248.35   2,204.00       60.96     -8184.0          3,41,991
     13-JAN-2021 15:30:02         ABB   1,269.30   1,276.00       60.61     -3306.0          1,59,568
     13-JAN-2021 15:30:02      INDOCO     318.00     310.00       59.76     -6597.0          1,68,736
     13-JAN-2021 15:30:02    EVEREADY     207.10     204.45       59.62   -152053.0          2,70,159
     13-JAN-2021 15:30:02        HDFC   2,747.55   2,672.00       58.71    -19654.0         55,80,886
     13-JAN-2021 15:30:02    SYMPHONY   1,065.15   1,051.00       55.44     -8900.0            49,398
     13-JAN-2021 15:30:02  CASTROLIND     128.05     129.50       55.26   -388442.0         18,29,577
     13-JAN-2021 15:30:02         TCS   3,174.85   3,158.00       55.03     -8764.0         35,72,287
     13-JAN-2021 15:30:02  WOCKPHARMA     509.45     495.30       54.25    -47592.0          6,20,728
     13-JAN-2021 15:30:02   POWERGRID     203.70     205.00       54.17   -190444.0       1,33,82,757
     13-JAN-2021 15:30:02          LT   1,349.80   1,350.00       53.85   -282955.0         43,89,199
     13-JAN-2021 15:30:02        IDBI      32.15      31.40       53.66  -2591283.0       1,39,30,466
     13-JAN-2021 15:30:02  KAJARIACER     741.40     747.00       53.62    -14266.0          2,64,187
     13-JAN-2021 15:30:02    CROMPTON     403.30     397.25       53.12    -10720.0         11,89,119
     13-JAN-2021 15:30:02      RADICO     507.05     507.00       52.91    -86642.0          4,33,139
     13-JAN-2021 15:30:02  CHAMBLFERT     232.60     231.35       52.80   -105721.0          6,29,960
     13-JAN-2021 15:30:02   GODREJIND     434.55     434.00       52.45   -101223.0         17,55,353
     13-JAN-2021 15:30:02    GOODYEAR     959.15     955.95       51.76      2937.0            23,649
     13-JAN-2021 15:30:02      BIOCON     471.75     462.65       49.93   -219459.0         34,30,009
     13-JAN-2021 15:30:02      CONCOR     445.60     439.00       49.91   -185639.0         27,45,347
     13-JAN-2021 15:30:02  TORNTPHARM   2,833.50   2,767.95       48.54     -6328.0          3,70,961
     13-JAN-2021 15:30:02   REPCOHOME     270.70     265.00       48.17   -104416.0          6,37,267
     13-JAN-2021 15:30:02    HDFCBANK   1,481.00   1,473.65       48.13   -325155.0         84,65,607
     13-JAN-2021 15:30:02  ASIANPAINT   2,720.55   2,700.00       47.40     -7592.0         28,61,619
     13-JAN-2021 15:30:02      ARVIND      55.85      55.35       47.32   -335123.0         26,59,457
     13-JAN-2021 15:30:02     PRAJIND     130.10     125.55       47.28   -331887.0         16,32,592
     13-JAN-2021 15:30:02       SPARC     195.65     193.25       46.85   -256047.0          5,79,851
     13-JAN-2021 15:30:02    GODREJCP     762.20     770.50       45.95    -58223.0         1,756,953
     13-JAN-2021 15:30:02   BOMDYEING      82.25      80.10       45.72   -674830.0         25,32,984
     13-JAN-2021 15:30:02        INFY   1,371.75   1,388.65       45.01   -145870.0       1,44,41,047
     13-JAN-2021 15:30:02  TATACONSUM     624.30     619.95       44.29   -201096.0         36,59,235
     13-JAN-2021 15:30:02  BANDHANBNK     391.45     375.65       43.43   -664910.0       2,17,29,060
     13-JAN-2021 15:30:02  TORNTPOWER     337.45     330.50       43.35    -77974.0         13,58,268
     13-JAN-2021 15:30:02      FORTIS     171.80     166.90       43.32   -336844.0         50,97,715
     13-JAN-2021 15:30:02       TECHM   1,064.20   1,065.40       43.01    -54750.0         46,70,556
     13-JAN-2021 15:30:02  HINDUNILVR   2,375.90   2,371.00       42.95    -65291.0         17,02,421
     13-JAN-2021 15:30:02       TITAN   1,527.10   1,508.00       42.56      4940.0         35,26,352
     13-JAN-2021 15:30:02        MFSL     719.90     715.00       41.65      2322.0          9,73,158
     13-JAN-2021 15:30:02     HCLTECH   1,062.10   1,057.00  
    

Tag summary

Content type

Image

Digest

Size

664.1 MB

Last updated

about 5 years ago

docker pull pkjmesra/fbprophet_debian_gnu_linux