示例#1
0
 def __init__(self):
     super().__init__()
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.tran = Transactions()
     self.load_table(self.tran.expense_transactions)
     self.show()
示例#2
0
    def loadHavelockFile(self, filename):
        f = open(filename, "r")
        raw = f.read()
        f.close()
        transactions = Transactions()

        for line in raw.split("\n"):
            transactions.addTransaction(line)

        self.loadTransactions(transactions)
示例#3
0
    def __init__(self, conf):
        self.conf = conf
        self.apiKey = self.conf.hl_api_key
        self.currentPrices = {}
        self.transactions = Transactions()
        self.portfolio = Portfolio(self.conf.epsilon)
        self.havelockBalance = None
        self.havelockBalanceAvailable = None

        # (timestamps) api calls, last 600s
        self.apiRate = []
示例#4
0
    def loadBitcoinFile(self, filename):
        f = open(filename, "r")
        raw = f.read()
        f.close()

        transactions = Transactions()

        ts = []
        for line in raw.split("\n"):
            if not line:
                continue
            b = BitcoinTransaction()
            if b.parse(line):
                ts.append(b)
        transactions.addTransactions(ts)
        
        self.loadTransactions(transactions)
示例#5
0
    def getData(self, sym):
        s = self.portfolio.symbols[sym]

        ts = s.getTimestamps()
        ret = []
        for t in ts:
            tes = s.getTransactions(end=t)
            allTrans = Transactions()
            allTrans.addTransactions(tes)

            buys = allTrans.getBuyAmount()
            sells = allTrans.getSellAmount()
            dividend = allTrans.getDividendAmount()
            try:
                val = allTrans.getShareQuantity() * self.currentPrices[sym]
            except:
                val = allTrans.getShareQuantity() * s.getMeanPrice()

            ret.append((t, val + dividend + sells - buys))

        return ret
示例#6
0
    def getActivity(self):
        # get all timestamps where something happens
        ts = self.transactions.getTimestamps()
        ret = []
        for t in ts:
            trans = self.transactions.getTransactions(end=t)
            allTrans = Transactions()
            allTrans.addTransactions(trans)

            bal = allTrans.getBalance()
            dep = allTrans.getDepositAmount()
            wit = allTrans.getWithdrawAmount()
            portfolio = Portfolio(self.conf.epsilon)
            prices = {}
            for s in allTrans.getSymbols():
                portfolio.addTransactions(allTrans.getTransactions(symbol=s),
                                          s)
                prices[s] = portfolio.symbols[s].getLastPrice()
            portfolio.setCurrentPrices(prices)
            val = portfolio.getCurrentValue()

            ret.append((t, bal + val + wit - dep))

        return ret
示例#7
0
 def __init__(self, root, user, firstweekday=0):
     self.firstweekday = firstweekday  # 0 = Monday, 6 = Sunday
     self.date_clicked = None
     self.root = root
     self.transaction = Transactions(user, self.root)
     self.transaction_dates = []
示例#8
0
 def __init__(self, conf):
     self.conf = conf
     self.apiKey = self.conf.btc_de_api_key
     self.btc2eur = 0.0
     self.eur2btc = 0.0
     self.transactions = Transactions()
