Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Data> Financial Technology> Python Algorithmic Trading Cookbook
Python Algorithmic Trading Cookbook
Python Algorithmic Trading Cookbook

Python Algorithmic Trading Cookbook: All the recipes you need to implement your own algorithmic trading strategies in Python

Arrow left icon
Profile Icon Dagade
Arrow right icon
€8.98€29.99
Full star iconFull star iconFull star iconHalf star iconEmpty star icon3.8(10 Ratings)
eBookAug 2020542 pages1st Edition
eBook
€8.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Python Algorithmic Trading Cookbook

Stock Markets - Primer on Trading

When building algorithmic trading systems, it is essential to have an account open with a modern broker that provides APIs for placing and querying trades programmatically. This allows us to control the broking account, which is conventionally operated manually using the broker's website, using our Python script, which would be part of our larger algorithmic trading system. This chapter demonstrates various essential recipes that introduce the essential broker API calls needed for developing a complete algorithmic trading system.

This chapter covers the following recipes:

  • Setting up Python connectivity with the broker
  • Querying a list of instruments
  • Fetching an instrument
  • Querying a list of exchanges
  • Querying a list of segments
  • Knowing other attributes supported by the broker
  • Placing a simple REGULAR order
  • Placing a simple BRACKET order
  • Placing a simple DELIVERY order
  • Placing a simple INTRADAY order
  • Querying margins and funds
  • Calculating the brokerage charged
  • Calculating the government taxes charged

Let's get started!

Technical requirements

You will need the following to successfully execute the recipes in this chapter:

  • Python 3.7+
  • The Pythonpyalgotrading package ($ pip install pyalgotrading)

The latest Jupyter Notebook for this chapter can be found on GitHub athttps://github.com/PacktPublishing/Python-Algorithmic-Trading-Cookbook/tree/master/Chapter02.

This chapter demonstrates the APIs of a modern broker,ZERODHA, which is supported bypyalgotrading. You may wish to choose other brokers supported bypyalgotrading as well. The recipes in this chapter should be more or less the same for any other broker. Thepyalgotrading package abstracts broker APIs behind a unified interface, so you don't need to worry about the underlying broker API calls.

To set up a broking account withZERODHA, please refer to the detailed steps provided inAppendix I.

Setting up Python connectivity with the broker

The first thing you need to set up connectivity with the broker is API keys. The broker provides unique keys to each customer, typically as anapi-key andapi-secret key pair. These API keys are chargeable, usually on a monthly subscription basis. You need to get your copies ofapi-key andapi-secret from the broker's website before you start this recipe. Please refer toAppendix I for more details.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary modules:
>>> from pyalgotrading.broker.broker_connection_zerodha import BrokerConnectionZerodha
  1. Get theapi_key andapi_secret keys from the broker. These are unique to you and will be used by the broker to identify your Demat account:
>>> api_key = "<your-api-key>"
>>> api_secret = "<your-api-secret>"
>>> broker_connection = BrokerConnectionZerodha(api_key, api_secret)

You will get the following result:

Installing package kiteconnect via pip...
Please login to this link to generate your request token: https://kite.trade/connect/login?api_key=<your-api-key>&v=3
  1. Get the request token from the preceding URL:
>>> request_token = "<your-request-token>"
>>> broker_connection.set_access_token(request_token)

How it works...

Instep 1, you import theBrokerConnectionZerodha class frompyalgotrading. TheBrokerConnectionZerodha class provides an abstraction around the broker-specific APIs. Forstep 2, you need your API key and API secret from the broker. If you do not have them, please refer toAppendix I for detailed instructions with screenshots on getting this keys. Instep 2, you assign your API key and API secret to the newapi_key andapi_secret variables and use them to createbroker_connection, an instance of theBrokerConnectionZerodha class. If you are running this for the first time andkiteconnect is not installed,pyalgotrading will automatically install it for you. (kiteconnect is the official Python package that talks to the Zerodha backend;BrokerConnectionZerodha is a wrapper on top ofkiteconnect.)Step 2 generates a login URL. Here, you need to click on the link and log in with your Zerodha credentials. If the authentication process is successful, you will see a link in your browser's address bar that looks similar to the following:

https://127.0.0.1/?request_token=&action=login&status=success

For example, the full link would be as follows:

https://127.0.0.1/?request_token=H06I6Ydv95y23D2Dp7NbigFjKweGwRP7&action=login&status=success

Copy the alphanumeric-token,H06I6Ydv95y23D2Dp7NbigFjKweGwRP7, and paste it intorequest_token as part ofstep 3. Thebroker_connection instance is now ready to perform API calls.

Querying a list of instruments

Once thebroker_connection handle is ready, it can be used to query the list containing all the financial instruments provided by the broker.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the previous recipe in this chapter to set up this object.

How to do it…

We execute the following steps to complete this recipe:

  1. Display all the instruments:
>>> instruments = broker_connection.get_all_instruments()
>>> instruments

You will get an output similar to the following. The exact output may differ for you:

  instrument_token exchange_token tradingsymbol name last_price expiry strike tick_size lot_size instrument_type segment exchange
0 267556358 1045142 EURINR20AUGFUT EURINR 0.0 2020-08-27 0.0 0.0025 1 FUT BCD-FUT BCD
1 268660998 1049457 EURINR20DECFUT EURINR 0.0 2020-12-29 0.0 0.0025 1 FUT BCD-FUT BCD
2 266440966 1040785 EURINR20JULFUT EURINR 0.0 2020-07-29 0.0 0.0025 1 FUT BCD-FUT BCD
3 266073606 1039350 EURINR20JUNFUT EURINR 0.0 2020-06-26 0.0 0.0025 1 FUT BCD-FUT BCD
4 265780742 1038206 EURINR20MAYFUT EURINR 0.0 2020-05-27 0.0 0.0025 1 FUT BCD-FUT BCD
... ... ... ... ... ... ... ... ... ... ... ... ...
64738 978945 3824 ZODJRDMKJ ZODIAC JRD-MKJ 0.0 0.0 0.0500 1 EQ NSE NSE
64739 2916865 11394 ZOTA ZOTA HEALTH CARE 0.0 0.0 0.0500 1 EQ NSE NSE
64740 7437825 29054 ZUARI-BE ZUARI AGRO CHEMICALS 0.0 0.0 0.0500 1 EQ NSE NSE
64741 979713 3827 ZUARIGLOB ZUARI GLOBAL 0.0 0.0 0.0500 1 EQ NSE NSE
64742 4514561 17635 ZYDUSWELL ZYDUS WELLNESS 0.0 0.0 0.0500 1 EQ NSE NSE

