app/controllers/iro/positions_controller.rb in iron_warbler-2.0.7.20 vs app/controllers/iro/positions_controller.rb in iron_warbler-2.0.7.21
- old
+ new
@@ -31,9 +31,28 @@
def edit
@position = Iro::Position.find params[:id]
authorize! :edit, @position
end
+ def refresh
+ @position = pos = Iro::Position.find params[:id]
+ authorize! :refresh, @position
+
+ ## covered call
+ out = Tda::Option.get_quote({
+ contractType: 'CALL',
+ strike: pos.inner_strike,
+ expirationDate: pos.expires_on,
+ ticker: pos.stock.ticker,
+ })
+ puts! out, 'out'
+ @position.update({
+ end_inner_price: ( out.bid + out.ask ) / 2,
+ end_inner_delta: out.delta,
+ })
+ redirect_to request.referrer || purse_path( @position.purse )
+ end
+
def roll
@position = Iro::Position.find params[:id]
authorize! :roll, @position
stock = @position.stock