コード例 #1
0
expiry4 = dt.date(2018, 8, 21)
expiry5 = dt.date(2018, 9, 21)
expiry6 = dt.date(2018, 10, 21)
expiry6 = dt.date(2018, 11, 21)
expiry6 = dt.date(2018, 12, 21)
expiries = [expiry1, expiry2, expiry3, expiry4, expiry5, expiry6]
expiries = [expiry1, expiry3, expiry5]
expiries = [expiry3]

# Define Events
event8_info = pd.read_excel('CLVS_RiskScenarios.xlsx',
                            header=[0],
                            index_col=[0, 1],
                            sheet_name='Sub_States')

event0 = IdiosyncraticVol('CLVS', .15)
event1 = SysEvt_PresElection('CLVS', .02, 'Q2_2018')
event2 = Event('CLVS', .05, 'Q2_2018', 'Q2_Earnings')
event3 = Event('CLVS', .05, 'Q3_2018', 'Q3_Earnings')
event4 = Event('CLVS', .075, 'Q3_2018', 'Investor_Day')
event5 = Event('CLVS', .1, 'Q2_2018', 'FDA_Approval')
event6 = TakeoutEvent('CLVS', 4)
event7 = Event('CLVS', Distribution(pd.read_csv('CLVS.csv')), 'Q2_2018',
               'Ph3_Data')
event8 = Event('CLVS', Distribution_MultiIndex(event8_info), 'Q3_2018',
               'Elagolix_Approval')
events = [
    event0, event1, event2, event3, event4, event5, event6, event7, event8
]
events = [event0, event6]
コード例 #2
0
import pandas as pd
import datetime as dt
from functools import reduce
from biotech_class_run_9 import get_total_mc_distribution, get_option_sheet_from_mc_distribution
from option_model.Event_Module import IdiosyncraticVol, SysEvt_PresElection, Event, TakeoutEvent
from option_model.Distribution_Module import Distribution, Distribution_MultiIndex
from paul_resources import show_mc_distributions_as_line_chart
from option_model.Option_Module import Option, OptionPriceMC
# Define Events

event8_info = pd.read_excel('CLVS_RiskScenarios.xlsx',
                            header=[0],
                            index_col=[0, 1],
                            sheet_name='Sub_States')

event0 = IdiosyncraticVol('CLVS', .05)
event1 = SysEvt_PresElection('CLVS', .02, 'Q2_2018')
event2 = Event('CLVS', .05, 'Q2_2018', 'Q2_Earnings')
event3 = Event('CLVS', .05, 'Q3_2018', 'Q3_Earnings')
event4 = Event('CLVS', .075, 'Q3_2018', 'Investor_Day')
event5 = Event('CLVS', .1, 'Q2_2018', 'FDA_Approval')
event6 = TakeoutEvent('CLVS', 1)
event7 = Event('CLVS', Distribution(pd.read_csv('CLVS.csv')), 'Q2_2018',
               'Ph3_Data')
event8 = Event('CLVS', Distribution_MultiIndex(event8_info), 'Q3_2018',
               'Elagolix_Approval')