64743 rows × 12 columns
  1. Print the total number of instruments:
>>> print(f'Total instruments: {len(instruments)}')

We get the following output (your output may differ):

Total instruments: 64743

How it works…

The first step fetches all the available financial instruments using theget_all_instruments() method ofbroker_connection. This method returns apandas.DataFrame object. This object is assigned to a new variable,instruments, which is shown in the output ofstep 1. This output may differ for you as new financial instruments are frequently added and existing ones expire regularly. The final step shows the total number of instruments provided by the broker.

An explanation of the data that was returned by the preceding API call will be discussed in depth inChapter 3,Analyzing Financial Data. For this recipe, it suffices to know the method for fetching the list of instruments.

Fetching an instrument

Instruments, also known asfinancial instruments orsecurities, are assets that can be traded in an exchange. In an exchange, there can easily be tens of thousands of instruments. This recipe demonstrates how to fetch an instrument based on itsexchange andtrading symbol.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe in this chapter to set up this object.

How to do it…

Fetch an instrument for a specific trading symbol and exchange:

>>> broker_connection.get_instrument(segment='NSE', tradingsymbol='TATASTEEL')

You'll get the following output:

segment: NSE
exchange: NSE
tradingsymbol: TATASTEEL
broker_token: 895745
tick_size: 0.05
lot_size: 1
expiry:
strike_price: 0.0

How it works…

Thebroker_connection object provides a handy method,get_instrument, for fetching any financial instrument. It takessegment andtradingsymbol as attributes before returning an instrument. The return object is an instance of theInstrument class.

Querying a list of exchanges

Anexchange is a marketplace where instruments are traded. Exchanges ensure that the trading process is fair and happens in an orderly fashion at all times. Usually, a broker supports multiple exchanges. This recipe demonstrates how to find the list of exchanges supported by the broker.

Getting ready

Make sure theinstruments object is available in your Python namespace. Refer to the second recipe of this chapter to learn how to set up this object.

How to do it…

Display the exchanges supported by the broker:

>>> exchanges = instruments.exchange.unique()
>>> print(exchanges)

You will get the following output:

['BCD' 'BSE' 'NSE' 'CDS' 'MCX' 'NFO']

How it works…

instruments.exchange returns apandas.Series object. Itsunique() method returns anumpy.ndarray object consisting of unique exchanges supported by the broker.

Querying a list of segments

A segment is essentially a categorization of instruments based on their types. The various types of segments that are commonly found at exchanges include cash/equities, futures, options, commodities, and currency. Each segment may have a different operating time. Usually, a broker supports multiple segments within multiple exchanges. This recipe demonstrates how to find the list of segments supported by the broker.

Getting ready

Make sure theinstruments object is available in your Python namespace. Refer to the second recipe of this chapter to learn how to set up this object.

How to do it…

Display the segments supported by the broker:

>>> segments = instruments.segment.unique()
>>> print(segments)

You will get the following output:

['BCD-FUT' 'BCD' 'BCD-OPT' 'BSE' 'INDICES' 'CDS-FUT' 'CDS-OPT' 'MCX-FUT' 'MCX-OPT' 'NFO-OPT' 'NFO-FUT' 'NSE']

How it works…

instruments.segment returns apandas.Series object. Its unique method returns anumpy.ndarray object consisting of unique segments supported by the broker.

Knowing other attributes supported by the broker

For placing an order, the following attributes are needed: order transaction type, order variety, order type, and order code. Different brokers may support different types of order attributes. For example, some brokers may support just regular orders, while others may support regular and bracket orders. The value for each of the attributes supported by the broker can be queried using the broker specific constants provided by thepyalgotrading package.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary class from thepyalgotrading module:
>>> from pyalgotrading.broker.broker_connection_zerodha import BrokerConnectionZerodha
  1. List the order transaction types:
>>> list(BrokerConnectionZerodha.ORDER_TRANSACTION_TYPE_MAP.keys())

We'll get the following output:

[<BrokerOrderTransactionTypeConstants.BUY: 'BUY'>,
<BrokerOrderTransactionTypeConstants.SELL: 'SELL'>]
  1. List the order varieties:
>>> list(BrokerConnectionZerodha.ORDER_VARIETY_MAP.keys())

We'll get the following output:

[<BrokerOrderVarietyConstants.MARKET: 'ORDER_VARIETY_MARKET'>,
<BrokerOrderVarietyConstants.LIMIT: 'ORDER_VARIETY_LIMIT'>,
<BrokerOrderVarietyConstants.STOPLOSS_LIMIT: 'ORDER_VARIETY_STOPLOSS_LIMIT'>,
<BrokerOrderVarietyConstants.STOPLOSS_MARKET: 'ORDER_VARIETY_STOPLOSS_MARKET'>]
  1. List the order types:
>>> list(BrokerConnectionZerodha.ORDER_TYPE_MAP.keys())

We'll get the following output:

[<BrokerOrderTypeConstants.REGULAR: 'ORDER_TYPE_REGULAR'>,
<BrokerOrderTypeConstants.BRACKET: 'ORDER_TYPE_BRACKET'>,
<BrokerOrderTypeConstants.COVER: 'ORDER_TYPE_COVER'>,
<BrokerOrderTypeConstants.AMO: 'ORDER_TYPE_AFTER_MARKET_ORDER'>]
  1. List the order codes:
>>> list(BrokerConnectionZerodha.ORDER_CODE_MAP.keys())

We'll get the following output:

[<BrokerOrderCodeConstants.INTRADAY: 'ORDER_CODE_INTRADAY'>,
<BrokerOrderCodeConstants.DELIVERY: 'ORDER_CODE_DELIVERY_T0'>]

How it works…

