A Pen by amCharts team on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from timeit import default_timer as timer | |
from numba import vectorize | |
import pandas as pd | |
@vectorize(['float32(float32, float32,float32, float32)'], target='cuda') | |
def get_length(x1, y1, x2, y2): | |
return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** (1 / 2) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compute trade-off curve. | |
MinTarget = [i for i in range(500,5000,100)] | |
risk_data = np.zeros(len(MinTarget)) | |
ret_data = np.zeros(len(MinTarget)) | |
for j in range(len(MinTarget)): | |
m.addConstr(sum(x[i]*Mu[i] for i in range(len(altcoins))) >= MinTarget[j],'BudgetConstr') | |
m.optimize() | |
Invest = m.getAttr('x',x) | |
Risk = m.objVal | |
m.remove(m.getConstrByName('BudgetConstr')) |