daily update
This commit is contained in:
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='ttools',
|
name='ttools',
|
||||||
version='0.1.7',
|
version='0.1.6',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'vectorbtpro',
|
'vectorbtpro',
|
||||||
|
|||||||
@ -17,6 +17,8 @@ def create_mask_from_window(entries: Any, entry_window_opens:int, entry_window_c
|
|||||||
entry_window_closes : int
|
entry_window_closes : int
|
||||||
Number of minutes from market start to close the window.
|
Number of minutes from market start to close the window.
|
||||||
|
|
||||||
|
TODO: test with entries not covering whole main session
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
type of entries
|
type of entries
|
||||||
@ -28,9 +30,13 @@ def create_mask_from_window(entries: Any, entry_window_opens:int, entry_window_c
|
|||||||
|
|
||||||
market_hours =market_hours.tz_localize(nyse.tz)
|
market_hours =market_hours.tz_localize(nyse.tz)
|
||||||
|
|
||||||
|
# Ensure both entries and market_hours are timezone-aware and in the same timezone
|
||||||
|
if entries.index.tz is None:
|
||||||
|
entries.index = entries.index.tz_localize('America/New_York')
|
||||||
|
|
||||||
# Use merge_asof to align entries with the nearest market_open in market_hours
|
# Use merge_asof to align entries with the nearest market_open in market_hours
|
||||||
merged = pd.merge_asof(
|
merged = pd.merge_asof(
|
||||||
entries,
|
entries.to_frame(),
|
||||||
market_hours[['market_open', 'market_close']],
|
market_hours[['market_open', 'market_close']],
|
||||||
left_index=True,
|
left_index=True,
|
||||||
right_index=True,
|
right_index=True,
|
||||||
@ -48,7 +54,8 @@ def create_mask_from_window(entries: Any, entry_window_opens:int, entry_window_c
|
|||||||
# Create a boolean mask for entries that are within the window
|
# Create a boolean mask for entries that are within the window
|
||||||
window_opened = (elapsed_minutes >= entry_window_opens) & (elapsed_minutes < entry_window_closes)
|
window_opened = (elapsed_minutes >= entry_window_opens) & (elapsed_minutes < entry_window_closes)
|
||||||
|
|
||||||
return window_opened
|
# Return the mask as a series with the same index as entries
|
||||||
|
return pd.Series(window_opened.values, index=entries.index)
|
||||||
|
|
||||||
|
|
||||||
class AnchoredIndicator:
|
class AnchoredIndicator:
|
||||||
|
|||||||
Reference in New Issue
Block a user