Instep 1, we import theBrokerConnectionZerodha class frompyalgotrading. This class holds the order attributes mapping betweenpyalgotrading and broker specific constants as dictionary objects. The next steps fetch and print these mappings. Step 2 shows that your broker supports bothBUY andSELL order transaction types.

Step 3 shows that your broker supportsMARKET,LIMIT,STOPLOSS_LIMIT, andSTOPLOSS_MARKET order varieties.Step 4 shows that your broker supportsREGULAR,BRACKET,COVER, andAFTER_MARKET order types.Step 5 shows that your broker supportsINTRADAY andDELIVERY order codes.

The outputs may differ from broker to broker, so consult your broker documentation if you are using a different broker. A detailed explanation of all these types of parameters will be covered inChapter 6,Placing Trading Orders on the Exchange. This recipe is to just give an overview of the parameters, as they are needed in the subsequent recipes of this chapter.

Placing a simple REGULAR order

This recipe demonstrates how to place aREGULAR order on the exchange via the broker.REGULAR orders are the simplest types of orders. After trying out this recipe, check your broking account by logging into the broker's website; you will find that an order has been placed there. You can match the order ID with the one that's returned in the last code snippet shown in this recipe.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe of this chapter to learn how to set up this object.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary constants frompyalgotrading:
>>> from pyalgotrading.constants import *
  1. Fetch an instrument for a specific trading symbol and exchange:
>>> instrument = broker_connection.get_instrument(segment='NSE',
tradingsymbol='TATASTEEL')
  1. Place a simple regular order– aBUY,REGULAR,INTRADAY,MARKET order:
>>> order_id = broker_connection.place_order(
instrument=instrument,
order_transaction_type= \
BrokerOrderTransactionTypeConstants.BUY,
order_type=BrokerOrderTypeConstants.REGULAR,
order_code=BrokerOrderCodeConstants.INTRADAY,
order_variety= \
BrokerOrderVarietyConstants.MARKET,
quantity=1)
>>> order_id

We'll get the following output:

191209000001676

How it works…

Instep 1, you import constants frompyalgotrading. Instep 2, you fetch the financial instrument withsegment = 'NSE' andtradingsymbol = 'TATASTEEL' using theget_instrument() method ofbroker_connection. Instep 3, you place aREGULAR order using theplace_order() method ofbroker_connection. The descriptions of the parameters accepted by theplace_order() method are as follows:

  • instrument: The financial instrument for which the order must be placed. Should an instance of theInstrument class. You passinstrument here.
  • order_transaction_type: The order transaction type. Should be an enum of typeBrokerOrderTransactionTypeConstants. You passBrokerOrderTransactionTypeConstants.BUY here.
  • order_type: The order type. Should be an enum of typeBrokerOrderTypeConstants. You passBrokerOrderTypeConstants.REGULAR here.
  • order_code: The order code. Should be an enum of typeBrokerOrderCodeConstants. You passBrokerOrderCodeConstants.INTRADAY here.
  • order_variety: The order variety. Should be an enum of typeBrokerOrderVarietyConstants. You passBrokerOrderVarietyConstants.MARKET here.
  • quantity: The number of shares to be traded for the given instrument. Should be a positive integer. We pass1 here.

If the order placement is successful, the method returns an order ID which you can use at any point in time later on for querying the status of the order.

A detailed explanation of the different types of parameters will be covered inChapter 6,Placing Trading Orders on the Exchange. This recipe is intended to give you an idea of how to place aREGULAR order, one of the various types of possible orders.

Placing a simple BRACKET order

This recipe demonstrates how to place aBRACKET order on the exchange via the broker.BRACKET orders are two-legged orders. Once the first order is executed, the broker automatically places two new ordersaSTOPLOSS order and aTARGET order. Only one of them is executed at any time; the other is canceled when the first order is completed. After trying out this recipe, check your broking account by logging into the broker's website; you will find that an order has been placed there. You can match the order ID with the one that's returned in the last code snippet shown in this recipe.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe of this chapter to learn how to set up this object.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary modules:
>>> from pyalgotrading.constants import *
  1. Fetch an instrument for a specific trading symbol and exchange:
>>> instrument = broker_connection.get_instrument(segment='NSE',
tradingsymbol='ICICIBANK')
  1. Fetch the last traded price of the instrument:
>>> ltp = broker_connection.get_ltp(instrument)
  1. Place a simpleBRACKET order– aBUY,BRACKET,INTRADAY,LIMIT order:
>>> order_id = broker_connection.place_order(
instrument=instrument,
order_transaction_type= \
BrokerOrderTransactionTypeConstants.BUY,
order_type=BrokerOrderTypeConstants.BRACKET,
order_code=BrokerOrderCodeConstants.INTRADAY,
order_variety=BrokerOrderVarietyConstants.LIMIT,
quantity=1, price=ltp-1,
stoploss=2, target=2)
>>> order_id

We'll get the following output:

191212001268839
If you get the following error while executing this code, it would mean that Bracket orders are blocked by the broker due to high volatility in the markets:

InputException: Due to expected higher volatility in the markets, Bracket orders are blocked temporarily.

You should try the recipe later when the broker starts allowing Bracket orders. You can check for updates on the Broker site from time to time to know when Bracket orders would be allowed.

How it works…

Instep 1, you import the constants frompyalgotrading. Instep 2, you fetch the financial instrument withsegment = 'NSE' andtradingsymbol = 'ICICBANK' using theget_instrument() method ofbroker_connection. Instep 3, you fetch thelast traded price orLTP of the instrument. (LTP will be explained in more detail in theLast traded price of a financial instrument recipe ofChapter 3,Analyzing Financial Data.) Instep 4, you place aBRACKET order using theplace_order() method ofbroker_connection. The descriptions of the parameters accepted by theplace_order() method are as follows:

  • instrument: The financial instrument for which the order must be placed. Should be an instance of theInstrument class. You passinstrument here.
  • order_transaction_type: The order transaction type. Should be an enum of typeBrokerOrderTransactionTypeConstants. You passBrokerOrderTransactionTypeConstants.BUY here.
  • order_type: The order type. Should be an enum of typeBrokerOrderTypeConstants. You passBrokerOrderTypeConstants.BRACKET here.
  • order_code: The order code. Should be an enum of typeBrokerOrderCodeConstants.You passBrokerOrderCodeConstants.INTRADAY here.
  • order_variety: The order variety. Should be an enum of typeBrokerOrderVarietyConstants.You passBrokerOrderVarietyConstants.LIMIT here.
  • quantity: The number of shares to be traded for the given instrument. Should be a positive integer. You pass1 here.
  • price: The limit price at which the order should be placed. You passltp-1 here, which means 1 unit price below theltp value.
  • stoploss: The price difference from the initial order price, at which the stoploss order should be placed. Should be a positive integer or float value. You pass2 here.
  • target: The price difference from the initial price, at which the target order should be placed. Should be a positive integer or float value. You pass2 here.

