示例#1
0
文件: unit.py 项目: arctellion/pywind
    def offer_cashflow(self):
        """Return the bid cashflow.

        :rtype: float
        :returns: Bid cashflow or 0.0
        """
        return float(multi_level_get(self.cashflow, "offer_values.total.value", '0.0'))
示例#2
0
文件: unit.py 项目: arctellion/pywind
    def offer_volume(self):
        """Get the bid volume.

        :rtype: float
        :returns: Bid volume or 0.0
        """
        return float(multi_level_get(self.volume, "offer_values.original.total.value", '0.0'))
示例#3
0
    def offer_cashflow(self):
        """Return the bid cashflow.

        :rtype: float
        :returns: Bid cashflow or 0.0
        """
        return float(
            multi_level_get(self.cashflow, "offer_values.total.value", '0.0'))
示例#4
0
文件: unit.py 项目: arctellion/pywind
    def rate(self, which):
        """Extract the rate paid for either "bid" or "offer" from the data.

         :param which: "bid" or "offer"
         :returns: The calculated rate
         :rtype: float
        """
        if which.lower() not in ["bid", "offer"]:
            return 0.0
        if which.lower() == "bid":
            volume = multi_level_get(self.volume, "bid_values.original.total.value", '0.0')
            cash = multi_level_get(self.cashflow, "bid_values.total.value", '0.0')
        else:
            volume = multi_level_get(self.volume, "offer_values.original.total.value", '0.0')
            cash = multi_level_get(self.cashflow, "offer_values.total.value", '0.0')
        if cash == '0.0' or volume == '0.0':
            return 0.0
        return float(cash) / float(volume)
示例#5
0
    def bid_volume(self):
        """Get the bid volume.

        :rtype: float
        :returns: Bid volume or 0.0
        """
        return float(
            multi_level_get(self.volume, "bid_values.original.total.value",
                            '0.0'))
示例#6
0
def bm_unitdata(args):
    """ BMReport Unit Constraint Data
    The data can be filtered by date and or period using the --date and --period flags.

    :Example:
    To obtain data for period 5, 1st Jan 2016

    .. code-block:
    $ pywind bm_unitdata --date 2016-01-01 --period 5

    """

    if args.date is not None:
        udd = UnitData(date=args.date)
    else:
        udd = UnitData()
        print("No date supplied, getting information for yesterday, {}.\n".
              format(udd.date))

    if args.period is not None:
        udd.period = args.period

    if udd.get_data() is False:
        print("Unable to get unit data.")
        sys.exit(0)

    print("Data is for period {}, {}".format(udd.period, udd.date))
    fmt = StdoutFormatter('9s', '30s', '>10.4f', '>10s', '>10.4f', '>10s',
                          '>10.4f', '>10.4f', '>10.4f', ">10.4f")
    print("{:43s}     Bid Volume              Offer Volume           Cashflow".
          format(' '))
    print(
        fmt.titles("NGC", 'Lead', 'Original', 'Tagged', 'Original', 'Tagged',
                   'Bid', 'Offer', 'Bid Rate', 'Offer Rate'))
    for bmu in udd.data:
        print(
            fmt.row(
                bmu.id, bmu.lead, bmu.bid_volume,
                multi_level_get(bmu.volume, 'bid_values.tagged.total.value',
                                'n/a'), bmu.offer_volume,
                multi_level_get(bmu.volume, 'offer_values.tagged.total.value',
                                'n/a'), bmu.bid_cashflow, bmu.offer_cashflow,
                bmu.rate("bid"), bmu.rate("offer")))
    return udd
示例#7
0
文件: cmd.py 项目: arctellion/pywind
def bm_unitdata(args):
    """ BMReport Unit Constraint Data
    The data can be filtered by date and or period using the --date and --period flags.

    :Example:
    To obtain data for period 5, 1st Jan 2016

    .. code-block:
    $ pywind bm_unitdata --date 2016-01-01 --period 5

    """

    if args.date is not None:
        udd = UnitData(date=args.date)
    else:
        udd = UnitData()
        print("No date supplied, getting information for yesterday, {}.\n".format(udd.date))

    if args.period is not None:
        udd.period = args.period

    if udd.get_data() is False:
        print("Unable to get unit data.")
        sys.exit(0)

    print("Data is for period {}, {}".format(udd.period, udd.date))
    fmt = StdoutFormatter('9s', '30s', '>10.4f', '>10s', '>10.4f', '>10s', '>10.4f', '>10.4f', '>10.4f', ">10.4f")
    print("{:43s}     Bid Volume              Offer Volume           Cashflow".format(' '))
    print(fmt.titles("NGC", 'Lead', 'Original', 'Tagged', 'Original', 'Tagged', 'Bid', 'Offer', 'Bid Rate', 'Offer Rate'))
    for bmu in udd.data:
        print(fmt.row(bmu.id, bmu.lead,
                      bmu.bid_volume,
                      multi_level_get(bmu.volume, 'bid_values.tagged.total.value', 'n/a'),
                      bmu.offer_volume,
                      multi_level_get(bmu.volume, 'offer_values.tagged.total.value', 'n/a'),
                      bmu.bid_cashflow,
                      bmu.offer_cashflow,
                      bmu.rate("bid"),
                      bmu.rate("offer")))
    return udd
示例#8
0
    def rate(self, which):
        """Extract the rate paid for either "bid" or "offer" from the data.

         :param which: "bid" or "offer"
         :returns: The calculated rate
         :rtype: float
        """
        if which.lower() not in ["bid", "offer"]:
            return 0.0
        if which.lower() == "bid":
            volume = multi_level_get(self.volume,
                                     "bid_values.original.total.value", '0.0')
            cash = multi_level_get(self.cashflow, "bid_values.total.value",
                                   '0.0')
        else:
            volume = multi_level_get(self.volume,
                                     "offer_values.original.total.value",
                                     '0.0')
            cash = multi_level_get(self.cashflow, "offer_values.total.value",
                                   '0.0')
        if cash == '0.0' or volume == '0.0':
            return 0.0
        return float(cash) / float(volume)