Skip to content

Instantly share code, notes, and snippets.

View eight886's full-sized avatar

william jiang eight886

  • MorningStar
  • HangZhou
View GitHub Profile
@InJeCTrL
InJeCTrL / openai_invoker.py
Created February 12, 2023 10:45
A thread-safe OpenAI api invoker which support api_key pool
import openai
import threading
import time
from collections import OrderedDict
class OpenAIInvoker:
__unblock_time = 60 * 1000
Completion = openai.Completion()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
import pandas_datareader.data as web
import numpy as np
import datetime
from scipy.optimize import minimize
TOLERANCE = 1e-10
def _allocation_risk(weights, covariances):