コード例 #1
0
def generate_quote(asset_manager_id=0, asset_id=None, bid=None, ask=None):
    quote = Quote(asset_manager_id=asset_manager_id,
                  asset_id=asset_id or random_string(10),
                  bid=bid or random_decimal(),
                  ask=ask or random_decimal(),
                  quote_datetime=datetime.utcnow())
    return quote
コード例 #2
0
def generate_fund(asset_manager_id=None, asset_id=None):
    props = generate_common(asset_manager_id=asset_manager_id,
                            asset_id=asset_id)
    asset = Fund(fund_type=random.choice(['Open', 'Closed']),
                 nav=random_decimal(),
                 expense_ratio=random_decimal(),
                 net_assets=1e06 * random.randint(1, 10000),
                 **props)
    return asset
コード例 #3
0
def generate_eod_price(asset_manager_id=0,
                       asset_id=None,
                       business_date=date.today(),
                       price=None):
    eod_price = EODPrice(asset_manager_id=asset_manager_id,
                         asset_id=asset_id or random_string(10),
                         business_date=business_date,
                         price=price or random_decimal())
    return eod_price
コード例 #4
0
def generate_fx_forward(asset_manager_id=None,
                        asset_id=None,
                        settlement_date=None):
    props = generate_common(asset_manager_id=asset_manager_id,
                            asset_id=asset_id,
                            display_name=asset_id)
    asset = ForeignExchangeForward(forward_rate=random_decimal(),
                                   settlement_date=settlement_date
                                   or random_date(start_year=2017),
                                   **props)
    return asset
コード例 #5
0
def generate_fx_rate(asset_manager_id=0, asset_id=None, rate_timestamp=None, rate=None, business_date=None,
                     rate_type='EOD'):
    now = datetime.utcnow().replace(tzinfo=pytz.utc, microsecond=0)
    rate_timestamp = rate_timestamp or now
    business_date = business_date or rate_timestamp.date() if type(rate_timestamp) == datetime else rate_timestamp
    fx_rate = FXRate(asset_manager_id=asset_manager_id,
                     asset_id=asset_id or random.choice(['USDJPY', 'USDSGD', 'EURUSD']),
                     business_date=business_date,
                     rate_timestamp=rate_timestamp,
                     rate=rate or random_decimal(),
                     rate_type=rate_type)
    return fx_rate
コード例 #6
0
 def test_RandomDecimal(self):
     test_decimal = random_decimal()
     self.assertEqual(type(test_decimal), Decimal)
     self.assertGreater(test_decimal, 0)
     self.assertLess(test_decimal, 100)