Skip to content

Commit

Permalink
Update automatic-indicator.php
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMelchin authored Oct 10, 2024
1 parent afbe823 commit 8b634b4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Resources/option-indicators/automatic-indicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@
# Group the contracts into call/put pairs.
contracts_pair_sizes = chain.groupby(['expiry', 'strike']).count()['right']
paired_contracts = contracts_pair_sizes[contracts_pair_sizes == 2].index
symbols = chain[
chain['expiry'].isin(paired_contracts.levels[0]) &
chain['strike'].isin(paired_contracts.levels[1])
].reset_index().groupby(['expiry', 'strike', 'right', 'symbol']).first().index.levels[-1]
symbols = [
idx[-1] for idx in chain[
chain['expiry'].isin(paired_contracts.levels[0]) &
chain['strike'].isin(paired_contracts.levels[1])
].reset_index().groupby(['expiry', 'strike', 'right', 'symbol']).first().index
]
pairs = [(symbols[i], symbols[i+1]) for i in range(0, len(symbols), 2)]

for call, put in pairs:
Expand Down

0 comments on commit 8b634b4

Please sign in to comment.