If the order placement is successful, the method returns an order ID which you can use at any point in time later on for querying the status of the order.

A detailed explanation of the different types of parameters will be covered inChapter 6,Placing Trading Orders on the Exchange. This recipe is intended to give you an idea of how to place aBRACKET order, one of the various types of possible orders.

Placing a simple DELIVERY order

This recipe demonstrates how to place aDELIVERY order on the exchange via the broker. ADELIVERY order is delivered to the user's Demat account and exists until it is explicitly squared-off by the user. Positions created by delivery orders at the end of a trading session are carried forwarded to the next trading session. They are not explicitly squared-off by the broker. After trying out this recipe, check your broking account by logging into the broker's website; you will find that an order has been placed there. You can match the order ID with the one that's returned in the last code snippet shown in this recipe.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe of this chapter to learn how to set up this object.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary modules:
>>> from pyalgotrading.constants import *
  1. Fetch an instrument for a specific trading symbol and exchange:
>>> instrument = broker_connection.get_instrument(segment='NSE',
tradingsymbol='AXISBANK')
  1. Place a simpleDELIVERY order– aSELL,REGULAR,DELIVERY,MARKET order:
>>> order_id = broker_connection.place_order(
instrument=instrument,
order_transaction_type= \
BrokerOrderTransactionTypeConstants.SELL,
order_type=BrokerOrderTypeConstants.REGULAR,
order_code=BrokerOrderCodeConstants.DELIVERY,
order_variety= \
BrokerOrderVarietyConstants.MARKET,
quantity=1)
>>> order_id

We'll get the following output:

191212001268956

How it works…

Instep 1, you import the constants frompyalgotrading. Instep 2, you fetch the financial instrument withsegment = 'NSE' andtradingsymbol = 'AXISBANK' using theget_instrument() method ofbroker_connection. Instep 3, you place aDELIVERY order using theplace_order() method ofbroker_connection. This method accepts the following arguments:

  • instrument: The financial instrument for which the order must be placed. Should be an instance of theInstrument class. You passinstrument here.
  • order_transaction_type: The order transaction type. Should be an enum of typeBrokerOrderTransactionTypeConstants. You passBrokerOrderTransactionTypeConstants.SELL here.
  • order_type: The order type. Should be an enum of typeBrokerOrderTypeConstants. You passBrokerOrderTypeConstants.REGULAR here.
  • order_code: The order code. Should be an enum of typeBrokerOrderCodeConstants. You passBrokerOrderCodeConstants.DELIVERY here.
  • order_variety: The order variety. Should be an enum of typeBrokerOrderVarietyConstants. You passBrokerOrderVarietyConstants.MARKET here.
  • quantity: The number of shares to be traded for the given instrument. Should be a positive integer. We pass1 here.

If the order placement is successful, the method returns an order ID which you can use at any point in time later on for querying the status of the order.

A detailed explanation of the different types of parameters will be covered inChapter 6,Placing Trading Orders on the Exchange. This recipe is intended to give you an idea of how to place aDELIVERY order, one of the various types of possible orders.

Placing a simple INTRADAY order

This recipe demonstrates how to place anINTRADAY order via the broker API. AnINTRADAY order is not delivered to the user's Demat account. Positions created by intraday orders have a lifetime of a single day. The positions are explicitly squared off by the broker at the end of a trading session and are not carried forward to the next trading session. After trying out this recipe, check your broking account by logging into the broker's website; you will find that an order has been placed there. You can match the order ID with the one that's returned in the last code snippet shown in this recipe.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe of this chapter to learn how to set up this object.

How to do it…

We execute the following steps to complete this recipe:

  1. Import the necessary modules:
>>> from pyalgotrading.constants import *
  1. Fetch an instrument for a specific trading symbol and exchange:
>>> instrument = broker_connection.get_instrument(segment='NSE',
tradingsymbol='HDFCBANK')
  1. Fetch the last traded price of the instrument:
>>> ltp = broker_connection.get_ltp(instrument)
  1. Place a simpleINTRADAY order– aSELL,BRACKET,INTRADAY,LIMIT order:
>>> order_id = broker_connection.place_order(
instrument=instrument,
order_transaction_type= \
BrokerOrderTransactionTypeConstants.SELL,
order_type=BrokerOrderTypeConstants.BRACKET,
order_code=BrokerOrderCodeConstants.INTRADAY,
order_variety=BrokerOrderVarietyConstants.LIMIT,
quantity=1, price=ltp+1, stoploss=2, target=2)
>>> order_id

We'll get the following output:

191212001269042
If you get the following error while executing this code, it would mean that Bracket orders are blocked by the broker due to high volatility in the markets:

InputException: Due to expected higher volatility in the markets, Bracket orders are blocked temporarily.

You should try the recipe later when the broker starts allowing Bracket orders. You can check for updates on the Broker site from time to time to know when Bracket orders would be allowed.

How it works…

Instep 1, you import the constants frompyalgotrading. Instep 2, you fetch the financial instrument withsegment = 'NSE' andtradingsymbol = 'HDFCBANK' using theget_instrument() method ofbroker_connection. Instep 3, you fetch the LTP of the instrument. (LTP will be explained in detail intheLast traded price of a financial instrument recipe ofChapter 3,Analyzing Financial Data.) Instep 4, you place aBRACKET order using theplace_order() method of thebroker_connection. The descriptions of the parameters accepted by theplace_order() method are as follows:

  • instrument: The financial instrument for which the order must be placed. Should be an instance of theInstrument class. You passinstrument here.
  • order_transaction_type: The order transaction type. Should be an enum of typeBrokerOrderTransactionTypeConstants. You passBrokerOrderTransactionTypeConstants.SELL here.
  • order_type: The order type. Should be an enum of typeBrokerOrderTypeConstants. You passBrokerOrderTypeConstants.BRACKET here.
  • order_code: The order code. Should be an enum of typeBrokerOrderCodeConstants. You passBrokerOrderCodeConstants.INTRADAY here.
  • order_variety: The order variety. Should be an enum of typeBrokerOrderVarietyConstants. You passBrokerOrderVarietyConstants.LIMIT here.
  • quantity: The number of shares to be traded for the given instrument. Should be a positive integer. You pass1 here.
  • price: The limit price at which the order should be placed. You passltp+1 here, which means 1 unit price above theltp value.
  • stoploss: The price difference from the initial order price, at which the stoploss order should be placed. Should be a positive integer or float value. You pass2 here.
  • target: The price difference from the initial order price, at which the target order should be placed. Should be a positive integer or float value. You pass2 here.

If the order placement is successful, the method returns an order ID which you can use at any point in time later on for querying the status of the order.

A detailed explanation of the different types of parameters will be covered inChapter 6,Placing Trading Orders on the Exchange. This recipe is intended to give you an idea of how to place anINTRADAY order, one of the various types of possible orders.

Querying margins and funds

Before placing orders, it is important to ensure that you have enough margins and funds available in your broking account to place the orders successfully. A lack of sufficient funds would result in the rejection of any orders placed by the broker, which means the others would never get placed on the exchange. This recipe shows you how to find the available margins and funds in your broking account at any point in time.

Getting ready

Make sure thebroker_connection object is available in your Python namespace. Refer to the first recipe of this chapter to learn how to set it up.

How to do it…

We execute the following steps to complete this recipe:

  1. Display the equity margins:
>>> equity_margins = broker_connection.get_margins('equity')
>>> equity_margins

We'll get the following output (your output may differ):

{'enabled': True,
'net': 1623.67,
'available': {'adhoc_margin': 0,
'cash': 1623.67,
'opening_balance': 1623.67,
'live_balance': 1623.67,
'collateral': 0,
'intraday_payin': 0},
'utilised': {'debits': 0,
'exposure': 0,
'm2m_realised': 0,
'm2m_unrealised': 0,
'option_premium': 0,
'payout': 0,
'span': 0,
'holding_sales': 0,
'turnover': 0,
'liquid_collateral': 0,
'stock_collateral': 0}}
  1. Display the equity funds:
>>> equity_funds = broker_connection.get_funds('equity')
>>> equity_funds

We'll get the following output (your output may differ):

1623.67
  1. Display the commodity margins:
>>> commodity_margins = get_margins(commodity')
>>> commodity_margins

We'll get the following output (your output may differ):

{'enabled': True,
'net': 16215.26,
'available': {'adhoc_margin': 0,
'cash': 16215.26,
'opening_balance': 16215.26,
'live_balance': 16215.26,
'collateral': 0,
'intraday_payin': 0},
'utilised': {'debits': 0,
'exposure': 0,
'm2m_realised': 0,
'm2m_unrealised': 0,
'option_premium': 0,
'payout': 0,
'span': 0,
'holding_sales': 0,
'turnover': 0,
'liquid_collateral': 0,
'stock_collateral': 0}}
  1. Display the commodity funds:
>>> commodity_funds = broker_connection.get_funds('commodity')
>>> commodity_funds

We'll get the following output (your output may differ):

0

How it works…

Thebroker_connection object provides methods for fetching the available margins and funds for your broking account:

  • get_margins()
  • get_funds()

The broker Zerodha keeps track of margins and funds separately forequity andcommodity products. If you are using a different broker supported bypyalgotrading, it may or may not track the funds and margins separately forequity andcommodity.

Step 1 shows how margins can be queried for theequity product using theget_margins() method of thebroker_connection object, withequity as an argument.Step 2 shows how funds can be queried for theequity product using theget_funds() method of thebroker_connection object, with theequity string as an argument.

Steps 3 and4 show how margins and funds can be queried for thecommodity product in a similar way with thecommodity string as an argument.

Calculating the brokerage charged

For every order completed successfully, the broker may charge a certain fee, which is usually a small fraction of the price at which the instrument was bought or sold. While the amount may seem small, it is important to keep track of the brokerage as it may end up eating a significant chunk of your profit at the end of the day.

The brokerage that's charged varies from broker to broker and also from segment to segment. For the purpose of this recipe, we will consider a brokerage of 0.01%.

How to do it…

We execute the following steps to complete this recipe:

  1. Calculate the brokerage that's charged per trade:
>>> entry_price = 1245
>>> brokerage = (0.01 * 1245)/100
>>> print(f'Brokerage charged per trade: {brokerage:.4f}')

We'll get the following output:

Brokerage charged per trade: 0.1245
  1. Calculate the total brokerage that's charged for 10 trades:
>>> total_brokerage = 10 * (0.01 * 1245) / 100
>>> print(f'Total Brokerage charged for 10 trades: \
{total_brokerage:.4f}')

We'll get the following output:

Total Brokerage charged for 10 trades: 1.2450

How it works…

Instep 1, we start with the price at which a trade was bought or sold,entry_price. For this recipe, we have used1245. Next, we calculate 0.01% of the price, which comes to0.1245. Then, we calculate the total brokerage for 10 such trades, which comes out as10 * 0.1245 = 1.245.

For every order, the brokerage is charged twice. The first time is when the order has entered a position, while the second time is when it has exited the position. To get the exact details of the brokerage that's been charged for your trades, please refer to the list of charges offered by your broker.

Calculating the government taxes charged

For every order that's completed successfully, the government may charge a certain fee, which is a fraction of the price at which the instrument was bought or sold. While the amount may seem small, it is important to keep track of government taxes as they may end up eating a significant chunk of your profit at the end of the day.

The government charge depends on the location of the exchange, and varies from segment to segment. For the purpose of this recipe, we will consider government taxes at a rate of 0.1%.

How to do it…

We execute the following steps to complete this recipe:

  1. Calculate the government taxes that are charged per trade:
>>> entry_price = 1245
>>> brokerage = (0.1 * 1245)/100
>>> print(f'Government taxes charged per trade: {brokerage:.4f}')

We'll get the following output:

Government taxes charged per trade: 1.2450

  1. Calculate the total government taxes that are charged for 10 trades:
>>> total_brokerage = 10 * (0.1 * 1245) / 100
>>> print(f'Total Government taxes charged for 10 trades: \
{total_brokerage:.4f}')

We'll get the following output:

Total Government taxes charged for 10 trades: 12.4500

How it works…

Instep 1, we start with the price at which a trade was bought or sold,entry_price. For this recipe, we have used1245. Next, we calculate 0.1% of the price, which comes to1.245. Then, we calculate the total brokerage for 10 such trades, which comes out as10 * 1.245 = 12.245.

For every order, government taxes are charged twice. The first time is when the order has entered a position, while the second time is when it has exited the position. To get the exact details of the government taxes that are charged for your trades, please refer to the list of government taxes provided by your exchange.
Download code iconDownload Code

Key benefits

  • Build a strong foundation in algorithmic trading by becoming well-versed with the basics of financial markets
  • Demystify jargon related to understanding and placing multiple types of trading orders
  • Devise trading strategies and increase your odds of making a profit without human intervention

Description

If you want to find out how you can build a solid foundation in algorithmic trading using Python, this cookbook is here to help.Starting by setting up the Python environment for trading and connectivity with brokers, you’ll then learn the important aspects of financial markets. As you progress, you’ll learn to fetch financial instruments, query and calculate various types of candles and historical data, and finally, compute and plot technical indicators. Next, you’ll learn how to place various types of orders, such as regular, bracket, and cover orders, and understand their state transitions. Later chapters will cover backtesting, paper trading, and finally real trading for the algorithmic strategies that you've created. You’ll even understand how to automate trading and find the right strategy for making effective decisions that would otherwise be impossible for human traders.By the end of this book, you’ll be able to use Python libraries to conduct key tasks in the algorithmic trading ecosystem.Note: For demonstration, we're using Zerodha, an Indian Stock Market broker. If you're not an Indian resident, you won't be able to use Zerodha and therefore will not be able to test the examples directly. However, you can take inspiration from the book and apply the concepts across your preferred stock market broker of choice.

Who is this book for?

If you are a financial analyst, financial trader, data analyst, algorithmic trader, trading enthusiast or anyone who wants to learn algorithmic trading with Python and important techniques to address challenges faced in the finance domain, this book is for you. Basic working knowledge of the Python programming language is expected. Although fundamental knowledge of trade-related terminologies will be helpful, it is not mandatory.

What you will learn

  • Use Python to set up connectivity with brokers
  • Handle and manipulate time series data using Python
  • Fetch a list of exchanges, segments, financial instruments, and historical data to interact with the real market
  • Understand, fetch, and calculate various types of candles and use them to compute and plot diverse types of technical indicators
  • Develop and improve the performance of algorithmic trading strategies
  • Perform backtesting and paper trading on algorithmic trading strategies
  • Implement real trading in the live hours of stock markets

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Aug 28, 2020
Length:542 pages
Edition :1st
Language :English
ISBN-13 :9781838982515
Category :
Languages :
Tools :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Aug 28, 2020
Length:542 pages
Edition :1st
Language :English
ISBN-13 :9781838982515
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
€189.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts
€264.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts

Frequently bought together


Machine Learning for Algorithmic Trading
Machine Learning for Algorithmic Trading
Read more
Jul 2020820 pages
Full star icon4 (45)
eBook
eBook
€8.98€34.99
€43.99
€59.99
Learn Algorithmic Trading
Learn Algorithmic Trading
Read more
Nov 2019394 pages
Full star icon3.8 (10)
eBook
eBook
€8.98€29.99
€36.99
Python Algorithmic Trading Cookbook
Python Algorithmic Trading Cookbook
Read more
Aug 2020542 pages
Full star icon3.8 (10)
eBook
eBook
€8.98€29.99
€36.99
Stars icon
Total117.97
Machine Learning for Algorithmic Trading
€43.99
Learn Algorithmic Trading
€36.99
Python Algorithmic Trading Cookbook
€36.99
Total117.97Stars icon
Buy 2+ to unlock€6.99 prices - master what's next.
SHOP NOW

Table of Contents

12 Chapters
Handling and Manipulating Date, Time, and Time Series DataChevron down iconChevron up icon
Handling and Manipulating Date, Time, and Time Series Data
Technical requirements
Creating datetime objects
Creating timedelta objects
Operations on datetime objects
Modifying datetime objects
Converting a datetime object to a string
Creating a datetime object from a string
The datetime object and time zones
Creating a pandas.DataFrame object
DataFrame manipulation—renaming, rearranging, reversing, and slicing
DataFrame manipulation—applying, sorting, iterating, and concatenating
Converting a DataFrame into other formats
Creating a DataFrame from other formats
Stock Markets - Primer on TradingChevron down iconChevron up icon
Stock Markets - Primer on Trading
Technical requirements
Setting up Python connectivity with the broker
Querying a list of instruments
Fetching an instrument
Querying a list of exchanges
Querying a list of segments
Knowing other attributes supported by the broker
Placing a simple REGULAR order
Placing a simple BRACKET order
Placing a simple DELIVERY order
Placing a simple INTRADAY order
Querying margins and funds
Calculating the brokerage charged
Calculating the government taxes charged
Fetching Financial DataChevron down iconChevron up icon
Fetching Financial Data
Technical requirements
Fetching the list of financial instruments
Attributes of a financial instrument
Expiry of financial instruments
Circuit limits of a financial instrument
The market depth of a financial instrument
The total pending buy quantity of a financial instrument
The total pending sell quantity of a financial instrument
The total volume traded for the day of a financial instrument
The last traded price of a financial instrument
The last traded time of a financial instrument
The last traded quantity of a financial instrument
The recorded open price of the day of a financial instrument
The recorded highest price of the day of a financial instrument
The recorded lowest price of the day of a financial instrument
The recorded close price of the last traded day of a financial instrument
Computing Candlesticks and Historical DataChevron down iconChevron up icon
Computing Candlesticks and Historical Data
Technical requirements
Fetching historical data using the broker API
Fetching historical data using the Japanese (OHLC) candlestick pattern
Fetching the Japanese candlestick pattern with variations in candle intervals
Fetching historical data using the Line Break candlestick pattern
Fetching historical data using the Renko candlestick pattern
Fetching historical data using the Heikin-Ashi candlestick pattern
Fetching historical data using Quandl
Computing and Plotting Technical IndicatorsChevron down iconChevron up icon
Computing and Plotting Technical Indicators
Technical requirements
Trend indicators – simple moving average
Trend indicators – exponential moving average
Trend indicators – moving average convergence divergence
Trend indicators – parabolic stop and reverse
Momentum indicators – relative strength index
Momentum indicators – stochastic oscillator
Volatility indicators – Bollinger Bands
Volatility indicators – average true range
Volume indicators – on balance volume
Volume indicators – volume-weighted average price
Placing Regular Orders on the ExchangeChevron down iconChevron up icon
Placing Regular Orders on the Exchange
Technical requirements
Placing a regular market order
Placing a regular limit order
Placing a regular stoploss-limit order
Placing a regular stoploss-market order
Placing Bracket and Cover Orders on the ExchangeChevron down iconChevron up icon
Placing Bracket and Cover Orders on the Exchange
Technical requirements
Placing a bracket limit order
Placing a bracket stoploss-limit order
Placing a bracket limit order with trailing stoploss
Placing a bracket stoploss-limit order with trailing stoploss
Placing a cover market order
Placing a cover limit order
Algorithmic Trading Strategies - Coding Step by StepChevron down iconChevron up icon
Algorithmic Trading Strategies - Coding Step by Step
Technical requirements
EMA-Regular-Order strategy – coding the __init__, initialize, name, and versions_supported methods
EMA-Regular-Order strategy – coding the strategy_select_instruments_for_entry method
EMA-Regular-Order strategy – coding the strategy_enter_position method
EMA-Regular-Order strategy – coding the strategy_select_instruments_for_exit method
EMA-Regular-Order strategy – coding the strategy_exit_position method
EMA-Regular-Order strategy – uploading the strategy on the AlgoBulls trading platform
MACD-Bracket-Order strategy – coding the __init__, initialize, name, and versions_supported methods
MACD-Bracket-Order strategy – coding the strategy_select_instruments_for_entry method
MACD-Bracket-Order strategy – coding the strategy_enter_position method
MACD-Bracket-Order strategy – coding the strategy_select_instruments_for_exit method
MACD-Bracket-Order strategy – coding the strategy_exit_position method
MACD-Bracket-Order strategy — uploading the strategy on the AlgoBulls trading platform
Algorithmic Trading - BacktestingChevron down iconChevron up icon
Algorithmic Trading - Backtesting
Technical requirements
EMA-Regular-Order strategy – fetching the strategy
EMA-Regular-Order strategy – backtesting the strategy
EMA-Regular-Order strategy – fetching backtesting logs in real time
EMA-Regular-Order strategy – fetching a backtesting report – profit and loss table
EMA-Regular-Order strategy — fetching a backtesting report – statistics table
EMA-Regular-Order strategy – fetching a backtesting report – order history
MACD-Bracket-Order strategy – fetching the strategy
MACD-Bracket-Order strategy – backtesting the strategy
MACD-Bracket-Order strategy – fetching backtesting logs in real time
MACD-Bracket-Order strategy – fetching a backtesting report – profit and loss table
MACD-Bracket-Order strategy – fetching a backtesting report – statistics table
MACD-Bracket-Order strategy – fetching a backtesting report – order history
Algorithmic Trading - Paper TradingChevron down iconChevron up icon
Algorithmic Trading - Paper Trading
Technical requirements
EMA-Regular-Order strategy – fetching the strategy
EMA-Regular-Order strategy – paper trading the strategy
EMA-Regular-Order strategy – fetching paper trading logs in real time
EMA-Regular-Order strategy – fetching a paper trading report – profit and loss table
EMA-Regular-Order strategy – fetching a paper trading report – statistics table
EMA-Regular-Order strategy – fetching a paper trading report – order history
MACD-Bracket-Order strategy – fetching the strategy
MACD-Bracket-Order strategy – paper trading the strategy
MACD-Bracket-Order strategy – fetching paper trading logs in real time
MACD-Bracket-Order strategy – fetching a paper trading report – profit and loss table
MACD-Bracket-Order strategy – fetching a paper trading report – statistics table
MACD-Bracket-Order strategy – fetching a paper trading report – order history
Algorithmic Trading - Real TradingChevron down iconChevron up icon
Algorithmic Trading - Real Trading
Technical requirements
EMA–Regular–Order strategy – fetching the strategy
EMA–Regular–Order strategy – real trading the strategy
EMA–Regular–Order strategy – fetching real trading logs in real time
EMA–Regular–Order strategy – fetching a real trading report – profit and loss table
EMA–Regular–Order strategy – fetching a real trading report – statistics table
MACD–Bracket–Order strategy – fetching the strategy
MACD–Bracket–Order strategy – real trading the strategy
MACD–Bracket–Order strategy – fetching real trading logs in real time
MACD–Bracket–Order strategy – fetching a real trading report – profit and loss table
MACD–Bracket–Order strategy – fetching a real trading report – statistics table
Other Books You May EnjoyChevron down iconChevron up icon
Other Books You May Enjoy
Leave a review - let other readers know what you think

Recommendations for you

Left arrow icon
LLM Engineer's Handbook
LLM Engineer's Handbook
Read more
Oct 2024522 pages
Full star icon4.9 (27)
eBook
eBook
€8.98€43.99
€54.99
Getting Started with Tableau 2018.x
Getting Started with Tableau 2018.x
Read more
Sep 2018396 pages
Full star icon4 (3)
eBook
eBook
€8.98€32.99
€41.99
Python for Algorithmic Trading Cookbook
Python for Algorithmic Trading Cookbook
Read more
Aug 2024406 pages
Full star icon4.3 (20)
eBook
eBook
€8.98€35.99
€44.99
RAG-Driven Generative AI
RAG-Driven Generative AI
Read more
Sep 2024338 pages
Full star icon4.3 (16)
eBook
eBook
€8.98€32.99
€40.99
Machine Learning with PyTorch and Scikit-Learn
Machine Learning with PyTorch and Scikit-Learn
Read more
Feb 2022774 pages
Full star icon4.4 (87)
eBook
eBook
€8.98€32.99
€41.99
€59.99
Building LLM Powered Applications
Building LLM Powered Applications
Read more
May 2024342 pages
Full star icon4.2 (21)
eBook
eBook
€8.98€29.99
€37.99
Python Machine Learning By Example
Python Machine Learning By Example
Read more
Jul 2024526 pages
Full star icon4.3 (25)
eBook
eBook
€8.98€27.99
€34.99
AI Product Manager's Handbook
AI Product Manager's Handbook
Read more
Nov 2024488 pages
eBook
eBook
€8.98€27.99
€34.99
Right arrow icon

Customer reviews

Top Reviews
Rating distribution
Full star iconFull star iconFull star iconHalf star iconEmpty star icon3.8
(10 Ratings)
5 star60%
4 star0%
3 star20%
2 star0%
1 star20%
Filter icon Filter
Top Reviews

Filter reviews by




Anil Kumar DasDec 10, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
Book delivered on time .Highly recommend this book to anyone start in the python language for trading .
Amazon Verified reviewAmazon
Ajit NairOct 05, 2022
Full star iconFull star iconFull star iconFull star iconFull star icon5
Nothing to dislike !! Highly recommend d for domain specific programming and conceptual exposition to the topic !!!
Amazon Verified reviewAmazon
jmlSep 09, 2020
Full star iconFull star iconFull star iconFull star iconFull star icon5
Overview:Python Algorithmic Trading Cookbook starts with a gentle introduction to the power of Pandas and moves logically through the process of handling online trades. The book then demonstrates the procedural flow of automated trading, very useful if you’re new to the process. “Recipes” provide deep detail about the steps and terms involved, and subsequent chapters expand on familiarizing the reader with both the Python and investing terms and concepts. A light but readable treatment of the math behind indicators like trend, volatility, and volume analysis is also included with the sections demonstrating each of these tools. Order placement and handling are covered along with recipes for technical trades such as bracketing and stop-loss and lessons on pre-testing and performing actual trades. Appendices describe account setup for the services mentioned in the text as well as some useful strategy hints and reminders.Hits:You don’t need to have a lot of prior knowledge about financial markets to get the concepts and framework presented here. The math’s presented in easily-handled chunks and the author provides references for those who want to dive in deeper. If you’re not familiar with concepts like backtesting and paper trading, they’re made clear using short, comprehensible explanations.Misses:It looks like some chapters rely on specific GUI or at least graphics packages being installed, and it would be nice if more details were available regarding those requirements. I’d also like to see some information regarding trade and account security as those topics are integral to today's trading environments.Conclusion:A solid buy if you want to get into online stock markets and need to understand algorithmic trading. It’s not a trading textbook but if you have even a minimal understanding of how trading works, you’ll get up and running fast by following the recipes and explanations in this book.
Amazon Verified reviewAmazon
Karl BatemanNov 24, 2020
Full star iconFull star iconFull star iconFull star iconFull star icon5
Great book! I'm fairly new to python, and I am able to follow the book with ease.
Amazon Verified reviewAmazon
RajDec 13, 2020
Full star iconFull star iconFull star iconFull star iconFull star icon5
I have experience with Python and Data Analysis, but no experience with algorithmic trading. I would say anyone with little programming knowledge of Python can enjoy this book as it provides coding examples for all the concepts it explores.The author has dedicated a section to explain trading strategies which I cant wait to try out in real world with my brokerage account.With over 500 pages of content and detailed codebase on GitHub, this would be a fantastic read if you are an analyst or algorithmic trading enthusiast with an understanding of financial markets and an interest in trading strategies. You should also find value as an investment professional who aims to leverage Python to make better decisions.
Amazon Verified reviewAmazon
  • Arrow left icon Previous
  • 1
  • 2
  • Arrow right icon Next

People who bought this also bought

Left arrow icon
Causal Inference and Discovery in Python
Causal Inference and Discovery in Python
Read more
May 2023466 pages
Full star icon4.5 (47)
eBook
eBook
€8.98€32.99
€40.99
Generative AI with LangChain
Generative AI with LangChain
Read more
Dec 2023376 pages
Full star icon4.1 (33)
eBook
eBook
€8.98€47.99
€59.99
Modern Generative AI with ChatGPT and OpenAI Models
Modern Generative AI with ChatGPT and OpenAI Models
Read more
May 2023286 pages
Full star icon4.1 (30)
eBook
eBook
€8.98€29.99
€37.99
Deep Learning with TensorFlow and Keras – 3rd edition
Deep Learning with TensorFlow and Keras – 3rd edition
Read more
Oct 2022698 pages
Full star icon4.5 (44)
eBook
eBook
€8.98€29.99
€37.99
Machine Learning Engineering  with Python
Machine Learning Engineering with Python
Read more
Aug 2023462 pages
Full star icon4.6 (37)
eBook
eBook
€8.98€29.99
€37.99
Right arrow icon

About the author

Profile icon Dagade
Dagade
LinkedIn iconGithub icon
Pushpak Dagade is working in the area of algorithmic trading with Python for more than 3 years. He is a co-founder and CEO of AlgoBulls, an algorithmic trading platform.
Read more
See other products by Dagade
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.

Create a Free Account To Continue Reading

Modal Close icon
OR
    First name is required.
    Last name is required.

The Password should contain at least :

  • 8 characters
  • 1 uppercase
  • 1 number
Notify me about special offers, personalized product recommendations, and learning tips By signing up for the free trial you will receive emails related to this service, you can unsubscribe at any time
By clicking ‘Create Account’, you are agreeing to ourPrivacy Policy andTerms & Conditions
Already have an account? SIGN IN

Sign in to activate your 7-day free access

Modal Close icon
OR
By redeeming the free trial you will receive emails related to this service, you can unsubscribe at any time.

[8]ページ先頭

©2009-2025 Movatter.jp