async def fetch_future_with_orderbook(stock_id, fetched_futures, last_thurs,
                                      index):
    bids, asks, ltp, spot = outil.get_all_bids(stock_id, last_thurs)
    future = outil.Futures()
    future.bids = bids
    future.asks = asks
    future.ltp = ltp
    future.stock_id = stock_id
    future.spot_price = spot
    future.symbol = outil.get_future_symbol(stock_id, last_thurs)

    fetched_futures.insert(index, future)
예제 #2
0
        if debug:
            i += 1
            print("---Script executed in %s seconds ---" %
                  (time.time() - start_time) + str(i))

    except Exception as e:
        print(traceback.format_exc() + ' in Stock:' + future[nse_bse.STOCK_ID])

cs_responses.sort(key=lambda x: (-x[7]))

for cs_response in cs_responses:
    try:
        stock_id = cs_response[0].split(current_month_last_thurs_yr)[0]

        bids, asks, ltp1, spot = outil.get_all_bids(stock_id,
                                                    current_month_last_thurs)

        if all(ltp1 < i['price'] for i in asks) is False or True:

            if outil.is_instrument_liquid(bids, asks,
                                          clds_utils.future_liquidity_margin,
                                          clds_utils.min_no_of_bids_asks):
                if cs_response[1].split(current_month_last_thurs_yr)[
                        1].startswith(near_month_last_thurs_mn):
                    bids, asks, ltp2 = outil.get_all_bids(
                        stock_id, near_month_last_thurs)

                    if all(ltp2 > i['price'] for i in bids) is False or True:
                        if outil.is_instrument_liquid(
                                bids, asks, clds_utils.future_liquidity_margin,
                                clds_utils.min_no_of_bids_asks):