events = [
    event0, event1, event2, event3, event4, event5, event6, event7, event8
]
#events = [event0,  event8]
events = [
コード例 #3
0
def get_vol_surface(events, expiry):
    return get_vol_surface_from_event_grouping(events, expiry)


def get_vol_surface_spline(vol_surface):
    strikes = vol_surface.index.values.tolist()
    vols = vol_surface.iloc[:, 0].values.tolist()
    return interp1d(strikes, vols, kind='cubic')


#---------------------------------I optimize for speed again below here---------------------------------------------#
EarningsDist = Earnings('CRBP', .05, 'Q2_2018').get_distribution(
    dt.date(2018, 7, 1)).mc_simulation(10**4)
IdiosyncraticVolDist = IdiosyncraticVol(
    'CRBP', .10).get_distribution(dt.date.today() +
                                  timedelta(365)).mc_simulation(10**4)


#@my_time_decorator
def get_total_mc_distribution(events,
                              expiry=None,
                              symbol=None,
                              mc_iterations=10**4):
    """Add the simulation results of individual events to return the total simulated distribution."""
    """
    events = [evt for evt in events if event_prob_by_expiry(evt.timing_descriptor, expiry) > 0]
    distributions = map(lambda evt: evt.get_distribution(expiry), events)
    mc_distributions = map(lambda dist: dist.mc_simulation(mc_iterations), distributions)
    """
コード例 #4
0
 def idio_vol(self):
     return IdiosyncraticVol(self.stock, .10)
コード例 #5
0
expiry4 = dt.date(2018, 8, 21)
expiry5 = dt.date(2018, 9, 21)
expiry6 = dt.date(2018, 10, 21)
expiry7 = dt.date(2018, 11, 21)
expiry8 = dt.date(2018, 12, 21)
expiries = [expiry1, expiry2, expiry3, expiry4, expiry5, expiry6]
expiries = [expiry1, expiry3, expiry5]
expiries = [expiry3]

# Define Events
event8_info = pd.read_excel('CLVS_RiskScenarios.xlsx',
                         header = [0],
                         index_col = [0,1],
                         sheet_name = 'Sub_States')

idio = IdiosyncraticVol('CLVS', .05)
takeout = TakeoutEvent('CLVS', 2)
pres_elec = SysEvt_PresElection('CLVS', .02)
earns_q2 = Earnings('CLVS', .05, 'Q2_2018', 'Q2_Earnings')
earns_q3 = Earnings('CLVS', .05, 'Q3_2018', 'Q3_Earnings')
earns_q4 = Earnings('CLVS', .05, 'Q4_2018', 'Q4_Earnings')
event5 = Event('CLVS', .1, 'Q2_2018', 'FDA_Approval')
data = Event('CLVS', Distribution(pd.read_csv('CLVS.csv')), 'Q2_2018', 'Ph3_Data')
elagolix = ComplexEvent('CLVS', Distribution_MultiIndex(event8_info), 'Q2_2018', 'Elagolix_Approval')
events = [idio, takeout,  earns_q2, earns_q3, earns_q4, elagolix]
#events = [takeout]
#events = [idio, elagolix]

events_bid = [event.event_bid for event in events]
events_ask = [event.event_ask for event in events]
events_high_POS = [idio, elagolix.event_high_prob_success]
コード例 #6
0
ファイル: example.py プロジェクト: easternstarlinz/Paulthon
from option_model.Event_Module import IdiosyncraticVol
import datetime as dt
from option_model.Distribution_Module import Distribution, float_to_bs_distribution

event = IdiosyncraticVol('CLVS', .1)
distribution = event.get_distribution(dt.date(2018, 5, 10))
print(distribution.mean_move, distribution.average_move, distribution.straddle)
distribution.get_histogram()

event_input_distribution = Distribution(event.event_input_distribution_df)
print(event_input_distribution.mean_move,
      event_input_distribution.average_move, event_input_distribution.straddle)

event_input_dist = event.event_input
print(event_input_dist.mean_move, event_input_dist.average_move,
      event_input_dist.straddle)

dist = float_to_bs_distribution(.5)
print("HERE", dist.mean_move, dist.average_move, dist.straddle)
コード例 #7
0
from option_model.Stock_Module import Stock
from option_model.Option_Module import get_time_to_expiry
from option_model.Event_Module import IdiosyncraticVol
from option_model.Distribution_Module import Distribution, mc_distribution_to_distribution
from CreateMC import get_total_mc_distribution_from_events_vanilla
from Optimization_Formulas import find_maximum, kelly_criterion

# Paul General Formulas
from utility.graphing import get_histogram_from_array

# Declare Expiry
expiry = dt.date(2019, 5, 15)

# Declare Events
event = Stock.elagolix
vol = IdiosyncraticVol('NBIX', .20)

# Create MC_Distribution and distribution_df for the Combined Event
df = event.event_input_distribution_df
mc_dist = get_total_mc_distribution_from_events_vanilla([event, vol],
                                                        expiry=expiry,
                                                        mc_iterations=10**5)
get_histogram_from_array(mc_dist,
                         bins=2 * 10**1 + 1,
                         title='Expected GE Distribution')

mc_distribution_to_distribution(mc_dist,
                                bins=5 * 10**1 + 1,
                                to_file=True,
                                file_name='Elagolix_Dist')
combined_dist = Distribution(pd.read_csv('Elagolix_Dist.csv'))