示例#9
0
"""
from Strategy import *
from Transactions import *
import pandas as pd

result = pd.DataFrame()
s = []
t = []
for i in range(0, 30):
    print(round((i + 1) * 0.1, 1))
    s.append(
        Strategy(pd.read_csv('F:/小宇宙/R/History/GBPUSD60.csv'), 30, 100000,
                 -7.44, 3.37, 300000))
    s[i].setStrategyAugment((i + 1) * 0.1, 12, 26, 24)
    transactions = s[i].getTransactions()
    t.append(Transactions(transactions))
    t[i].caculateDetails()
    t[i].caculateAboutDrawDown()
    openTradesHistory = s[i].openTradesHistory
    days = t[i].days
    drawDown = t[i].drawDown
    result.at[i, 'R'] = (i + 1) * 0.1
    result.at[i, '年收益'] = t[i].netProfitPerYear
    result.at[i, '最大衰落金额'] = drawDown.describe().loc['max']['drawDown']
    result.at[i, 'MAR'] = result.at[i, '年收益'] / result.at[i, '最大衰落金额']
    result.at[i, '期望'] = t[i].expectedPayOff
    result.at[i, '最大衰落期'] = drawDown.describe().loc['max']['drawDownPeriod']
    result.at[i, '胜率'] = t[i].profitTradesRate
    result.at[i, '盈利月占比'] = len(
        t[i].profitPerMonth[t[i].profitPerMonth.profitPerMonth > 0]) / len(
            t[i].profitPerMonth)
示例#10
0
           "3 --> Cars with Owners\n"
           "4 --> Cars without Owners\n"
           "0 --> Exit\n"
           "Enter: "))
 if i == 1:
     z = 0
     answer = str(
         input(
             "\nAre you buying a first-hand or a second-hand car?\n"  # User can either buy a first or 
             "Enter: "))  # a second hand car
     if answer == "first" or answer == "first-hand":
         print("\n", "Accounts: ", Storage.Storage.User_Dic)
         print("\n", "Available Cars: ", Storage.Storage.Car_Name_List)
         x = str(input("\nWho is buying the car?\n" "Enter a name: "))
         y = int(input("\nWhich car?\n" "Enter an index number: "))
         Transactions.Transactions(x, y, z, i)
     elif answer == "second" or answer == "second-hand":
         i = 11
         print("\n", "Accounts: ", Storage.Storage.User_Dic)
         print("\n", "Owned Cars: ", Storage.Storage.Ownership_Dic)
         x = str(input("\nWho is buying the car?\n" "Enter a name: "))
         y = str(input("\nFrom whom he/she is buying?\n" "Enter a name: "))
         print(y, "'s Cars: ", Storage.Storage.Ownership_Dic[y])
         z = int(
             input("\nSelect the car you want to buy\n"
                   "Enter an index number: "))
         Transactions.Transactions(x, y, z, i)
 elif i == 2:  # User can buy options for his/her car
     print("\n", Storage.Storage.User_Dic)
     print("\n", Storage.Storage.Option_Dic)
     x = str(input("\nWho is buying an option?\n" "Enter a name: "))
示例#11
0
"""
多单swap-12.09与空单swap6.527取自2019年2月某刻数据
"""
import sys

sys.path.append("E:/TheSecondElement/Program/TheSecondElement001/")
from Strategy import *
from Transactions import *
import pandas as pd

result = pd.DataFrame()
s = Strategy(pd.read_csv('E:/TheSecondElement/History/XAUUSD60.csv'), 30, 100,
             -12.09, 6.527, 30000)
s.setStrategyAugment(1.6, 12, 26, 24, 19)
transactions = s.getTransactions()
t = Transactions(transactions)
t.caculateDetails()
t.caculateAboutDrawDown()
openTradesHistory = s.openTradesHistory
days = t.days
drawDown = t.drawDown
result.at[0, 'R'] = 1.6
result.at[0, 'lossLimit'] = 19
result.at[0, '年收益'] = t.netProfitPerYear
result.at[0, '最大衰落金额'] = drawDown.describe().loc['max']['drawDown']
result.at[0, 'MAR'] = result.at[0, '年收益'] / result.at[0, '最大衰落金额']
result.at[0, '期望'] = t.expectedPayOff
result.at[0, '最大衰落期'] = drawDown.describe().loc['max']['drawDownPeriod']
result.at[0, '胜率'] = t.profitTradesRate
result.at[0, '盈利月占比'] = len(
    t.profitPerMonth[t.profitPerMonth.profitPerMonth > 0]) / len(
示例#12
0
多单swap-12.09与空单swap6.527取自2019年2月某刻数据
"""
from Strategy import *
from Transactions import *
import pandas as pd

result = pd.DataFrame()
s = []
t = []
for i in range(9):
    print(round((i + 1) * 0.1, 1))
    s.append(
        Strategy(pd.read_csv('D:/graduate/TheSecondElement/History/XAUUSD60.csv'), 30, 100, -12.09, 6.527,
                 300000))
    s[i].setStrategyAugment(1.6, 12, 26, 24, (i + 1) * 0.1)
    t.append(Transactions(s[i].getTransactions()))
    t[i].caculateDetails()
    t[i].caculateAboutDrawDown()
    openTradesHistory = s[i].openTradesHistory
    days = t[i].days
    drawDown = t[i].drawDown
    result.at[i, 'R'] = (i + 1) * 0.1
    result.at[i, '年收益'] = t[i].netProfitPerYear
    result.at[i, '最大衰落金额'] = drawDown.describe().loc['max']['drawDown']
    result.at[i, 'MAR'] = result.at[i, '年收益'] / result.at[i, '最大衰落金额']
    result.at[i, '期望'] = t[i].expectedPayOff
    result.at[i, '最大衰落期'] = drawDown.describe().loc['max']['drawDownPeriod']
    result.at[i, '胜率'] = t[i].profitTradesRate
    result.at[i, '盈利月占比'] = len(t[i].profitPerMonth[t[i].profitPerMonth.profitPerMonth > 0]) / len(t[i].profitPerMonth)
    result.at[i, '盈利单均盈利'] = t[i].profitTradesAverageProfit
    result.at[i, '亏损单均亏损'] = t[i].lossTradesAverageLoss