예제 #1
0
def dfFromTable(Table):
    header = Table[0]
    df = pd.DataFrame(Table[1:])
    df.columns = Table[0]
    df.index = df.apply(
        lambda row: dtu.dateParser(row['Date']) + timedelta(hours=row['Hour']),
        axis=1)
    return df[[c for c in df.columns if c != 'Date' and c != 'Hour']]
예제 #2
0
def addTransaction(portfolioId):
    data = request.get_json()
    ack = portfolioData.addTransaction(client, portfolioId,
                                       data[pc.ASSET_CODE],
                                       data[pc.ASSET_NAME],
                                       data[portfolioData.TXN_CASHFLOW],
                                       data[pc.TXN_QUANTITY],
                                       dtu.dateParser(data[pc.TXN_DATE]),
                                       data.get(pc.TXN_TYPE))
    return webio.json(ack)
예제 #3
0
def updateHistStockPrices(client, minDate=dtu.dateParser('20060401'), maxDate=None, verbose=False):
    dt = maxDate if maxDate else datetime.datetime.today() - datetime.timedelta(days=2)
    missing = []
    while dt >= minDate:
        # try catch due to holidays - remove after implementing holiday calendar
        try:
            prices = stockPricesFromBSE(dt)
            ack = updateStockPrices(client, dt, prices)
            if not ack:
                print('Failed to write db for %s'%(dt.date()))
            elif verbose:
                print("Update successful for %s"%(dt.date()))
        except Exception:
            missing.append(dt)
            print("Skipping for %s"%(dt.date()))
        dt = dtu.prevMarketClose(dt - datetime.timedelta(days=1))
    return missing
예제 #4
0
def updateHistBenchmarkPrices(client,
                              minDate=dtu.dateParser('20060401'),
                              maxDate=None,
                              verbose=False):
    dt = maxDate if maxDate else datetime.datetime.today(
    ) - datetime.timedelta(days=2)
    missing = []
    while dt >= minDate:
        try:
            valueMap = bmLevelsFromNSE(dt)
            ack = updateBMVals(client, dt, valueMap)
            if not ack:
                print('Failed to write db for %s' % (dt.date()))
            elif verbose:
                print("Update successful for %s" % (dt.date()))
        except Exception:
            missing.append(dt)
            print("Skipping for %s" % (dt.date()))
        dt = dtu.prevMarketClose(dt - datetime.timedelta(days=1))
    return missing
예제 #5
0
def updateHistFundNAV(client,
                      minDate=dtu.dateParser('20060401'),
                      maxDate=None,
                      verbose=False):
    dt = maxDate if maxDate else datetime.datetime.today(
    ) - datetime.timedelta(days=2)
    missing = []
    while dt >= minDate:
        try:
            valueMap = fundNAVFromAMFI(dt)
            ack = fundData.updateFundNAVOnDate(client, dt, valueMap)
            if not ack:
                print('Failed to write db for %s' % (dt.date()))
            elif verbose:
                print("Update successful for %s" % (dt.date()))
        except Exception:
            missing.append(dt)
            print("Skipping for %s" % (dt.date()))
        dt = dt - datetime.timedelta(days=1)
    return missing
예제 #6
0
def getFundListOnDate(navDate):
    return webio.json(fundData.fundList(client, dtu.dateParser(navDate)))
예제 #7
0
from entropy.db import dbclient
import entropy.portfolio.portfolioData as po
import entropy.portfolio.constants as pc
import entropy.fund.constants as fc
import entropy.utils.dateandtime as dtu
import datetime
import entropy.fund.fundData as fundData
from entropy.fund.fund import Fund
from entropy.portfolio.portfolio import Portfolio
import pandas as pd

client = dbclient.MClient()
date = dtu.dateParser('20150101')
fundList = fundData.fundList(client)

# adding new portfolio, if it doesn't exist
clientName = 'Warren Buffet'
if len(po.clientPortfolios(client, clientName)) == 0:
    po.addPortfolio(client, clientName, "my Life's Savings")
Id = po.clientPortfolios(client, clientName)[0][pc.PORTFOLIO_ID]

Txns = [
    ["date", "hour", "schemeCode", "cashFlow"],
    ["20160405", 5, "125494", 1e4],
    ["20160601", 7, "100356", 2e4],
    ["20160601", 13, "118991", 3e3],
    ["20160701", 7, "101042", 4e3],
    ["20160701", 11, "100356", 6e4],
    ["20160901", 14, "113566", 4e4],
    ["20160901", 15, "113566", 1e4],
    #[ "20160105",   5,      "118991",       9e4         ],
예제 #8
0
parser.add_argument('--verbose',
                    help='Print verbose logs',
                    action='store_true')
parser.add_argument('--enrich',
                    help='Enrich and overwrite fund meta data',
                    action='store_true')
parser.add_argument('--mindate',
                    help='Date until which values will be filled',
                    default=minDt.strftime('%Y%m%d'))
parser.add_argument('--maxdate',
                    help='Date before which values will be filled',
                    default=maxDt.strftime('%Y%m%d'))
args = parser.parse_args()

verbose = args.verbose
minDt = dtu.dateParser(args.mindate)
maxDt = dtu.dateParser(args.maxdate)
forceEnrich = args.enrich

print('Running dataUpdater...')
print('Using args: verbose={}, dateRange=({}, {}), forceEnrich={}'.format(\
    verbose, minDt.strftime('%Y%m%d'), maxDt.strftime('%Y%m%d'), forceEnrich))

# update meta data
failedFunds = amfiFeeds.updateFundMetaData(client, forceEnrich=forceEnrich)
# daily
amfiFeeds.updateDailyFundNAV(client)
# historical
failedFundDates = amfiFeeds.updateHistFundNAV(client,
                                              minDate=minDt,
                                              maxDate=maxDt,