Exemplo n.º 1
0
def line_chart(doc, months, portfolioDate, monthlyInv, monthlyVal, Valuation,
               Investment):
    drawing = Drawing(doc.width / 2, doc.height / 2 - 80)
    data = [monthlyInv, monthlyVal]
    my_title = String(doc.width / 2 - 90,
                      doc.height / 2,
                      'Performance Chart',
                      fontSize=20)

    lc = HorizontalLineChart()
    lc.x = doc.leftMargin + 35
    lc.y = doc.bottomMargin
    lc.height = doc.height / 2 - 60
    lc.width = doc.width - 100

    lc.data = data
    lc.joinedLines = 1
    catNames = months[portfolioDate.month:]

    if portfolioDate.month > 1:
        catNames += months[:portfolioDate.month]

    lc.categoryAxis.categoryNames = catNames
    #lc.categoryAxis.labels.boxAnchor = 'autox'
    lc.valueAxis.valueMin = 0
    roundedVal = Valuation if Valuation % 10 == 0 else Valuation + Valuation % 10
    lc.valueAxis.valueMax = roundedVal
    lc.valueAxis.valueStep = int((roundedVal / 10) / 10) * 10
    lc.lines[0].strokeWidth = 2
    lc.lines[1].strokeWidth = 1.5
    lc.lines[0].strokeColor = colors.blue
    lc.lines[
        1].strokeColor = colors.green if Valuation > Investment else colors.red
    lc.valueAxis.visibleGrid = 1
    lc.valueAxis.gridStrokeColor = colors.lightgrey

    lc.lines[0].name = 'Investment Value'
    lc.lines[1].name = 'Closing Valuation'
    #lc.lineLabelFormat = '%2.0f'
    labels = ['Investment Value', 'Closing Valuation']
    lc._seriesCount = len(labels)

    drawing.add(my_title)
    drawing.add(lc)
    add_legend1(drawing, lc, labels, doc)

    return drawing
Exemplo n.º 2
0
def line_chart(doc, months, portfolioDate, monthlyInv, monthlyVal, Valuation,
               Investment):
    drawing = Drawing(doc.width / 2, doc.height / 2 - 80)
    data = [monthlyInv, monthlyVal]
    my_title = String(doc.width / 2 - 90,
                      doc.height / 2,
                      'Performance Chart',
                      fontSize=20)

    lc = HorizontalLineChart()
    lc.x = doc.leftMargin + 35
    lc.y = doc.bottomMargin
    lc.height = doc.height / 2 - 60
    lc.width = doc.width - 100

    lc.data = data
    lc.joinedLines = 1
    catNames = months[portfolioDate.month:]

    if portfolioDate.month > 1:
        catNames += months[:portfolioDate.month]

    lc.categoryAxis.categoryNames = catNames
    #lc.categoryAxis.labels.boxAnchor = 'autox'
    lc.valueAxis.valueMin = 0
    roundedVal = Valuation if Valuation % 10 == 0 else Valuation + Valuation % 10
    lc.valueAxis.valueMax = roundedVal
    lc.valueAxis.valueStep = int((roundedVal / 10) / 10) * 10
    lc.lines[0].strokeWidth = 2
    lc.lines[1].strokeWidth = 1.5
    lc.lines[0].strokeColor = colors.blue
    lc.lines[
        1].strokeColor = colors.green if Valuation > Investment else colors.red
    lc.valueAxis.visibleGrid = 1
    lc.valueAxis.gridStrokeColor = colors.lightgrey

    lc.lines[0].name = 'Investment Value'
    lc.lines[1].name = 'Closing Valuation'
    #lc.lineLabelFormat = '%2.0f'
    labels = ['Investment Value', 'Closing Valuation']
    lc._seriesCount = len(labels)

    drawing.add(my_title)
    drawing.add(lc)
    add_legend1(drawing, lc, labels, doc)

    return drawing


################### Old Function Call Segment#######################

# FI=[4531082, 4892169, 206462, 4.56, 45.94]
# Equity=[5218922,5362021.34,-62131.35,-1.19,50.36]

# Investment=225323
# Valuation=865489
# monthlyInv=[23564,5782,84,79765,3243,65799,43344,5668,43,78900,3456,7543]
# monthlyVal=[85265,578954,8656,87533,29754,264256,23244,23435,243234,5767,576854,574321]

# equityTrades=[
#     ['UBS BANK USA \n DEPOSIT ACCOUNT','IN8543975','Corporate','654','764.7','7643','764.97','245.65','9877','86','','','85.32%','1.69%']
# ]

# bondTrades=[
#     ['UBS BANK USA \n DEPOSIT ACCOUNT','IN8543975','Corporate','654','764.7','7643','764.97','245.65','9877','86','78','1/12/2021','85.32%','1.69%']
#     ,['UBS BANK USA \n DEPOSIT ACCOUNT','IN8543975','Corporate','654','764.7','7643','764.97','245.65','9877','86','78','1/12/2021','85.32%','1.69%']
#     ,['UBS BANK USA \n DEPOSIT ACCOUNT','IN8543975','Corporate','654','764.7','7643','764.97','245.65','9877','86','78','1/12/2021','85.32%','1.69%']
# ]

# #Page 5 data
# net_position=[
#         ['Total Portfolio','','','','','','$9,967,814.44','$10,648,193.73','$145,102.43','1.46%','100%','100%']
#     ]

# generatePDF(FI,Equity,Investment,Valuation,monthlyInv,monthlyVal,equityTrades,bondTrades,net_position)

################### New Function Call Segment#######################

# from helper_pdfgen import helperPdfgen , historyHelper , invAndVal

# resp = helperPdfgen()
# histdata = historyHelper()

# FI= resp['FI']
# Equity= resp['Equity']

# iv = invAndVal()
# Investment = iv['Investment']
# Valuation = iv['Valuation']
# monthlyInv = histdata['monthlyInv']
# monthlyVal = histdata['monthlyVal']
# labels = histdata['labels']

# equityTrades = resp['equityTrades']

# bondTrades= resp['bondTrades']

# URPL = Valuation - Investment
# perURPL = URPL*100 / ( Valuation )
# #Page 5 data
# net_position=[
#         ['Total Portfolio','','','','','', Investment , Valuation , URPL , perURPL ,'100%','100%']
#     ]

# generatePDF(FI,Equity,Investment,Valuation,monthlyInv,monthlyVal,equityTrades,bondTrades,net_position,labels)