Beispiel #1
0
    def _get_one_real_time_price_from_local_variable_hist(
            self, security, timeNow, tickType, freq='dummy'):
        # print('_get_one_real_time_price_from_local_variable_hist', security, timeNow, tickType)
        # Store the last value, be prepared that this function is fired twice at one timeNow
        security_no_exchange_primaryExchange = stripe_exchange_primaryExchange_from_security(
            security)
        str_security = security_no_exchange_primaryExchange.full_print()
        if (str_security, timeNow, tickType) in self._lastRealTimePrice:
            self._log.notset(
                __name__ +
                '::_get_one_real_time_price_from_local_variable_hist: str_security=%s timeNow=%s tickType=%s returnedValue=SavedValue'
                % (str_security, timeNow, tickType))
            return self._lastRealTimePrice[(str_security, timeNow, tickType)]

        ans = -1
        if tickType in [
                IBCpp.TickType.ASK, IBCpp.TickType.BID, IBCpp.TickType.LAST,
                IBCpp.TickType.OPEN, IBCpp.TickType.HIGH, IBCpp.TickType.LOW,
                IBCpp.TickType.CLOSE
        ]:
            ans = roundToMinTick(random.uniform(50, 100))
        elif tickType in [
                IBCpp.TickType.VOLUME, IBCpp.TickType.BID_SIZE,
                IBCpp.TickType.ASK_SIZE
        ]:
            ans = roundToMinTick(random.uniform(10000, 50000), 1)
        else:
            self._log.error(
                __name__ +
                '::_get_one_real_time_price_from_local_variable_hist: EXIT, do not support tickType=%s'
                % (str(tickType), ))
            exit()
        self._lastRealTimePrice[(str_security, timeNow, tickType)] = ans
        if tickType == IBCpp.TickType.CLOSE:
            self._lastRealTimePrice[(str_security, timeNow,
                                     IBCpp.TickType.ASK)] = ans
            self._lastRealTimePrice[(str_security, timeNow,
                                     IBCpp.TickType.BID)] = ans
        self._log.notset(
            __name__ +
            '::_get_one_real_time_price_from_local_variable_hist: str_security=%s timeNow=%s tickType=%s returnedValue=%s'
            % (str_security, timeNow, tickType, ans))
        return ans
Beispiel #2
0
 def provide_real_time_price(self, security, tickType):
     ans = roundToMinTick(random.uniform(50, 100))
     # print(__name__ + '::provide_real_time_price: ans=%s' % (ans,))
     self._log.notset(__name__ + '::provide_real_time_price: ans=%s' %
                      (ans, ))
     return ans
Beispiel #3
0
def simulate_commissions(execution):
    # self._log.debug(__name__ + '::simulate_commission: $0.0075 per share or $1.00')
    return roundToMinTick(max(execution.shares * 0.0075, 1.0))