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.2.tar.gz (6.5 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.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bullscatch-0.2.2.tar.gz
  • Upload date:
  • Size: 6.5 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.2.tar.gz
Algorithm Hash digest
SHA256 af0e378a69b8354b381eeb60ef3ea8900fa6a4fccc02a21a3f082c04e142b2be
MD5 32332a35081b30fa62f4644b9f71687e
BLAKE2b-256 640e6f8a73079ffc2f89bfbd9931ce86b1387fe33a70b1dac3dc939b4588873a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bullscatch-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c3909c74c55d8dcfbd8338ad253c981c24f47a5969fd413b3b5c9b47106a989
MD5 4b669f44edddd5d70275001443132901
BLAKE2b-256 af807a42ad101242fd0c6a413c3d734896297f50ceb8253d24f2e192f992a6fa

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