Skip to main content

A package for backtesting trading strategies meant for Bullscatch Securities

Project description

from bullscatch_backtest.spot_fetch_spa import get_spot_data

# Spot Data Fetch

data = get_spot_data("2024-10-25", "nifty")

print(data)

from bullscatch_backtest.expiry_list_spa import get_expiries

expiries = get_expiries("nifty", "options", "2024-01-25")

print(expiries)

##########################Single Date Option Chain Fetch################################

from bullscatch_backtest.option_chain_spa import get_option_chain

# option_chain_df = get_option_chain("date(YYYY-MM-DD)", "Expiry(YYYY_MM_DD)","nifty")

option_chain_df = get_option_chain("2025-02-28", "2025_03_06","nifty")

print(option_chain_df)

# Assuming option_chain_df is already defined

filtered_df = option_chain_df[option_chain_df['strike'] == 22450]

# Display the filtered rows

print(filtered_df)

########################## Multiple Date Option Chain Fetch For Multiple Expiry Fetch################################

from multidate_option_chain_spa import OptionDataFetcher

import time

# Define date-expiry pairs

date_expiry_pairs = [

("2019_10_01", "2019_10_03"),

("2019_10_02", "2019_10_03"),

("2019_10_03", "2019_10_03"),

("2019_10_08", "2019_10_10"),

("2019_10_15", "2019_10_17"),

("2019_10_22", "2019_10_24"),

("2019_10_29", "2019_10_31")

]

# Create fetcher instance

fetcher = OptionDataFetcher()

# Fetch data

start_time = time.time()

fetched_data = fetcher.fetch_all_data(date_expiry_pairs)

print(f"\nFetched {len(fetched_data)} records in {time.time() - start_time:.2f} seconds")

# Print results

for key, value in fetched_data.items():

print(f"{key}: {value}")

########################## Processed Option Chain ################################

from bullscatch_backtest.processed_option_chain_spa import fetch_and_process_option_chain

# Fetch and process data

final_option_chain_df = fetch_and_process_option_chain("2025-02-28", "2025_03_06", "nifty")

# Display processed DataFrame

print(final_option_chain_df)

# Example: Filter by strike price

filtered_df = final_option_chain_df[final_option_chain_df['strike'] == 22850]

print(filtered_df)

# Example: Filter by timestamp range

start_time = "2025-02-28 09:15:01"

end_time = "2025-02-28 09:24:00"

timestamp_filtered_df = filtered_df[(filtered_df['timestamp'] >= start_time) &

(filtered_df['timestamp'] <= end_time)]

print(timestamp_filtered_df.head(20))

########################## Option Chain ATM ################################

from bullscatch_backtest.processed_option_chain_spa import option_chain_atm

# Call function with desired values

filtered_df = option_chain_atm("2024-07-10", "2024_07_11", "nifty", 22400)

# Display the filtered DataFrame

print(filtered_df)

unique_strikes = sorted(filtered_df['strike'].unique())

# Display the unique strikes

print(unique_strikes)

strike_value = 22450

option_type_value = "CE"

filtered_strike_df = filtered_df[(filtered_df['strike'] == strike_value) &

(filtered_df['option_type'] == option_type_value)]

print(f"\nData for Strike = {strike_value} and Option Type = {option_type_value}:\n")

print(filtered_strike_df.head(50))

########################## Expiry List ################################

from bullscatch_backtest.expiry_list_spa import get_expiries

expiries = get_expiries("nifty", "options", "2024-03-03")

print(expiries)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bullscatch-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bullscatch-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file bullscatch-0.2.0.tar.gz.

File metadata

  • Download URL: bullscatch-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for bullscatch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0cba7e9af4257c088f3d51d31a4b9113509ff5949a7bbfce80f2a694233dd311
MD5 4c70d1c6899e2c40ebdbd0483c6624a2
BLAKE2b-256 2a461ee49fd5291d1d7d5395220a13aeaca950b42a59ecac3ab99c466de873e4

See more details on using hashes here.

File details

Details for the file bullscatch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bullscatch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for bullscatch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6dd76bb60b51e1345b2974519eaffcdd70354247b2c93ff891f3815ee4d22c2
MD5 4b507eb172563a9db2842213755e2389
BLAKE2b-256 303a77296a01483033ac5d91825c7b7f122fb388bb985cc03e37b98a81919cd6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page