Skip to content

sohhom/FyersBrokerageCalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Intraday Trading Costs Calculator

Description

TL;DR: The function calculate_costs is a helper for algorithmic traders to estimate the trading costs for NSE and BSE for stocks and options. It needs the buy price, sell price and the quantity as inputs. It produces net_PnL, total_charges, points_to_breakeven as outputs.

This is currently for Fyers brokerage charges and other transaction costs, verified against Fyers brokerage Calculator and the contract note from actual trading.

NOTE:

  1. BSE equities has not been verified.
  2. For options, the quantity has to be specified in lots. Lot size is specified in the py file.

Usage

Import the calculate_costs function, and the one or more of the dicts NSE_OPTIONS or NSE_EQUITY. Call it like so:

buy_price = 100.0
sell_price = 102.4
quantity = 40
net_pnl, total_cost, break_even_points = calculate_costs(buy_price, sell_price, quantity, NSE_EQUITY)

To see a quick demo, run

python costs_fyers.py

this should print output like so:

NTPC of type EQ at NSE : BUY ₹364.6 SELL ₹364.45 QTY 12
GROSS PnL: ₹-1.80 ; NET PnL: ₹-6.45 ; BreakEven: 0.387

SBICARD of type EQ at NSE : BUY ₹713.05 SELL ₹710.97 QTY 6
GROSS PnL: ₹-12.48 ; NET PnL: ₹-17.02 ; BreakEven: 0.756

SBILIFE of type EQ at NSE : BUY ₹1512.95 SELL ₹1511.6 QTY 3
GROSS PnL: ₹-4.05 ; NET PnL: ₹-8.87 ; BreakEven: 1.607

SIGNPOST of type EQ at NSE : BUY ₹308.0 SELL ₹307.31 QTY 10
GROSS PnL: ₹-6.90 ; NET PnL: ₹-10.17 ; BreakEven: 0.327

TATASTEEL of type EQ at NSE : BUY ₹144.04 SELL ₹143.71 QTY 20
GROSS PnL: ₹-6.60 ; NET PnL: ₹-9.66 ; BreakEven: 0.153

TATASTEEL of type EQ at NSE : BUY ₹143.85 SELL ₹143.71 QTY 20
GROSS PnL: ₹-2.80 ; NET PnL: ₹-5.85 ; BreakEven: 0.153

TORNTPOWER of type EQ at NSE : BUY ₹1526.2 SELL ₹1525.0 QTY 3
GROSS PnL: ₹-3.60 ; NET PnL: ₹-8.46 ; BreakEven: 1.621

WELSPUNLIV of type EQ at NSE : BUY ₹152.78 SELL ₹153.66 QTY 15
GROSS PnL: ₹13.20 ; NET PnL: ₹10.76 ; BreakEven: 0.163

WELSPUNLIV of type EQ at NSE : BUY ₹151.97 SELL ₹151.85 QTY 10
GROSS PnL: ₹-1.20 ; NET PnL: ₹-2.81 ; BreakEven: 0.161

********************
Overall net PnL : -58.5331

Dependencies

None.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages