Ejemplo n.º 1
0
    def create_strike_profit_chart(self, event=None):
        self.close_button.focus_force()
        self.status_var.set("Creating strike chart...")
        self.update()
        self.update_idletasks()

        def training_event(message):
            self.status_var.set(message)
            self.update()
            self.update_idletasks()

        if bool(self.shadow_expiration) and self.strike_var.get() != "":
            self.clear_plot_frame()
            fig = Figure(figsize=(10, 6))
            canvas = FigureCanvasTkAgg(fig, master=self.plot_frame)
            chart = ChartOptions()
            row = self.shadow_expiration[self.expiration_var.get()]
            strike = self.strike_var.get()
            forecast = Prediction(self.options_db,
                                  self.symbol_var.get(),
                                  row["option_expire_id"],
                                  row["expire_date"],
                                  strike,
                                  "CALL",
                                  "bid",
                                  training_event)
            last_day_predictions, next_day_predictions = forecast.calculate_predictions()

            success = chart.create_strike_profit_chart(self.options_db,
                                                       fig,
                                                       self.symbol_var.get(),
                                                       self.options_db.get_name_for_symbol(self.symbol_var.get()),
                                                       row["option_expire_id"],
                                                       strike,
                                                       row["expire_date"],
                                                       last_day_predictions, next_day_predictions,
                                                       put_call="CALL",
                                                       start_date=self.start_date,
                                                       end_date=self.end_date,
                                                       option_type='extrinsic' if self.bid_extrinsic_value.get() == 1 else 'bid')
            if success:
                self.show_figure(canvas)
                self.status_var.set("Done")
            else:
                self.status_var.set("No data available")