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_backtester-0.2.1.tar.gz (7.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_backtester-0.2.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file bullscatch_backtester-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for bullscatch_backtester-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8e5bb2f5a0660005f3438c414553add6e6b83fd68db357a5a7f6c67934728dfb
MD5 0b4c0bb4a92b4003257ad66fb6b9e2f4
BLAKE2b-256 f8fb0c0624eb816617e8cfeebb6e554f2f76e25449e365861b3939c76fd3ac19

See more details on using hashes here.

File details

Details for the file bullscatch_backtester-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bullscatch_backtester-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 754fc1024d9da1ab6a6d94c534e7d71d28a04e48ec7b7805e7157cc2bca3168f
MD5 1e24ce552b55a0cb54f1248b5c1df5ff
BLAKE2b-256 a6b75a309c70c480a5a3e32657d9626eebe07f4131c2c0d2e137f5d1a38e157c

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