partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
generateColorMap
This function generates a 256 jet colormap of HTML-like hex string colors (e.g. FF88AA)
pyAudioAnalysis/audioVisualization.py
def generateColorMap(): ''' This function generates a 256 jet colormap of HTML-like hex string colors (e.g. FF88AA) ''' Map = cm.jet(np.arange(256)) stringColors = [] for i in range(Map.shape[0]): rgb = (int(255*Map[i][0]), int(255*Map[i][1]), int(255*Map[i][2])) if (sys.vers...
def generateColorMap(): ''' This function generates a 256 jet colormap of HTML-like hex string colors (e.g. FF88AA) ''' Map = cm.jet(np.arange(256)) stringColors = [] for i in range(Map.shape[0]): rgb = (int(255*Map[i][0]), int(255*Map[i][1]), int(255*Map[i][2])) if (sys.vers...
[ "This", "function", "generates", "a", "256", "jet", "colormap", "of", "HTML", "-", "like", "hex", "string", "colors", "(", "e", ".", "g", ".", "FF88AA", ")" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L14-L29
[ "def", "generateColorMap", "(", ")", ":", "Map", "=", "cm", ".", "jet", "(", "np", ".", "arange", "(", "256", ")", ")", "stringColors", "=", "[", "]", "for", "i", "in", "range", "(", "Map", ".", "shape", "[", "0", "]", ")", ":", "rgb", "=", "...
e3da991e7247492deba50648a4c7c0f41e684af4
train
levenshtein
Distance between two strings
pyAudioAnalysis/audioVisualization.py
def levenshtein(str1, s2): ''' Distance between two strings ''' N1 = len(str1) N2 = len(s2) stringRange = [range(N1 + 1)] * (N2 + 1) for i in range(N2 + 1): stringRange[i] = range(i,i + N1 + 1) for i in range(0,N2): for j in range(0,N1): if str1[j] == s2[i]: ...
def levenshtein(str1, s2): ''' Distance between two strings ''' N1 = len(str1) N2 = len(s2) stringRange = [range(N1 + 1)] * (N2 + 1) for i in range(N2 + 1): stringRange[i] = range(i,i + N1 + 1) for i in range(0,N2): for j in range(0,N1): if str1[j] == s2[i]: ...
[ "Distance", "between", "two", "strings" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L32-L52
[ "def", "levenshtein", "(", "str1", ",", "s2", ")", ":", "N1", "=", "len", "(", "str1", ")", "N2", "=", "len", "(", "s2", ")", "stringRange", "=", "[", "range", "(", "N1", "+", "1", ")", "]", "*", "(", "N2", "+", "1", ")", "for", "i", "in", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
text_list_to_colors
Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors.
pyAudioAnalysis/audioVisualization.py
def text_list_to_colors(names): ''' Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors. ''' # STEP A: compute strings distance between all combnations of strings Dnames = np.zeros( (len(names), len(names)) ) for i in range(len(names)): ...
def text_list_to_colors(names): ''' Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors. ''' # STEP A: compute strings distance between all combnations of strings Dnames = np.zeros( (len(names), len(names)) ) for i in range(len(names)): ...
[ "Generates", "a", "list", "of", "colors", "based", "on", "a", "list", "of", "names", "(", "strings", ")", ".", "Similar", "strings", "correspond", "to", "similar", "colors", "." ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L55-L74
[ "def", "text_list_to_colors", "(", "names", ")", ":", "# STEP A: compute strings distance between all combnations of strings", "Dnames", "=", "np", ".", "zeros", "(", "(", "len", "(", "names", ")", ",", "len", "(", "names", ")", ")", ")", "for", "i", "in", "ra...
e3da991e7247492deba50648a4c7c0f41e684af4
train
text_list_to_colors_simple
Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors.
pyAudioAnalysis/audioVisualization.py
def text_list_to_colors_simple(names): ''' Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors. ''' uNames = list(set(names)) uNames.sort() textToColor = [ uNames.index(n) for n in names ] textToColor = np.array(textToColor) textTo...
def text_list_to_colors_simple(names): ''' Generates a list of colors based on a list of names (strings). Similar strings correspond to similar colors. ''' uNames = list(set(names)) uNames.sort() textToColor = [ uNames.index(n) for n in names ] textToColor = np.array(textToColor) textTo...
[ "Generates", "a", "list", "of", "colors", "based", "on", "a", "list", "of", "names", "(", "strings", ")", ".", "Similar", "strings", "correspond", "to", "similar", "colors", "." ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L77-L89
[ "def", "text_list_to_colors_simple", "(", "names", ")", ":", "uNames", "=", "list", "(", "set", "(", "names", ")", ")", "uNames", ".", "sort", "(", ")", "textToColor", "=", "[", "uNames", ".", "index", "(", "n", ")", "for", "n", "in", "names", "]", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
chordialDiagram
Generates a d3js chordial diagram that illustrates similarites
pyAudioAnalysis/audioVisualization.py
def chordialDiagram(fileStr, SM, Threshold, names, namesCategories): ''' Generates a d3js chordial diagram that illustrates similarites ''' colors = text_list_to_colors_simple(namesCategories) SM2 = SM.copy() SM2 = (SM2 + SM2.T) / 2.0 for i in range(SM2.shape[0]): M = Threshold # ...
def chordialDiagram(fileStr, SM, Threshold, names, namesCategories): ''' Generates a d3js chordial diagram that illustrates similarites ''' colors = text_list_to_colors_simple(namesCategories) SM2 = SM.copy() SM2 = (SM2 + SM2.T) / 2.0 for i in range(SM2.shape[0]): M = Threshold # ...
[ "Generates", "a", "d3js", "chordial", "diagram", "that", "illustrates", "similarites" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L92-L123
[ "def", "chordialDiagram", "(", "fileStr", ",", "SM", ",", "Threshold", ",", "names", ",", "namesCategories", ")", ":", "colors", "=", "text_list_to_colors_simple", "(", "namesCategories", ")", "SM2", "=", "SM", ".", "copy", "(", ")", "SM2", "=", "(", "SM2"...
e3da991e7247492deba50648a4c7c0f41e684af4
train
visualizeFeaturesFolder
This function generates a chordial visualization for the recordings of the provided path. ARGUMENTS: - folder: path of the folder that contains the WAV files to be processed - dimReductionMethod: method used to reduce the dimension of the initial feature space before computing the similari...
pyAudioAnalysis/audioVisualization.py
def visualizeFeaturesFolder(folder, dimReductionMethod, priorKnowledge = "none"): ''' This function generates a chordial visualization for the recordings of the provided path. ARGUMENTS: - folder: path of the folder that contains the WAV files to be processed - dimReductionMethod: ...
def visualizeFeaturesFolder(folder, dimReductionMethod, priorKnowledge = "none"): ''' This function generates a chordial visualization for the recordings of the provided path. ARGUMENTS: - folder: path of the folder that contains the WAV files to be processed - dimReductionMethod: ...
[ "This", "function", "generates", "a", "chordial", "visualization", "for", "the", "recordings", "of", "the", "provided", "path", ".", "ARGUMENTS", ":", "-", "folder", ":", "path", "of", "the", "folder", "that", "contains", "the", "WAV", "files", "to", "be", ...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioVisualization.py#L126-L232
[ "def", "visualizeFeaturesFolder", "(", "folder", ",", "dimReductionMethod", ",", "priorKnowledge", "=", "\"none\"", ")", ":", "if", "dimReductionMethod", "==", "\"pca\"", ":", "allMtFeatures", ",", "wavFilesList", ",", "_", "=", "aF", ".", "dirWavFeatureExtraction",...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stZCR
Computes zero crossing rate of frame
pyAudioAnalysis/audioFeatureExtraction.py
def stZCR(frame): """Computes zero crossing rate of frame""" count = len(frame) countZ = numpy.sum(numpy.abs(numpy.diff(numpy.sign(frame)))) / 2 return (numpy.float64(countZ) / numpy.float64(count-1.0))
def stZCR(frame): """Computes zero crossing rate of frame""" count = len(frame) countZ = numpy.sum(numpy.abs(numpy.diff(numpy.sign(frame)))) / 2 return (numpy.float64(countZ) / numpy.float64(count-1.0))
[ "Computes", "zero", "crossing", "rate", "of", "frame" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L19-L23
[ "def", "stZCR", "(", "frame", ")", ":", "count", "=", "len", "(", "frame", ")", "countZ", "=", "numpy", ".", "sum", "(", "numpy", ".", "abs", "(", "numpy", ".", "diff", "(", "numpy", ".", "sign", "(", "frame", ")", ")", ")", ")", "/", "2", "r...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stEnergyEntropy
Computes entropy of energy
pyAudioAnalysis/audioFeatureExtraction.py
def stEnergyEntropy(frame, n_short_blocks=10): """Computes entropy of energy""" Eol = numpy.sum(frame ** 2) # total frame energy L = len(frame) sub_win_len = int(numpy.floor(L / n_short_blocks)) if L != sub_win_len * n_short_blocks: frame = frame[0:sub_win_len * n_short_blocks] # ...
def stEnergyEntropy(frame, n_short_blocks=10): """Computes entropy of energy""" Eol = numpy.sum(frame ** 2) # total frame energy L = len(frame) sub_win_len = int(numpy.floor(L / n_short_blocks)) if L != sub_win_len * n_short_blocks: frame = frame[0:sub_win_len * n_short_blocks] # ...
[ "Computes", "entropy", "of", "energy" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L31-L46
[ "def", "stEnergyEntropy", "(", "frame", ",", "n_short_blocks", "=", "10", ")", ":", "Eol", "=", "numpy", ".", "sum", "(", "frame", "**", "2", ")", "# total frame energy", "L", "=", "len", "(", "frame", ")", "sub_win_len", "=", "int", "(", "numpy", ".",...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stSpectralCentroidAndSpread
Computes spectral centroid of frame (given abs(FFT))
pyAudioAnalysis/audioFeatureExtraction.py
def stSpectralCentroidAndSpread(X, fs): """Computes spectral centroid of frame (given abs(FFT))""" ind = (numpy.arange(1, len(X) + 1)) * (fs/(2.0 * len(X))) Xt = X.copy() Xt = Xt / Xt.max() NUM = numpy.sum(ind * Xt) DEN = numpy.sum(Xt) + eps # Centroid: C = (NUM / DEN) # Spread: ...
def stSpectralCentroidAndSpread(X, fs): """Computes spectral centroid of frame (given abs(FFT))""" ind = (numpy.arange(1, len(X) + 1)) * (fs/(2.0 * len(X))) Xt = X.copy() Xt = Xt / Xt.max() NUM = numpy.sum(ind * Xt) DEN = numpy.sum(Xt) + eps # Centroid: C = (NUM / DEN) # Spread: ...
[ "Computes", "spectral", "centroid", "of", "frame", "(", "given", "abs", "(", "FFT", "))" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L52-L71
[ "def", "stSpectralCentroidAndSpread", "(", "X", ",", "fs", ")", ":", "ind", "=", "(", "numpy", ".", "arange", "(", "1", ",", "len", "(", "X", ")", "+", "1", ")", ")", "*", "(", "fs", "/", "(", "2.0", "*", "len", "(", "X", ")", ")", ")", "Xt...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stSpectralEntropy
Computes the spectral entropy
pyAudioAnalysis/audioFeatureExtraction.py
def stSpectralEntropy(X, n_short_blocks=10): """Computes the spectral entropy""" L = len(X) # number of frame samples Eol = numpy.sum(X ** 2) # total spectral energy sub_win_len = int(numpy.floor(L / n_short_blocks)) # length of sub-frame if L != sub_win_len * n...
def stSpectralEntropy(X, n_short_blocks=10): """Computes the spectral entropy""" L = len(X) # number of frame samples Eol = numpy.sum(X ** 2) # total spectral energy sub_win_len = int(numpy.floor(L / n_short_blocks)) # length of sub-frame if L != sub_win_len * n...
[ "Computes", "the", "spectral", "entropy" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L74-L87
[ "def", "stSpectralEntropy", "(", "X", ",", "n_short_blocks", "=", "10", ")", ":", "L", "=", "len", "(", "X", ")", "# number of frame samples", "Eol", "=", "numpy", ".", "sum", "(", "X", "**", "2", ")", "# total spectral energy", "sub_win_len", "=", "int", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stSpectralFlux
Computes the spectral flux feature of the current frame ARGUMENTS: X: the abs(fft) of the current frame X_prev: the abs(fft) of the previous frame
pyAudioAnalysis/audioFeatureExtraction.py
def stSpectralFlux(X, X_prev): """ Computes the spectral flux feature of the current frame ARGUMENTS: X: the abs(fft) of the current frame X_prev: the abs(fft) of the previous frame """ # compute the spectral flux as the sum of square distances: sumX = numpy.sum...
def stSpectralFlux(X, X_prev): """ Computes the spectral flux feature of the current frame ARGUMENTS: X: the abs(fft) of the current frame X_prev: the abs(fft) of the previous frame """ # compute the spectral flux as the sum of square distances: sumX = numpy.sum...
[ "Computes", "the", "spectral", "flux", "feature", "of", "the", "current", "frame", "ARGUMENTS", ":", "X", ":", "the", "abs", "(", "fft", ")", "of", "the", "current", "frame", "X_prev", ":", "the", "abs", "(", "fft", ")", "of", "the", "previous", "frame...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L90-L102
[ "def", "stSpectralFlux", "(", "X", ",", "X_prev", ")", ":", "# compute the spectral flux as the sum of square distances:", "sumX", "=", "numpy", ".", "sum", "(", "X", "+", "eps", ")", "sumPrevX", "=", "numpy", ".", "sum", "(", "X_prev", "+", "eps", ")", "F",...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stSpectralRollOff
Computes spectral roll-off
pyAudioAnalysis/audioFeatureExtraction.py
def stSpectralRollOff(X, c, fs): """Computes spectral roll-off""" totalEnergy = numpy.sum(X ** 2) fftLength = len(X) Thres = c*totalEnergy # Ffind the spectral rolloff as the frequency position # where the respective spectral energy is equal to c*totalEnergy CumSum = numpy.cumsum(X ** 2) + ...
def stSpectralRollOff(X, c, fs): """Computes spectral roll-off""" totalEnergy = numpy.sum(X ** 2) fftLength = len(X) Thres = c*totalEnergy # Ffind the spectral rolloff as the frequency position # where the respective spectral energy is equal to c*totalEnergy CumSum = numpy.cumsum(X ** 2) + ...
[ "Computes", "spectral", "roll", "-", "off" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L105-L118
[ "def", "stSpectralRollOff", "(", "X", ",", "c", ",", "fs", ")", ":", "totalEnergy", "=", "numpy", ".", "sum", "(", "X", "**", "2", ")", "fftLength", "=", "len", "(", "X", ")", "Thres", "=", "c", "*", "totalEnergy", "# Ffind the spectral rolloff as the fr...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stHarmonic
Computes harmonic ratio and pitch
pyAudioAnalysis/audioFeatureExtraction.py
def stHarmonic(frame, fs): """ Computes harmonic ratio and pitch """ M = numpy.round(0.016 * fs) - 1 R = numpy.correlate(frame, frame, mode='full') g = R[len(frame)-1] R = R[len(frame):-1] # estimate m0 (as the first zero crossing of R) [a, ] = numpy.nonzero(numpy.diff(numpy.sign(R...
def stHarmonic(frame, fs): """ Computes harmonic ratio and pitch """ M = numpy.round(0.016 * fs) - 1 R = numpy.correlate(frame, frame, mode='full') g = R[len(frame)-1] R = R[len(frame):-1] # estimate m0 (as the first zero crossing of R) [a, ] = numpy.nonzero(numpy.diff(numpy.sign(R...
[ "Computes", "harmonic", "ratio", "and", "pitch" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L121-L166
[ "def", "stHarmonic", "(", "frame", ",", "fs", ")", ":", "M", "=", "numpy", ".", "round", "(", "0.016", "*", "fs", ")", "-", "1", "R", "=", "numpy", ".", "correlate", "(", "frame", ",", "frame", ",", "mode", "=", "'full'", ")", "g", "=", "R", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
mfccInitFilterBanks
Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call) This function is taken from the scikits.talkbox library (MIT Licence): https://pypi.python.org/pypi/scikits.talkbox
pyAudioAnalysis/audioFeatureExtraction.py
def mfccInitFilterBanks(fs, nfft): """ Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call) This function is taken from the scikits.talkbox library (MIT Licence): https://pypi.python.org/pypi/scikits.talkbox """ ...
def mfccInitFilterBanks(fs, nfft): """ Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call) This function is taken from the scikits.talkbox library (MIT Licence): https://pypi.python.org/pypi/scikits.talkbox """ ...
[ "Computes", "the", "triangular", "filterbank", "for", "MFCC", "computation", "(", "used", "in", "the", "stFeatureExtraction", "function", "before", "the", "stMFCC", "function", "call", ")", "This", "function", "is", "taken", "from", "the", "scikits", ".", "talkb...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L169-L216
[ "def", "mfccInitFilterBanks", "(", "fs", ",", "nfft", ")", ":", "# filter bank params:", "lowfreq", "=", "133.33", "linsc", "=", "200", "/", "3.", "logsc", "=", "1.0711703", "numLinFiltTotal", "=", "13", "numLogFilt", "=", "27", "if", "fs", "<", "8000", ":...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stMFCC
Computes the MFCCs of a frame, given the fft mag ARGUMENTS: X: fft magnitude abs(FFT) fbank: filter bank (see mfccInitFilterBanks) RETURN ceps: MFCCs (13 element vector) Note: MFCC calculation is, in general, taken from the scikits.talkbox library (MI...
pyAudioAnalysis/audioFeatureExtraction.py
def stMFCC(X, fbank, n_mfcc_feats): """ Computes the MFCCs of a frame, given the fft mag ARGUMENTS: X: fft magnitude abs(FFT) fbank: filter bank (see mfccInitFilterBanks) RETURN ceps: MFCCs (13 element vector) Note: MFCC calculation is, in general, taken fr...
def stMFCC(X, fbank, n_mfcc_feats): """ Computes the MFCCs of a frame, given the fft mag ARGUMENTS: X: fft magnitude abs(FFT) fbank: filter bank (see mfccInitFilterBanks) RETURN ceps: MFCCs (13 element vector) Note: MFCC calculation is, in general, taken fr...
[ "Computes", "the", "MFCCs", "of", "a", "frame", "given", "the", "fft", "mag" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L219-L237
[ "def", "stMFCC", "(", "X", ",", "fbank", ",", "n_mfcc_feats", ")", ":", "mspec", "=", "numpy", ".", "log10", "(", "numpy", ".", "dot", "(", "X", ",", "fbank", ".", "T", ")", "+", "eps", ")", "ceps", "=", "dct", "(", "mspec", ",", "type", "=", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stChromaFeaturesInit
This function initializes the chroma matrices used in the calculation of the chroma features
pyAudioAnalysis/audioFeatureExtraction.py
def stChromaFeaturesInit(nfft, fs): """ This function initializes the chroma matrices used in the calculation of the chroma features """ freqs = numpy.array([((f + 1) * fs) / (2 * nfft) for f in range(nfft)]) Cp = 27.50 nChroma = numpy.round(12.0 * numpy.log2(freqs / Cp)).astype(int) ...
def stChromaFeaturesInit(nfft, fs): """ This function initializes the chroma matrices used in the calculation of the chroma features """ freqs = numpy.array([((f + 1) * fs) / (2 * nfft) for f in range(nfft)]) Cp = 27.50 nChroma = numpy.round(12.0 * numpy.log2(freqs / Cp)).astype(int) ...
[ "This", "function", "initializes", "the", "chroma", "matrices", "used", "in", "the", "calculation", "of", "the", "chroma", "features" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L240-L255
[ "def", "stChromaFeaturesInit", "(", "nfft", ",", "fs", ")", ":", "freqs", "=", "numpy", ".", "array", "(", "[", "(", "(", "f", "+", "1", ")", "*", "fs", ")", "/", "(", "2", "*", "nfft", ")", "for", "f", "in", "range", "(", "nfft", ")", "]", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stChromagram
Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term window size (in samples) step: the short-term win...
pyAudioAnalysis/audioFeatureExtraction.py
def stChromagram(signal, fs, win, step, PLOT=False): """ Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term...
def stChromagram(signal, fs, win, step, PLOT=False): """ Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term...
[ "Short", "-", "term", "FFT", "mag", "for", "spectogram", "estimation", ":", "Returns", ":", "a", "numpy", "array", "(", "nFFT", "x", "numOfShortTermWindows", ")", "ARGUMENTS", ":", "signal", ":", "the", "input", "signal", "samples", "fs", ":", "the", "samp...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L298-L365
[ "def", "stChromagram", "(", "signal", ",", "fs", ",", "win", ",", "step", ",", "PLOT", "=", "False", ")", ":", "win", "=", "int", "(", "win", ")", "step", "=", "int", "(", "step", ")", "signal", "=", "numpy", ".", "double", "(", "signal", ")", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
beatExtraction
This function extracts an estimate of the beat rate for a musical signal. ARGUMENTS: - st_features: a numpy array (n_feats x numOfShortTermWindows) - win_len: window size in seconds RETURNS: - BPM: estimates of beats per minute - Ratio: a confidence measure
pyAudioAnalysis/audioFeatureExtraction.py
def beatExtraction(st_features, win_len, PLOT=False): """ This function extracts an estimate of the beat rate for a musical signal. ARGUMENTS: - st_features: a numpy array (n_feats x numOfShortTermWindows) - win_len: window size in seconds RETURNS: - BPM: estimates o...
def beatExtraction(st_features, win_len, PLOT=False): """ This function extracts an estimate of the beat rate for a musical signal. ARGUMENTS: - st_features: a numpy array (n_feats x numOfShortTermWindows) - win_len: window size in seconds RETURNS: - BPM: estimates o...
[ "This", "function", "extracts", "an", "estimate", "of", "the", "beat", "rate", "for", "a", "musical", "signal", ".", "ARGUMENTS", ":", "-", "st_features", ":", "a", "numpy", "array", "(", "n_feats", "x", "numOfShortTermWindows", ")", "-", "win_len", ":", "...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L392-L450
[ "def", "beatExtraction", "(", "st_features", ",", "win_len", ",", "PLOT", "=", "False", ")", ":", "# Features that are related to the beat tracking task:", "toWatch", "=", "[", "0", ",", "1", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stSpectogram
Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term window size (in samples) step: the short-term win...
pyAudioAnalysis/audioFeatureExtraction.py
def stSpectogram(signal, fs, win, step, PLOT=False): """ Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term...
def stSpectogram(signal, fs, win, step, PLOT=False): """ Short-term FFT mag for spectogram estimation: Returns: a numpy array (nFFT x numOfShortTermWindows) ARGUMENTS: signal: the input signal samples fs: the sampling freq (in Hz) win: the short-term...
[ "Short", "-", "term", "FFT", "mag", "for", "spectogram", "estimation", ":", "Returns", ":", "a", "numpy", "array", "(", "nFFT", "x", "numOfShortTermWindows", ")", "ARGUMENTS", ":", "signal", ":", "the", "input", "signal", "samples", "fs", ":", "the", "samp...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L453-L515
[ "def", "stSpectogram", "(", "signal", ",", "fs", ",", "win", ",", "step", ",", "PLOT", "=", "False", ")", ":", "win", "=", "int", "(", "win", ")", "step", "=", "int", "(", "step", ")", "signal", "=", "numpy", ".", "double", "(", "signal", ")", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
stFeatureExtraction
This function implements the shor-term windowing process. For each short-term window a set of features is extracted. This results to a sequence of feature vectors, stored in a numpy matrix. ARGUMENTS signal: the input signal samples fs: the sampling freq (in Hz) win: ...
pyAudioAnalysis/audioFeatureExtraction.py
def stFeatureExtraction(signal, fs, win, step): """ This function implements the shor-term windowing process. For each short-term window a set of features is extracted. This results to a sequence of feature vectors, stored in a numpy matrix. ARGUMENTS signal: the input signal samples ...
def stFeatureExtraction(signal, fs, win, step): """ This function implements the shor-term windowing process. For each short-term window a set of features is extracted. This results to a sequence of feature vectors, stored in a numpy matrix. ARGUMENTS signal: the input signal samples ...
[ "This", "function", "implements", "the", "shor", "-", "term", "windowing", "process", ".", "For", "each", "short", "-", "term", "window", "a", "set", "of", "features", "is", "extracted", ".", "This", "results", "to", "a", "sequence", "of", "feature", "vect...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L521-L614
[ "def", "stFeatureExtraction", "(", "signal", ",", "fs", ",", "win", ",", "step", ")", ":", "win", "=", "int", "(", "win", ")", "step", "=", "int", "(", "step", ")", "# Signal normalization", "signal", "=", "numpy", ".", "double", "(", "signal", ")", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
mtFeatureExtraction
Mid-term feature extraction
pyAudioAnalysis/audioFeatureExtraction.py
def mtFeatureExtraction(signal, fs, mt_win, mt_step, st_win, st_step): """ Mid-term feature extraction """ mt_win_ratio = int(round(mt_win / st_step)) mt_step_ratio = int(round(mt_step / st_step)) mt_features = [] st_features, f_names = stFeatureExtraction(signal, fs, st_win, st_step) ...
def mtFeatureExtraction(signal, fs, mt_win, mt_step, st_win, st_step): """ Mid-term feature extraction """ mt_win_ratio = int(round(mt_win / st_step)) mt_step_ratio = int(round(mt_step / st_step)) mt_features = [] st_features, f_names = stFeatureExtraction(signal, fs, st_win, st_step) ...
[ "Mid", "-", "term", "feature", "extraction" ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L617-L654
[ "def", "mtFeatureExtraction", "(", "signal", ",", "fs", ",", "mt_win", ",", "mt_step", ",", "st_win", ",", "st_step", ")", ":", "mt_win_ratio", "=", "int", "(", "round", "(", "mt_win", "/", "st_step", ")", ")", "mt_step_ratio", "=", "int", "(", "round", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
dirWavFeatureExtraction
This function extracts the mid-term features of the WAVE files of a particular folder. The resulting feature vector is extracted by long-term averaging the mid-term features. Therefore ONE FEATURE VECTOR is extracted for each WAV file. ARGUMENTS: - dirName: the path of the WAVE directory ...
pyAudioAnalysis/audioFeatureExtraction.py
def dirWavFeatureExtraction(dirName, mt_win, mt_step, st_win, st_step, compute_beat=False): """ This function extracts the mid-term features of the WAVE files of a particular folder. The resulting feature vector is extracted by long-term averaging the mid-term features. Ther...
def dirWavFeatureExtraction(dirName, mt_win, mt_step, st_win, st_step, compute_beat=False): """ This function extracts the mid-term features of the WAVE files of a particular folder. The resulting feature vector is extracted by long-term averaging the mid-term features. Ther...
[ "This", "function", "extracts", "the", "mid", "-", "term", "features", "of", "the", "WAVE", "files", "of", "a", "particular", "folder", "." ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L726-L799
[ "def", "dirWavFeatureExtraction", "(", "dirName", ",", "mt_win", ",", "mt_step", ",", "st_win", ",", "st_step", ",", "compute_beat", "=", "False", ")", ":", "all_mt_feats", "=", "numpy", ".", "array", "(", "[", "]", ")", "process_times", "=", "[", "]", "...
e3da991e7247492deba50648a4c7c0f41e684af4
train
dirsWavFeatureExtraction
Same as dirWavFeatureExtraction, but instead of a single dir it takes a list of paths as input and returns a list of feature matrices. EXAMPLE: [features, classNames] = a.dirsWavFeatureExtraction(['audioData/classSegmentsRec/noise','audioData/classSegmentsRec/speech', ...
pyAudioAnalysis/audioFeatureExtraction.py
def dirsWavFeatureExtraction(dirNames, mt_win, mt_step, st_win, st_step, compute_beat=False): ''' Same as dirWavFeatureExtraction, but instead of a single dir it takes a list of paths as input and returns a list of feature matrices. EXAMPLE: [features, classNames] = a.dirsWavFeatureExtrac...
def dirsWavFeatureExtraction(dirNames, mt_win, mt_step, st_win, st_step, compute_beat=False): ''' Same as dirWavFeatureExtraction, but instead of a single dir it takes a list of paths as input and returns a list of feature matrices. EXAMPLE: [features, classNames] = a.dirsWavFeatureExtrac...
[ "Same", "as", "dirWavFeatureExtraction", "but", "instead", "of", "a", "single", "dir", "it", "takes", "a", "list", "of", "paths", "as", "input", "and", "returns", "a", "list", "of", "feature", "matrices", ".", "EXAMPLE", ":", "[", "features", "classNames", ...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L802-L831
[ "def", "dirsWavFeatureExtraction", "(", "dirNames", ",", "mt_win", ",", "mt_step", ",", "st_win", ",", "st_step", ",", "compute_beat", "=", "False", ")", ":", "# feature extraction for each class:", "features", "=", "[", "]", "classNames", "=", "[", "]", "fileNa...
e3da991e7247492deba50648a4c7c0f41e684af4
train
dirWavFeatureExtractionNoAveraging
This function extracts the mid-term features of the WAVE files of a particular folder without averaging each file. ARGUMENTS: - dirName: the path of the WAVE directory - mt_win, mt_step: mid-term window and step (in seconds) - st_win, st_step: short-term window and step (...
pyAudioAnalysis/audioFeatureExtraction.py
def dirWavFeatureExtractionNoAveraging(dirName, mt_win, mt_step, st_win, st_step): """ This function extracts the mid-term features of the WAVE files of a particular folder without averaging each file. ARGUMENTS: - dirName: the path of the WAVE directory - mt_win, mt_step: m...
def dirWavFeatureExtractionNoAveraging(dirName, mt_win, mt_step, st_win, st_step): """ This function extracts the mid-term features of the WAVE files of a particular folder without averaging each file. ARGUMENTS: - dirName: the path of the WAVE directory - mt_win, mt_step: m...
[ "This", "function", "extracts", "the", "mid", "-", "term", "features", "of", "the", "WAVE", "files", "of", "a", "particular", "folder", "without", "averaging", "each", "file", "." ]
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L834-L879
[ "def", "dirWavFeatureExtractionNoAveraging", "(", "dirName", ",", "mt_win", ",", "mt_step", ",", "st_win", ",", "st_step", ")", ":", "all_mt_feats", "=", "numpy", ".", "array", "(", "[", "]", ")", "signal_idx", "=", "numpy", ".", "array", "(", "[", "]", ...
e3da991e7247492deba50648a4c7c0f41e684af4
train
mtFeatureExtractionToFile
This function is used as a wrapper to: a) read the content of a WAV file b) perform mid-term feature extraction on that signal c) write the mid-term feature sequences to a numpy file
pyAudioAnalysis/audioFeatureExtraction.py
def mtFeatureExtractionToFile(fileName, midTermSize, midTermStep, shortTermSize, shortTermStep, outPutFile, storeStFeatures=False, storeToCSV=False, PLOT=False): """ This function is used as a wrapper to: a) read the content of a WAV file b) perform mid-term feature extract...
def mtFeatureExtractionToFile(fileName, midTermSize, midTermStep, shortTermSize, shortTermStep, outPutFile, storeStFeatures=False, storeToCSV=False, PLOT=False): """ This function is used as a wrapper to: a) read the content of a WAV file b) perform mid-term feature extract...
[ "This", "function", "is", "used", "as", "a", "wrapper", "to", ":", "a", ")", "read", "the", "content", "of", "a", "WAV", "file", "b", ")", "perform", "mid", "-", "term", "feature", "extraction", "on", "that", "signal", "c", ")", "write", "the", "mid"...
tyiannak/pyAudioAnalysis
python
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L889-L928
[ "def", "mtFeatureExtractionToFile", "(", "fileName", ",", "midTermSize", ",", "midTermStep", ",", "shortTermSize", ",", "shortTermStep", ",", "outPutFile", ",", "storeStFeatures", "=", "False", ",", "storeToCSV", "=", "False", ",", "PLOT", "=", "False", ")", ":"...
e3da991e7247492deba50648a4c7c0f41e684af4
train
BaseAccount.market_value
[float] 市值
rqalpha/model/base_account.py
def market_value(self): """ [float] 市值 """ return sum(position.market_value for position in six.itervalues(self._positions))
def market_value(self): """ [float] 市值 """ return sum(position.market_value for position in six.itervalues(self._positions))
[ "[", "float", "]", "市值" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/base_account.py#L103-L107
[ "def", "market_value", "(", "self", ")", ":", "return", "sum", "(", "position", ".", "market_value", "for", "position", "in", "six", ".", "itervalues", "(", "self", ".", "_positions", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BaseAccount.transaction_cost
[float] 总费用
rqalpha/model/base_account.py
def transaction_cost(self): """ [float] 总费用 """ return sum(position.transaction_cost for position in six.itervalues(self._positions))
def transaction_cost(self): """ [float] 总费用 """ return sum(position.transaction_cost for position in six.itervalues(self._positions))
[ "[", "float", "]", "总费用" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/base_account.py#L110-L114
[ "def", "transaction_cost", "(", "self", ")", ":", "return", "sum", "(", "position", ".", "transaction_cost", "for", "position", "in", "six", ".", "itervalues", "(", "self", ".", "_positions", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
buy_open
买入开仓。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 :param style: 下单类型, 默认是市价单。目前支持的订单类型有 :class:`~LimitOrder` 和 :cla...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py
def buy_open(id_or_ins, amount, price=None, style=None): """ 买入开仓。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 ...
def buy_open(id_or_ins, amount, price=None, style=None): """ 买入开仓。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 ...
[ "买入开仓。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L208-L231
[ "def", "buy_open", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "return", "order", "(", "id_or_ins", ",", "amount", ",", "SIDE", ".", "BUY", ",", "POSITION_EFFECT", ".", "OPEN", ",", "cal_style", "(",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
buy_close
平卖仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 :param style: 下单类型, 默认是市价单。目前支持的订单类型有 :class:`~LimitOrder` 和 :class...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py
def buy_close(id_or_ins, amount, price=None, style=None, close_today=False): """ 平卖仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要...
def buy_close(id_or_ins, amount, price=None, style=None, close_today=False): """ 平卖仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要...
[ "平卖仓" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L235-L261
[ "def", "buy_close", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ",", "close_today", "=", "False", ")", ":", "position_effect", "=", "POSITION_EFFECT", ".", "CLOSE_TODAY", "if", "close_today", "else", "POSITION_EFFECT"...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
sell_open
卖出开仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 :param style: 下单类型, 默认是市价单。目前支持的订单类型有 :class:`~LimitOrder` 和 :clas...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py
def sell_open(id_or_ins, amount, price=None, style=None): """ 卖出开仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 ...
def sell_open(id_or_ins, amount, price=None, style=None): """ 卖出开仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 ...
[ "卖出开仓" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L265-L281
[ "def", "sell_open", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "return", "order", "(", "id_or_ins", ",", "amount", ",", "SIDE", ".", "SELL", ",", "POSITION_EFFECT", ".", "OPEN", ",", "cal_style", "(...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
sell_close
平买仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 :param style: 下单类型, 默认是市价单。目前支持的订单类型有 :class:`~LimitOrder` 和 :class...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py
def sell_close(id_or_ins, amount, price=None, style=None, close_today=False): """ 平买仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主...
def sell_close(id_or_ins, amount, price=None, style=None, close_today=False): """ 平买仓 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param int amount: 下单手数 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主...
[ "平买仓" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L285-L304
[ "def", "sell_close", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ",", "close_today", "=", "False", ")", ":", "position_effect", "=", "POSITION_EFFECT", ".", "CLOSE_TODAY", "if", "close_today", "else", "POSITION_EFFECT...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
get_future_contracts
获取某一期货品种在策略当前日期的可交易合约order_book_id列表。按照到期月份,下标从小到大排列,返回列表中第一个合约对应的就是该品种的近月合约。 :param str underlying_symbol: 期货合约品种,例如沪深300股指期货为'IF' :return: list[`str`] :example: 获取某一天的主力合约代码(策略当前日期是20161201): .. code-block:: python [In] logger.info(get_future_contracts('IF')) ...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py
def get_future_contracts(underlying_symbol): """ 获取某一期货品种在策略当前日期的可交易合约order_book_id列表。按照到期月份,下标从小到大排列,返回列表中第一个合约对应的就是该品种的近月合约。 :param str underlying_symbol: 期货合约品种,例如沪深300股指期货为'IF' :return: list[`str`] :example: 获取某一天的主力合约代码(策略当前日期是20161201): .. code-block:: python [In...
def get_future_contracts(underlying_symbol): """ 获取某一期货品种在策略当前日期的可交易合约order_book_id列表。按照到期月份,下标从小到大排列,返回列表中第一个合约对应的就是该品种的近月合约。 :param str underlying_symbol: 期货合约品种,例如沪深300股指期货为'IF' :return: list[`str`] :example: 获取某一天的主力合约代码(策略当前日期是20161201): .. code-block:: python [In...
[ "获取某一期货品种在策略当前日期的可交易合约order_book_id列表。按照到期月份,下标从小到大排列,返回列表中第一个合约对应的就是该品种的近月合约。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py#L329-L349
[ "def", "get_future_contracts", "(", "underlying_symbol", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "return", "env", ".", "data_proxy", ".", "get_future_contracts", "(", "underlying_symbol", ",", "env", ".", "trading_dt", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Order.quantity
[int] 订单数量
rqalpha/model/order.py
def quantity(self): """ [int] 订单数量 """ if np.isnan(self._quantity): raise RuntimeError("Quantity of order {} is not supposed to be nan.".format(self.order_id)) return self._quantity
def quantity(self): """ [int] 订单数量 """ if np.isnan(self._quantity): raise RuntimeError("Quantity of order {} is not supposed to be nan.".format(self.order_id)) return self._quantity
[ "[", "int", "]", "订单数量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/order.py#L156-L162
[ "def", "quantity", "(", "self", ")", ":", "if", "np", ".", "isnan", "(", "self", ".", "_quantity", ")", ":", "raise", "RuntimeError", "(", "\"Quantity of order {} is not supposed to be nan.\"", ".", "format", "(", "self", ".", "order_id", ")", ")", "return", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Order.filled_quantity
[int] 订单已成交数量
rqalpha/model/order.py
def filled_quantity(self): """ [int] 订单已成交数量 """ if np.isnan(self._filled_quantity): raise RuntimeError("Filled quantity of order {} is not supposed to be nan.".format(self.order_id)) return self._filled_quantity
def filled_quantity(self): """ [int] 订单已成交数量 """ if np.isnan(self._filled_quantity): raise RuntimeError("Filled quantity of order {} is not supposed to be nan.".format(self.order_id)) return self._filled_quantity
[ "[", "int", "]", "订单已成交数量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/order.py#L200-L206
[ "def", "filled_quantity", "(", "self", ")", ":", "if", "np", ".", "isnan", "(", "self", ".", "_filled_quantity", ")", ":", "raise", "RuntimeError", "(", "\"Filled quantity of order {} is not supposed to be nan.\"", ".", "format", "(", "self", ".", "order_id", ")",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Order.frozen_price
[float] 冻结价格
rqalpha/model/order.py
def frozen_price(self): """ [float] 冻结价格 """ if np.isnan(self._frozen_price): raise RuntimeError("Frozen price of order {} is not supposed to be nan.".format(self.order_id)) return self._frozen_price
def frozen_price(self): """ [float] 冻结价格 """ if np.isnan(self._frozen_price): raise RuntimeError("Frozen price of order {} is not supposed to be nan.".format(self.order_id)) return self._frozen_price
[ "[", "float", "]", "冻结价格" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/order.py#L244-L250
[ "def", "frozen_price", "(", "self", ")", ":", "if", "np", ".", "isnan", "(", "self", ".", "_frozen_price", ")", ":", "raise", "RuntimeError", "(", "\"Frozen price of order {} is not supposed to be nan.\"", ".", "format", "(", "self", ".", "order_id", ")", ")", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
TickObject.datetime
[datetime.datetime] 当前快照数据的时间戳
rqalpha/model/tick.py
def datetime(self): """ [datetime.datetime] 当前快照数据的时间戳 """ try: dt = self._tick_dict['datetime'] except (KeyError, ValueError): return datetime.datetime.min else: if not isinstance(dt, datetime.datetime): if dt > 1000000...
def datetime(self): """ [datetime.datetime] 当前快照数据的时间戳 """ try: dt = self._tick_dict['datetime'] except (KeyError, ValueError): return datetime.datetime.min else: if not isinstance(dt, datetime.datetime): if dt > 1000000...
[ "[", "datetime", ".", "datetime", "]", "当前快照数据的时间戳" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/tick.py#L44-L58
[ "def", "datetime", "(", "self", ")", ":", "try", ":", "dt", "=", "self", ".", "_tick_dict", "[", "'datetime'", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "return", "datetime", ".", "datetime", ".", "min", "else", ":", "if", "not", "...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
StockPosition.value_percent
[float] 获得该持仓的实时市场价值在股票投资组合价值中所占比例,取值范围[0, 1]
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py
def value_percent(self): """ [float] 获得该持仓的实时市场价值在股票投资组合价值中所占比例,取值范围[0, 1] """ accounts = Environment.get_instance().portfolio.accounts if DEFAULT_ACCOUNT_TYPE.STOCK.name not in accounts: return 0 total_value = accounts[DEFAULT_ACCOUNT_TYPE.STOCK.name].total_v...
def value_percent(self): """ [float] 获得该持仓的实时市场价值在股票投资组合价值中所占比例,取值范围[0, 1] """ accounts = Environment.get_instance().portfolio.accounts if DEFAULT_ACCOUNT_TYPE.STOCK.name not in accounts: return 0 total_value = accounts[DEFAULT_ACCOUNT_TYPE.STOCK.name].total_v...
[ "[", "float", "]", "获得该持仓的实时市场价值在股票投资组合价值中所占比例,取值范围", "[", "0", "1", "]" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py#L155-L163
[ "def", "value_percent", "(", "self", ")", ":", "accounts", "=", "Environment", ".", "get_instance", "(", ")", ".", "portfolio", ".", "accounts", "if", "DEFAULT_ACCOUNT_TYPE", ".", "STOCK", ".", "name", "not", "in", "accounts", ":", "return", "0", "total_valu...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
StockPosition.is_de_listed
判断合约是否过期
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py
def is_de_listed(self): """ 判断合约是否过期 """ env = Environment.get_instance() instrument = env.get_instrument(self._order_book_id) current_date = env.trading_dt if instrument.de_listed_date is not None: if instrument.de_listed_date.date() > env.config.bas...
def is_de_listed(self): """ 判断合约是否过期 """ env = Environment.get_instance() instrument = env.get_instrument(self._order_book_id) current_date = env.trading_dt if instrument.de_listed_date is not None: if instrument.de_listed_date.date() > env.config.bas...
[ "判断合约是否过期" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py#L166-L179
[ "def", "is_de_listed", "(", "self", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "instrument", "=", "env", ".", "get_instrument", "(", "self", ".", "_order_book_id", ")", "current_date", "=", "env", ".", "trading_dt", "if", "instrument...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
StockPosition.bought_value
[已弃用]
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py
def bought_value(self): """ [已弃用] """ user_system_log.warn(_(u"[abandon] {} is no longer valid.").format('stock_position.bought_value')) return self._quantity * self._avg_price
def bought_value(self): """ [已弃用] """ user_system_log.warn(_(u"[abandon] {} is no longer valid.").format('stock_position.bought_value')) return self._quantity * self._avg_price
[ "[", "已弃用", "]" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/stock_position.py#L200-L205
[ "def", "bought_value", "(", "self", ")", ":", "user_system_log", ".", "warn", "(", "_", "(", "u\"[abandon] {} is no longer valid.\"", ")", ".", "format", "(", "'stock_position.bought_value'", ")", ")", "return", "self", ".", "_quantity", "*", "self", ".", "_avg_...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BookingPosition.trading_pnl
[float] 交易盈亏,策略在当前交易日产生的盈亏中来源于当日成交的部分
rqalpha/model/booking.py
def trading_pnl(self): """ [float] 交易盈亏,策略在当前交易日产生的盈亏中来源于当日成交的部分 """ last_price = self._data_proxy.get_last_price(self._order_book_id) return self._contract_multiplier * (self._trade_quantity * last_price - self._trade_cost)
def trading_pnl(self): """ [float] 交易盈亏,策略在当前交易日产生的盈亏中来源于当日成交的部分 """ last_price = self._data_proxy.get_last_price(self._order_book_id) return self._contract_multiplier * (self._trade_quantity * last_price - self._trade_cost)
[ "[", "float", "]", "交易盈亏,策略在当前交易日产生的盈亏中来源于当日成交的部分" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/booking.py#L223-L228
[ "def", "trading_pnl", "(", "self", ")", ":", "last_price", "=", "self", ".", "_data_proxy", ".", "get_last_price", "(", "self", ".", "_order_book_id", ")", "return", "self", ".", "_contract_multiplier", "*", "(", "self", ".", "_trade_quantity", "*", "last_pric...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BookingPosition.position_pnl
[float] 昨仓盈亏,策略在当前交易日产生的盈亏中来源于昨仓的部分
rqalpha/model/booking.py
def position_pnl(self): """ [float] 昨仓盈亏,策略在当前交易日产生的盈亏中来源于昨仓的部分 """ last_price = self._data_proxy.get_last_price(self._order_book_id) if self._direction == POSITION_DIRECTION.LONG: price_spread = last_price - self._last_price else: price_spread = s...
def position_pnl(self): """ [float] 昨仓盈亏,策略在当前交易日产生的盈亏中来源于昨仓的部分 """ last_price = self._data_proxy.get_last_price(self._order_book_id) if self._direction == POSITION_DIRECTION.LONG: price_spread = last_price - self._last_price else: price_spread = s...
[ "[", "float", "]", "昨仓盈亏,策略在当前交易日产生的盈亏中来源于昨仓的部分" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/booking.py#L231-L241
[ "def", "position_pnl", "(", "self", ")", ":", "last_price", "=", "self", ".", "_data_proxy", ".", "get_last_price", "(", "self", ".", "_order_book_id", ")", "if", "self", ".", "_direction", "==", "POSITION_DIRECTION", ".", "LONG", ":", "price_spread", "=", "...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.register_event
注册事件
rqalpha/model/portfolio.py
def register_event(self): """ 注册事件 """ event_bus = Environment.get_instance().event_bus event_bus.prepend_listener(EVENT.PRE_BEFORE_TRADING, self._pre_before_trading) event_bus.prepend_listener(EVENT.POST_SETTLEMENT, self._post_settlement)
def register_event(self): """ 注册事件 """ event_bus = Environment.get_instance().event_bus event_bus.prepend_listener(EVENT.PRE_BEFORE_TRADING, self._pre_before_trading) event_bus.prepend_listener(EVENT.POST_SETTLEMENT, self._post_settlement)
[ "注册事件" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L41-L47
[ "def", "register_event", "(", "self", ")", ":", "event_bus", "=", "Environment", ".", "get_instance", "(", ")", ".", "event_bus", "event_bus", ".", "prepend_listener", "(", "EVENT", ".", "PRE_BEFORE_TRADING", ",", "self", ".", "_pre_before_trading", ")", "event_...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.unit_net_value
[float] 实时净值
rqalpha/model/portfolio.py
def unit_net_value(self): """ [float] 实时净值 """ if self._units == 0: return np.nan return self.total_value / self._units
def unit_net_value(self): """ [float] 实时净值 """ if self._units == 0: return np.nan return self.total_value / self._units
[ "[", "float", "]", "实时净值" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L119-L125
[ "def", "unit_net_value", "(", "self", ")", ":", "if", "self", ".", "_units", "==", "0", ":", "return", "np", ".", "nan", "return", "self", ".", "total_value", "/", "self", ".", "_units" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.daily_returns
[float] 当前最新一天的日收益
rqalpha/model/portfolio.py
def daily_returns(self): """ [float] 当前最新一天的日收益 """ if self._static_unit_net_value == 0: return np.nan return 0 if self._static_unit_net_value == 0 else self.unit_net_value / self._static_unit_net_value - 1
def daily_returns(self): """ [float] 当前最新一天的日收益 """ if self._static_unit_net_value == 0: return np.nan return 0 if self._static_unit_net_value == 0 else self.unit_net_value / self._static_unit_net_value - 1
[ "[", "float", "]", "当前最新一天的日收益" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L139-L145
[ "def", "daily_returns", "(", "self", ")", ":", "if", "self", ".", "_static_unit_net_value", "==", "0", ":", "return", "np", ".", "nan", "return", "0", "if", "self", ".", "_static_unit_net_value", "==", "0", "else", "self", ".", "unit_net_value", "/", "self...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.total_value
[float]总权益
rqalpha/model/portfolio.py
def total_value(self): """ [float]总权益 """ return sum(account.total_value for account in six.itervalues(self._accounts))
def total_value(self): """ [float]总权益 """ return sum(account.total_value for account in six.itervalues(self._accounts))
[ "[", "float", "]", "总权益" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L167-L171
[ "def", "total_value", "(", "self", ")", ":", "return", "sum", "(", "account", ".", "total_value", "for", "account", "in", "six", ".", "itervalues", "(", "self", ".", "_accounts", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.positions
[dict] 持仓
rqalpha/model/portfolio.py
def positions(self): """ [dict] 持仓 """ if self._mixed_positions is None: self._mixed_positions = MixedPositions(self._accounts) return self._mixed_positions
def positions(self): """ [dict] 持仓 """ if self._mixed_positions is None: self._mixed_positions = MixedPositions(self._accounts) return self._mixed_positions
[ "[", "dict", "]", "持仓" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L181-L187
[ "def", "positions", "(", "self", ")", ":", "if", "self", ".", "_mixed_positions", "is", "None", ":", "self", ".", "_mixed_positions", "=", "MixedPositions", "(", "self", ".", "_accounts", ")", "return", "self", ".", "_mixed_positions" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.cash
[float] 可用资金
rqalpha/model/portfolio.py
def cash(self): """ [float] 可用资金 """ return sum(account.cash for account in six.itervalues(self._accounts))
def cash(self): """ [float] 可用资金 """ return sum(account.cash for account in six.itervalues(self._accounts))
[ "[", "float", "]", "可用资金" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L190-L194
[ "def", "cash", "(", "self", ")", ":", "return", "sum", "(", "account", ".", "cash", "for", "account", "in", "six", ".", "itervalues", "(", "self", ".", "_accounts", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Portfolio.market_value
[float] 市值
rqalpha/model/portfolio.py
def market_value(self): """ [float] 市值 """ return sum(account.market_value for account in six.itervalues(self._accounts))
def market_value(self): """ [float] 市值 """ return sum(account.market_value for account in six.itervalues(self._accounts))
[ "[", "float", "]", "市值" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/portfolio.py#L205-L209
[ "def", "market_value", "(", "self", ")", ":", "return", "sum", "(", "account", ".", "market_value", "for", "account", "in", "six", ".", "itervalues", "(", "self", ".", "_accounts", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.buy_holding_pnl
[float] 买方向当日持仓盈亏
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def buy_holding_pnl(self): """ [float] 买方向当日持仓盈亏 """ return (self.last_price - self.buy_avg_holding_price) * self.buy_quantity * self.contract_multiplier
def buy_holding_pnl(self): """ [float] 买方向当日持仓盈亏 """ return (self.last_price - self.buy_avg_holding_price) * self.buy_quantity * self.contract_multiplier
[ "[", "float", "]", "买方向当日持仓盈亏" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L107-L111
[ "def", "buy_holding_pnl", "(", "self", ")", ":", "return", "(", "self", ".", "last_price", "-", "self", ".", "buy_avg_holding_price", ")", "*", "self", ".", "buy_quantity", "*", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.sell_holding_pnl
[float] 卖方向当日持仓盈亏
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def sell_holding_pnl(self): """ [float] 卖方向当日持仓盈亏 """ return (self.sell_avg_holding_price - self.last_price) * self.sell_quantity * self.contract_multiplier
def sell_holding_pnl(self): """ [float] 卖方向当日持仓盈亏 """ return (self.sell_avg_holding_price - self.last_price) * self.sell_quantity * self.contract_multiplier
[ "[", "float", "]", "卖方向当日持仓盈亏" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L114-L118
[ "def", "sell_holding_pnl", "(", "self", ")", ":", "return", "(", "self", ".", "sell_avg_holding_price", "-", "self", ".", "last_price", ")", "*", "self", ".", "sell_quantity", "*", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.buy_pnl
[float] 买方向累计盈亏
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def buy_pnl(self): """ [float] 买方向累计盈亏 """ return (self.last_price - self._buy_avg_open_price) * self.buy_quantity * self.contract_multiplier
def buy_pnl(self): """ [float] 买方向累计盈亏 """ return (self.last_price - self._buy_avg_open_price) * self.buy_quantity * self.contract_multiplier
[ "[", "float", "]", "买方向累计盈亏" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L170-L174
[ "def", "buy_pnl", "(", "self", ")", ":", "return", "(", "self", ".", "last_price", "-", "self", ".", "_buy_avg_open_price", ")", "*", "self", ".", "buy_quantity", "*", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.sell_pnl
[float] 卖方向累计盈亏
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def sell_pnl(self): """ [float] 卖方向累计盈亏 """ return (self._sell_avg_open_price - self.last_price) * self.sell_quantity * self.contract_multiplier
def sell_pnl(self): """ [float] 卖方向累计盈亏 """ return (self._sell_avg_open_price - self.last_price) * self.sell_quantity * self.contract_multiplier
[ "[", "float", "]", "卖方向累计盈亏" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L177-L181
[ "def", "sell_pnl", "(", "self", ")", ":", "return", "(", "self", ".", "_sell_avg_open_price", "-", "self", ".", "last_price", ")", "*", "self", ".", "sell_quantity", "*", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.buy_open_order_quantity
[int] 买方向挂单量
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def buy_open_order_quantity(self): """ [int] 买方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.BUY and order.position_effect == POSITION_EFFECT.OPEN)
def buy_open_order_quantity(self): """ [int] 买方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.BUY and order.position_effect == POSITION_EFFECT.OPEN)
[ "[", "int", "]", "买方向挂单量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L192-L197
[ "def", "buy_open_order_quantity", "(", "self", ")", ":", "return", "sum", "(", "order", ".", "unfilled_quantity", "for", "order", "in", "self", ".", "open_orders", "if", "order", ".", "side", "==", "SIDE", ".", "BUY", "and", "order", ".", "position_effect", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.sell_open_order_quantity
[int] 卖方向挂单量
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def sell_open_order_quantity(self): """ [int] 卖方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.SELL and order.position_effect == POSITION_EFFECT.OPEN)
def sell_open_order_quantity(self): """ [int] 卖方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.SELL and order.position_effect == POSITION_EFFECT.OPEN)
[ "[", "int", "]", "卖方向挂单量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L200-L205
[ "def", "sell_open_order_quantity", "(", "self", ")", ":", "return", "sum", "(", "order", ".", "unfilled_quantity", "for", "order", "in", "self", ".", "open_orders", "if", "order", ".", "side", "==", "SIDE", ".", "SELL", "and", "order", ".", "position_effect"...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.buy_close_order_quantity
[int] 买方向挂单量
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def buy_close_order_quantity(self): """ [int] 买方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.BUY and order.position_effect in [POSITION_EFFECT.CLOSE, POSITION_EFFECT.CLOSE_TODAY])
def buy_close_order_quantity(self): """ [int] 买方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.BUY and order.position_effect in [POSITION_EFFECT.CLOSE, POSITION_EFFECT.CLOSE_TODAY])
[ "[", "int", "]", "买方向挂单量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L208-L213
[ "def", "buy_close_order_quantity", "(", "self", ")", ":", "return", "sum", "(", "order", ".", "unfilled_quantity", "for", "order", "in", "self", ".", "open_orders", "if", "order", ".", "side", "==", "SIDE", ".", "BUY", "and", "order", ".", "position_effect",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.sell_close_order_quantity
[int] 卖方向挂单量
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def sell_close_order_quantity(self): """ [int] 卖方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.SELL and order.position_effect in [POSITION_EFFECT.CLOSE, POSITION_EFFECT.CLOSE_TODAY])
def sell_close_order_quantity(self): """ [int] 卖方向挂单量 """ return sum(order.unfilled_quantity for order in self.open_orders if order.side == SIDE.SELL and order.position_effect in [POSITION_EFFECT.CLOSE, POSITION_EFFECT.CLOSE_TODAY])
[ "[", "int", "]", "卖方向挂单量" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L216-L221
[ "def", "sell_close_order_quantity", "(", "self", ")", ":", "return", "sum", "(", "order", ".", "unfilled_quantity", "for", "order", "in", "self", ".", "open_orders", "if", "order", ".", "side", "==", "SIDE", ".", "SELL", "and", "order", ".", "position_effect...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.buy_avg_holding_price
[float] 买方向持仓均价
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def buy_avg_holding_price(self): """ [float] 买方向持仓均价 """ return 0 if self.buy_quantity == 0 else self._buy_holding_cost / self.buy_quantity / self.contract_multiplier
def buy_avg_holding_price(self): """ [float] 买方向持仓均价 """ return 0 if self.buy_quantity == 0 else self._buy_holding_cost / self.buy_quantity / self.contract_multiplier
[ "[", "float", "]", "买方向持仓均价" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L322-L326
[ "def", "buy_avg_holding_price", "(", "self", ")", ":", "return", "0", "if", "self", ".", "buy_quantity", "==", "0", "else", "self", ".", "_buy_holding_cost", "/", "self", ".", "buy_quantity", "/", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.sell_avg_holding_price
[float] 卖方向持仓均价
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def sell_avg_holding_price(self): """ [float] 卖方向持仓均价 """ return 0 if self.sell_quantity == 0 else self._sell_holding_cost / self.sell_quantity / self.contract_multiplier
def sell_avg_holding_price(self): """ [float] 卖方向持仓均价 """ return 0 if self.sell_quantity == 0 else self._sell_holding_cost / self.sell_quantity / self.contract_multiplier
[ "[", "float", "]", "卖方向持仓均价" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L329-L333
[ "def", "sell_avg_holding_price", "(", "self", ")", ":", "return", "0", "if", "self", ".", "sell_quantity", "==", "0", "else", "self", ".", "_sell_holding_cost", "/", "self", ".", "sell_quantity", "/", "self", ".", "contract_multiplier" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.is_de_listed
判断合约是否过期
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def is_de_listed(self): """ 判断合约是否过期 """ instrument = Environment.get_instance().get_instrument(self._order_book_id) current_date = Environment.get_instance().trading_dt if instrument.de_listed_date is not None and current_date >= instrument.de_listed_date: re...
def is_de_listed(self): """ 判断合约是否过期 """ instrument = Environment.get_instance().get_instrument(self._order_book_id) current_date = Environment.get_instance().trading_dt if instrument.de_listed_date is not None and current_date >= instrument.de_listed_date: re...
[ "判断合约是否过期" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L372-L380
[ "def", "is_de_listed", "(", "self", ")", ":", "instrument", "=", "Environment", ".", "get_instance", "(", ")", ".", "get_instrument", "(", "self", ".", "_order_book_id", ")", "current_date", "=", "Environment", ".", "get_instance", "(", ")", ".", "trading_dt",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition.apply_trade
应用成交,并计算交易产生的现金变动。 开仓: delta_cash = -1 * margin = -1 * quantity * contract_multiplier * price * margin_rate 平仓: delta_cash = old_margin - margin + delta_realized_pnl = (sum of (cost_price * quantity) of closed trade) * contract_multiplier * margin_rate +...
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def apply_trade(self, trade): """ 应用成交,并计算交易产生的现金变动。 开仓: delta_cash = -1 * margin = -1 * quantity * contract_multiplier * price * margin_rate 平仓: delta_cash = old_margin - margin + delta_realized_pnl = (sum of (cost_price * quantity) of c...
def apply_trade(self, trade): """ 应用成交,并计算交易产生的现金变动。 开仓: delta_cash = -1 * margin = -1 * quantity * contract_multiplier * price * margin_rate 平仓: delta_cash = old_margin - margin + delta_realized_pnl = (sum of (cost_price * quantity) of c...
[ "应用成交,并计算交易产生的现金变动。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L411-L455
[ "def", "apply_trade", "(", "self", ",", "trade", ")", ":", "# close_trade: delta_cash = old_margin - margin + delta_realized_pnl", "trade_quantity", "=", "trade", ".", "last_quantity", "if", "trade", ".", "side", "==", "SIDE", ".", "BUY", ":", "if", "trade", ".", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
FuturePosition._close_holding
应用平仓,并计算平仓盈亏 买平: delta_realized_pnl = sum of ((trade_price - cost_price)* quantity) of closed trades * contract_multiplier 卖平: delta_realized_pnl = sum of ((cost_price - trade_price)* quantity) of closed trades * contract_multiplier :param trade: rqalpha.model.trade.Trade ...
rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py
def _close_holding(self, trade): """ 应用平仓,并计算平仓盈亏 买平: delta_realized_pnl = sum of ((trade_price - cost_price)* quantity) of closed trades * contract_multiplier 卖平: delta_realized_pnl = sum of ((cost_price - trade_price)* quantity) of closed trades * contract_multiplier ...
def _close_holding(self, trade): """ 应用平仓,并计算平仓盈亏 买平: delta_realized_pnl = sum of ((trade_price - cost_price)* quantity) of closed trades * contract_multiplier 卖平: delta_realized_pnl = sum of ((cost_price - trade_price)* quantity) of closed trades * contract_multiplier ...
[ "应用平仓,并计算平仓盈亏" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/position_model/future_position.py#L457-L520
[ "def", "_close_holding", "(", "self", ",", "trade", ")", ":", "left_quantity", "=", "trade", ".", "last_quantity", "delta", "=", "0", "if", "trade", ".", "side", "==", "SIDE", ".", "BUY", ":", "# 先平昨仓", "if", "trade", ".", "position_effect", "==", "POSIT...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.sector_code
[str] 板块缩写代码,全球通用标准定义(股票专用)
rqalpha/model/instrument.py
def sector_code(self): """ [str] 板块缩写代码,全球通用标准定义(股票专用) """ try: return self.__dict__["sector_code"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'sector_code' ".format(self.order_book_i...
def sector_code(self): """ [str] 板块缩写代码,全球通用标准定义(股票专用) """ try: return self.__dict__["sector_code"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'sector_code' ".format(self.order_book_i...
[ "[", "str", "]", "板块缩写代码,全球通用标准定义(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L116-L125
[ "def", "sector_code", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"sector_code\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'sector_...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.sector_code_name
[str] 以当地语言为标准的板块代码名(股票专用)
rqalpha/model/instrument.py
def sector_code_name(self): """ [str] 以当地语言为标准的板块代码名(股票专用) """ try: return self.__dict__["sector_code_name"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'sector_code_name' ".format(sel...
def sector_code_name(self): """ [str] 以当地语言为标准的板块代码名(股票专用) """ try: return self.__dict__["sector_code_name"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'sector_code_name' ".format(sel...
[ "[", "str", "]", "以当地语言为标准的板块代码名(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L128-L137
[ "def", "sector_code_name", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"sector_code_name\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribut...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.industry_code
[str] 国民经济行业分类代码,具体可参考“Industry列表” (股票专用)
rqalpha/model/instrument.py
def industry_code(self): """ [str] 国民经济行业分类代码,具体可参考“Industry列表” (股票专用) """ try: return self.__dict__["industry_code"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'industry_code' ".form...
def industry_code(self): """ [str] 国民经济行业分类代码,具体可参考“Industry列表” (股票专用) """ try: return self.__dict__["industry_code"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'industry_code' ".form...
[ "[", "str", "]", "国民经济行业分类代码,具体可参考“Industry列表”", "(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L140-L149
[ "def", "industry_code", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"industry_code\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'ind...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.industry_name
[str] 国民经济行业分类名称(股票专用)
rqalpha/model/instrument.py
def industry_name(self): """ [str] 国民经济行业分类名称(股票专用) """ try: return self.__dict__["industry_name"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'industry_name' ".format(self.order_book_...
def industry_name(self): """ [str] 国民经济行业分类名称(股票专用) """ try: return self.__dict__["industry_name"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'industry_name' ".format(self.order_book_...
[ "[", "str", "]", "国民经济行业分类名称(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L152-L161
[ "def", "industry_name", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"industry_name\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'ind...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.concept_names
[str] 概念股分类,例如:’铁路基建’,’基金重仓’等(股票专用)
rqalpha/model/instrument.py
def concept_names(self): """ [str] 概念股分类,例如:’铁路基建’,’基金重仓’等(股票专用) """ try: return self.__dict__["concept_names"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'concept_names' ".format(sel...
def concept_names(self): """ [str] 概念股分类,例如:’铁路基建’,’基金重仓’等(股票专用) """ try: return self.__dict__["concept_names"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'concept_names' ".format(sel...
[ "[", "str", "]", "概念股分类,例如:’铁路基建’,’基金重仓’等(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L164-L173
[ "def", "concept_names", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"concept_names\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'con...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.board_type
[str] 板块类别,’MainBoard’ - 主板,’GEM’ - 创业板(股票专用)
rqalpha/model/instrument.py
def board_type(self): """ [str] 板块类别,’MainBoard’ - 主板,’GEM’ - 创业板(股票专用) """ try: return self.__dict__["board_type"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'board_type' ".format(se...
def board_type(self): """ [str] 板块类别,’MainBoard’ - 主板,’GEM’ - 创业板(股票专用) """ try: return self.__dict__["board_type"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'board_type' ".format(se...
[ "[", "str", "]", "板块类别,’MainBoard’", "-", "主板", "’GEM’", "-", "创业板(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L176-L185
[ "def", "board_type", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"board_type\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'board_typ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.status
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市, ‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
rqalpha/model/instrument.py
def status(self): """ [str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市, ‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用) """ try: return self.__dict__["status"] except (KeyError, ValueError): raise AttributeError( ...
def status(self): """ [str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市, ‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用) """ try: return self.__dict__["status"] except (KeyError, ValueError): raise AttributeError( ...
[ "[", "str", "]", "合约状态。’Active’", "-", "正常上市", "‘Delisted’", "-", "终止上市", "‘TemporarySuspended’", "-", "暂停上市", "‘PreIPO’", "-", "发行配售期间", "‘FailIPO’", "-", "发行失败(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L188-L198
[ "def", "status", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"status\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'status' \"", "....
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.special_type
[str] 特别处理状态。’Normal’ - 正常上市, ‘ST’ - ST处理, ‘StarST’ - *ST代表该股票正在接受退市警告, ‘PT’ - 代表该股票连续3年收入为负,将被暂停交易, ‘Other’ - 其他(股票专用)
rqalpha/model/instrument.py
def special_type(self): """ [str] 特别处理状态。’Normal’ - 正常上市, ‘ST’ - ST处理, ‘StarST’ - *ST代表该股票正在接受退市警告, ‘PT’ - 代表该股票连续3年收入为负,将被暂停交易, ‘Other’ - 其他(股票专用) """ try: return self.__dict__["special_type"] except (KeyError, ValueError): raise AttributeError( ...
def special_type(self): """ [str] 特别处理状态。’Normal’ - 正常上市, ‘ST’ - ST处理, ‘StarST’ - *ST代表该股票正在接受退市警告, ‘PT’ - 代表该股票连续3年收入为负,将被暂停交易, ‘Other’ - 其他(股票专用) """ try: return self.__dict__["special_type"] except (KeyError, ValueError): raise AttributeError( ...
[ "[", "str", "]", "特别处理状态。’Normal’", "-", "正常上市", "‘ST’", "-", "ST处理", "‘StarST’", "-", "*", "ST代表该股票正在接受退市警告", "‘PT’", "-", "代表该股票连续3年收入为负,将被暂停交易", "‘Other’", "-", "其他(股票专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L201-L211
[ "def", "special_type", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"special_type\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'speci...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.contract_multiplier
[float] 合约乘数,例如沪深300股指期货的乘数为300.0(期货专用)
rqalpha/model/instrument.py
def contract_multiplier(self): """ [float] 合约乘数,例如沪深300股指期货的乘数为300.0(期货专用) """ try: return self.__dict__["contract_multiplier"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'contract_mu...
def contract_multiplier(self): """ [float] 合约乘数,例如沪深300股指期货的乘数为300.0(期货专用) """ try: return self.__dict__["contract_multiplier"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'contract_mu...
[ "[", "float", "]", "合约乘数,例如沪深300股指期货的乘数为300", ".", "0(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L214-L223
[ "def", "contract_multiplier", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"contract_multiplier\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no at...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.margin_rate
[float] 合约最低保证金率(期货专用)
rqalpha/model/instrument.py
def margin_rate(self): """ [float] 合约最低保证金率(期货专用) """ try: return self.__dict__["margin_rate"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'margin_rate' ".format(self.order_book_id) ...
def margin_rate(self): """ [float] 合约最低保证金率(期货专用) """ try: return self.__dict__["margin_rate"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'margin_rate' ".format(self.order_book_id) ...
[ "[", "float", "]", "合约最低保证金率(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L226-L235
[ "def", "margin_rate", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"margin_rate\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'margin_...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.underlying_order_book_id
[str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用)
rqalpha/model/instrument.py
def underlying_order_book_id(self): """ [str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用) """ try: return self.__dict__["underlying_order_book_id"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={})...
def underlying_order_book_id(self): """ [str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用) """ try: return self.__dict__["underlying_order_book_id"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={})...
[ "[", "str", "]", "合约标的代码,目前除股指期货", "(", "IH", "IF", "IC", ")", "之外的期货合约,这一字段全部为’null’(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L238-L247
[ "def", "underlying_order_book_id", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"underlying_order_book_id\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={})...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.underlying_symbol
[str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用)
rqalpha/model/instrument.py
def underlying_symbol(self): """ [str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用) """ try: return self.__dict__["underlying_symbol"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attrib...
def underlying_symbol(self): """ [str] 合约标的代码,目前除股指期货(IH, IF, IC)之外的期货合约,这一字段全部为’null’(期货专用) """ try: return self.__dict__["underlying_symbol"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attrib...
[ "[", "str", "]", "合约标的代码,目前除股指期货", "(", "IH", "IF", "IC", ")", "之外的期货合约,这一字段全部为’null’(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L250-L259
[ "def", "underlying_symbol", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"underlying_symbol\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attrib...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.maturity_date
[datetime] 期货到期日。主力连续合约与指数连续合约都为 datetime(2999, 12, 31)(期货专用)
rqalpha/model/instrument.py
def maturity_date(self): """ [datetime] 期货到期日。主力连续合约与指数连续合约都为 datetime(2999, 12, 31)(期货专用) """ try: return self.__dict__["maturity_date"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'm...
def maturity_date(self): """ [datetime] 期货到期日。主力连续合约与指数连续合约都为 datetime(2999, 12, 31)(期货专用) """ try: return self.__dict__["maturity_date"] except (KeyError, ValueError): raise AttributeError( "Instrument(order_book_id={}) has no attribute 'm...
[ "[", "datetime", "]", "期货到期日。主力连续合约与指数连续合约都为", "datetime", "(", "2999", "12", "31", ")", "(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L262-L271
[ "def", "maturity_date", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"maturity_date\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'mat...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.settlement_method
[str] 交割方式,’CashSettlementRequired’ - 现金交割, ‘PhysicalSettlementRequired’ - 实物交割(期货专用)
rqalpha/model/instrument.py
def settlement_method(self): """ [str] 交割方式,’CashSettlementRequired’ - 现金交割, ‘PhysicalSettlementRequired’ - 实物交割(期货专用) """ try: return self.__dict__["settlement_method"] except (KeyError, ValueError): raise AttributeError( "Instrument(order...
def settlement_method(self): """ [str] 交割方式,’CashSettlementRequired’ - 现金交割, ‘PhysicalSettlementRequired’ - 实物交割(期货专用) """ try: return self.__dict__["settlement_method"] except (KeyError, ValueError): raise AttributeError( "Instrument(order...
[ "[", "str", "]", "交割方式,’CashSettlementRequired’", "-", "现金交割", "‘PhysicalSettlementRequired’", "-", "实物交割(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L274-L283
[ "def", "settlement_method", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"settlement_method\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attrib...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
Instrument.listing
[bool] 该合约当前日期是否在交易
rqalpha/model/instrument.py
def listing(self): """ [bool] 该合约当前日期是否在交易 """ now = Environment.get_instance().calendar_dt return self.listed_date <= now <= self.de_listed_date
def listing(self): """ [bool] 该合约当前日期是否在交易 """ now = Environment.get_instance().calendar_dt return self.listed_date <= now <= self.de_listed_date
[ "[", "bool", "]", "该合约当前日期是否在交易" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L286-L292
[ "def", "listing", "(", "self", ")", ":", "now", "=", "Environment", ".", "get_instance", "(", ")", ".", "calendar_dt", "return", "self", ".", "listed_date", "<=", "now", "<=", "self", ".", "de_listed_date" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
StockTransactionCostDecider.get_trade_commission
计算手续费这个逻辑比较复杂,按照如下算法来计算: 1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission 2. 当trade来时计算该trade产生的手续费cost_money 3. 如果cost_money > commission 3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回cost_money即可 3.2 如果commission 不等于 min_commission...
rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py
def get_trade_commission(self, trade): """ 计算手续费这个逻辑比较复杂,按照如下算法来计算: 1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission 2. 当trade来时计算该trade产生的手续费cost_money 3. 如果cost_money > commission 3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回c...
def get_trade_commission(self, trade): """ 计算手续费这个逻辑比较复杂,按照如下算法来计算: 1. 定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission 2. 当trade来时计算该trade产生的手续费cost_money 3. 如果cost_money > commission 3.1 如果commission 等于 min_commission,说明这是第一笔trade,此时,直接commission置0,返回c...
[ "计算手续费这个逻辑比较复杂,按照如下算法来计算:", "1", ".", "定义一个剩余手续费的概念,根据order_id存储在commission_map中,默认为min_commission", "2", ".", "当trade来时计算该trade产生的手续费cost_money", "3", ".", "如果cost_money", ">", "commission", "3", ".", "1", "如果commission", "等于", "min_commission,说明这是第一笔trade,此时,直接commission置0,返回cost...
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py#L50-L80
[ "def", "get_trade_commission", "(", "self", ",", "trade", ")", ":", "order_id", "=", "trade", ".", "order_id", "if", "self", ".", "env", ".", "data_proxy", ".", "instruments", "(", "trade", ".", "order_book_id", ")", ".", "type", "==", "'PublicFund'", ":",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
HKStockTransactionCostDecider._get_tax
港交所收费项目繁多,按照如下逻辑计算税费: 1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。 2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。
rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py
def _get_tax(self, order_book_id, _, cost_money): """ 港交所收费项目繁多,按照如下逻辑计算税费: 1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。 2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。 """ instrument = Environment.get_instance().get_instrument(order_book_id) if instrument.type ...
def _get_tax(self, order_book_id, _, cost_money): """ 港交所收费项目繁多,按照如下逻辑计算税费: 1. 税费比例为 0.11%,不足 1 元按 1 元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。 2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。 """ instrument = Environment.get_instance().get_instrument(order_book_id) if instrument.type ...
[ "港交所收费项目繁多,按照如下逻辑计算税费:", "1", ".", "税费比例为", "0", ".", "11%,不足", "1", "元按", "1", "元记,四舍五入保留两位小数(包括印花税、交易征费、交易系统使用费)。", "2,五元固定费用(包括卖方收取的转手纸印花税、买方收取的过户费用)。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py#L108-L122
[ "def", "_get_tax", "(", "self", ",", "order_book_id", ",", "_", ",", "cost_money", ")", ":", "instrument", "=", "Environment", ".", "get_instance", "(", ")", ".", "get_instrument", "(", "order_book_id", ")", "if", "instrument", ".", "type", "!=", "'CS'", "...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BarObject.prev_close
[float] 昨日收盘价
rqalpha/model/bar.py
def prev_close(self): """ [float] 昨日收盘价 """ try: return self._data['prev_close'] except (ValueError, KeyError): pass if self._prev_close is None: trading_dt = Environment.get_instance().trading_dt data_proxy = Environment.g...
def prev_close(self): """ [float] 昨日收盘价 """ try: return self._data['prev_close'] except (ValueError, KeyError): pass if self._prev_close is None: trading_dt = Environment.get_instance().trading_dt data_proxy = Environment.g...
[ "[", "float", "]", "昨日收盘价" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L91-L104
[ "def", "prev_close", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_data", "[", "'prev_close'", "]", "except", "(", "ValueError", ",", "KeyError", ")", ":", "pass", "if", "self", ".", "_prev_close", "is", "None", ":", "trading_dt", "=", "E...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BarObject._bar_status
WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!!
rqalpha/model/bar.py
def _bar_status(self): """ WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!! """ if self.isnan or np.isnan(self.limit_up): return BAR_STATUS.ERROR if self.close >= self.limit_up: return BAR_STATUS.LIMIT_UP if self.close <= self.limit_down:...
def _bar_status(self): """ WARNING: 获取 bar_status 比较耗费性能,而且是lazy_compute,因此不要多次调用!!!! """ if self.isnan or np.isnan(self.limit_up): return BAR_STATUS.ERROR if self.close >= self.limit_up: return BAR_STATUS.LIMIT_UP if self.close <= self.limit_down:...
[ "WARNING", ":", "获取", "bar_status", "比较耗费性能,而且是lazy_compute,因此不要多次调用!!!!" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L107-L117
[ "def", "_bar_status", "(", "self", ")", ":", "if", "self", ".", "isnan", "or", "np", ".", "isnan", "(", "self", ".", "limit_up", ")", ":", "return", "BAR_STATUS", ".", "ERROR", "if", "self", ".", "close", ">=", "self", ".", "limit_up", ":", "return",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
BarObject.prev_settlement
[float] 昨日结算价(期货专用)
rqalpha/model/bar.py
def prev_settlement(self): """ [float] 昨日结算价(期货专用) """ try: return self._data['prev_settlement'] except (ValueError, KeyError): pass if self._prev_settlement is None: trading_dt = Environment.get_instance().trading_dt data_...
def prev_settlement(self): """ [float] 昨日结算价(期货专用) """ try: return self._data['prev_settlement'] except (ValueError, KeyError): pass if self._prev_settlement is None: trading_dt = Environment.get_instance().trading_dt data_...
[ "[", "float", "]", "昨日结算价(期货专用)" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/bar.py#L180-L193
[ "def", "prev_settlement", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_data", "[", "'prev_settlement'", "]", "except", "(", "ValueError", ",", "KeyError", ")", ":", "pass", "if", "self", ".", "_prev_settlement", "is", "None", ":", "trading_d...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
submit_order
通用下单函数,策略可以通过该函数自由选择参数下单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param float amount: 下单量,需为正数 :param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL) :type side: :class:`~SIDE` enum :param float price: 下单价格,默认为None,表示市价单 :param position_effect: 开平方向,开仓(POSITION...
rqalpha/api/api_base.py
def submit_order(id_or_ins, amount, side, price=None, position_effect=None): """ 通用下单函数,策略可以通过该函数自由选择参数下单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param float amount: 下单量,需为正数 :param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL) :type side: :class:`~SIDE` enum ...
def submit_order(id_or_ins, amount, side, price=None, position_effect=None): """ 通用下单函数,策略可以通过该函数自由选择参数下单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param float amount: 下单量,需为正数 :param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL) :type side: :class:`~SIDE` enum ...
[ "通用下单函数,策略可以通过该函数自由选择参数下单。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L224-L291
[ "def", "submit_order", "(", "id_or_ins", ",", "amount", ",", "side", ",", "price", "=", "None", ",", "position_effect", "=", "None", ")", ":", "order_book_id", "=", "assure_order_book_id", "(", "id_or_ins", ")", "env", "=", "Environment", ".", "get_instance", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
cancel_order
撤单 :param order: 需要撤销的order对象 :type order: :class:`~Order` object
rqalpha/api/api_base.py
def cancel_order(order): """ 撤单 :param order: 需要撤销的order对象 :type order: :class:`~Order` object """ env = Environment.get_instance() if env.can_cancel_order(order): env.broker.cancel_order(order) return order
def cancel_order(order): """ 撤单 :param order: 需要撤销的order对象 :type order: :class:`~Order` object """ env = Environment.get_instance() if env.can_cancel_order(order): env.broker.cancel_order(order) return order
[ "撤单" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L304-L314
[ "def", "cancel_order", "(", "order", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "if", "env", ".", "can_cancel_order", "(", "order", ")", ":", "env", ".", "broker", ".", "cancel_order", "(", "order", ")", "return", "order" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
update_universe
该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Ins...
rqalpha/api/api_base.py
def update_universe(id_or_symbols): """ 该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。 :param id_or_sy...
def update_universe(id_or_symbols): """ 该方法用于更新现在关注的证券的集合(e.g.:股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为['000001.XSHE', '000024.XSHE']然后调用了update_universe(['000030.XSHE'])之后,股票池就会变成000030.XSHE一个股票了,随后的数据更新也只会跟踪000030.XSHE这一个股票了。 :param id_or_sy...
[ "该方法用于更新现在关注的证券的集合(e", ".", "g", ".", ":股票池)。PS:会在下一个bar事件触发时候产生(新的关注的股票池更新)效果。并且update_universe会是覆盖(overwrite)的操作而不是在已有的股票池的基础上进行增量添加。比如已有的股票池为", "[", "000001", ".", "XSHE", "000024", ".", "XSHE", "]", "然后调用了update_universe", "(", "[", "000030", ".", "XSHE", "]", ")", "之后,...
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L327-L340
[ "def", "update_universe", "(", "id_or_symbols", ")", ":", "if", "isinstance", "(", "id_or_symbols", ",", "(", "six", ".", "string_types", ",", "Instrument", ")", ")", ":", "id_or_symbols", "=", "[", "id_or_symbols", "]", "order_book_ids", "=", "set", "(", "a...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
subscribe
订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。 需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
rqalpha/api/api_base.py
def subscribe(id_or_symbols): """ 订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。 需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] """ current_universe = Environment...
def subscribe(id_or_symbols): """ 订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。 需要注意,用户在初次编写策略时候需要首先订阅合约行情,否则handle_bar不会被触发。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] """ current_universe = Environment...
[ "订阅合约行情。该操作会导致合约池内合约的增加,从而影响handle_bar中处理bar数据的数量。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L353-L374
[ "def", "subscribe", "(", "id_or_symbols", ")", ":", "current_universe", "=", "Environment", ".", "get_instance", "(", ")", ".", "get_universe", "(", ")", "if", "isinstance", "(", "id_or_symbols", ",", "six", ".", "string_types", ")", ":", "order_book_id", "=",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
unsubscribe
取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`]
rqalpha/api/api_base.py
def unsubscribe(id_or_symbols): """ 取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] """ current_universe = Environment.get_instance().get_universe() if isinstance(...
def unsubscribe(id_or_symbols): """ 取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。 :param id_or_symbols: 标的物 :type id_or_symbols: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] """ current_universe = Environment.get_instance().get_universe() if isinstance(...
[ "取消订阅合约行情。取消订阅会导致合约池内合约的减少,如果当前合约池中没有任何合约,则策略直接退出。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L387-L407
[ "def", "unsubscribe", "(", "id_or_symbols", ")", ":", "current_universe", "=", "Environment", ".", "get_instance", "(", ")", ".", "get_universe", "(", ")", "if", "isinstance", "(", "id_or_symbols", ",", "six", ".", "string_types", ")", ":", "order_book_id", "=...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
get_yield_curve
获取某个国家市场指定日期的收益率曲线水平。 数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。 :param date: 查询日期,默认为策略当前日期前一天 :type date: `str` | `date` | `datetime` | `pandas.Timestamp` :param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限 :return: `pandas.DataFrame` - 查询时间段内无风险收益率曲线 :example: .. code-block:...
rqalpha/api/api_base.py
def get_yield_curve(date=None, tenor=None): """ 获取某个国家市场指定日期的收益率曲线水平。 数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。 :param date: 查询日期,默认为策略当前日期前一天 :type date: `str` | `date` | `datetime` | `pandas.Timestamp` :param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限 :return: `pandas.DataFra...
def get_yield_curve(date=None, tenor=None): """ 获取某个国家市场指定日期的收益率曲线水平。 数据为2002年至今的中债国债收益率曲线,来源于中央国债登记结算有限责任公司。 :param date: 查询日期,默认为策略当前日期前一天 :type date: `str` | `date` | `datetime` | `pandas.Timestamp` :param str tenor: 标准期限,'0S' - 隔夜,'1M' - 1个月,'1Y' - 1年,默认为全部期限 :return: `pandas.DataFra...
[ "获取某个国家市场指定日期的收益率曲线水平。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L423-L465
[ "def", "get_yield_curve", "(", "date", "=", "None", ",", "tenor", "=", "None", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "trading_date", "=", "env", ".", "trading_dt", ".", "date", "(", ")", "yesterday", "=", "env", ".", "data...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
history_bars
获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。 日回测获取分钟历史数据:不支持 日回测获取日历史数据 ========================= =================================================== 调用时间 返回数据 ========================= =================================================== T日before_trading ...
rqalpha/api/api_base.py
def history_bars( order_book_id, bar_count, frequency, fields=None, skip_suspended=True, include_now=False, adjust_type="pre", ): """ 获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。 日回测获取分钟历史数据:不支持 日回测获取日历史数据 ========================= ========================...
def history_bars( order_book_id, bar_count, frequency, fields=None, skip_suspended=True, include_now=False, adjust_type="pre", ): """ 获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。 注意,该API会自动跳过停牌数据。 日回测获取分钟历史数据:不支持 日回测获取日历史数据 ========================= ========================...
[ "获取指定合约的历史行情,同时支持日以及分钟历史数据。不能在init中调用。", "注意,该API会自动跳过停牌数据。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L487-L612
[ "def", "history_bars", "(", "order_book_id", ",", "bar_count", ",", "frequency", ",", "fields", "=", "None", ",", "skip_suspended", "=", "True", ",", "include_now", "=", "False", ",", "adjust_type", "=", "\"pre\"", ",", ")", ":", "order_book_id", "=", "assur...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
all_instruments
获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。 :param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型 :param date: 查询时间点 :type date: `str` | `datetime` | `date` :return: `pandas DataFrame` 所有合约的基本信息。 其中type参数传入的合约类型和对应的解释如下: ========================= ==================================...
rqalpha/api/api_base.py
def all_instruments(type=None, date=None): """ 获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。 :param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型 :param date: 查询时间点 :type date: `str` | `datetime` | `date` :return: `pandas DataFrame` 所有合约的基本信息。 其中type参数传入的合约类型和对应的解释如下: =======...
def all_instruments(type=None, date=None): """ 获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。 :param str type: 需要查询合约类型,例如:type='CS'代表股票。默认是所有类型 :param date: 查询时间点 :type date: `str` | `datetime` | `date` :return: `pandas DataFrame` 所有合约的基本信息。 其中type参数传入的合约类型和对应的解释如下: =======...
[ "获取某个国家市场的所有合约信息。使用者可以通过这一方法很快地对合约信息有一个快速了解,目前仅支持中国市场。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L630-L707
[ "def", "all_instruments", "(", "type", "=", "None", ",", "date", "=", "None", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "if", "date", "is", "None", ":", "dt", "=", "env", ".", "trading_dt", "else", ":", "dt", "=", "pd", "....
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
current_snapshot
获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。 市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。 在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。 需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。 如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, high, low, last几个价格水平都将以0表示。 :param str id_or_...
rqalpha/api/api_base.py
def current_snapshot(id_or_symbol): """ 获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。 市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。 在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。 需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。 如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, hig...
def current_snapshot(id_or_symbol): """ 获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。 市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day bar数据。 在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。 需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。 如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close, hig...
[ "获得当前市场快照数据。只能在日内交易阶段调用,获取当日调用时点的市场快照数据。", "市场快照数据记录了每日从开盘到当前的数据信息,可以理解为一个动态的day", "bar数据。", "在目前分钟回测中,快照数据为当日所有分钟线累积而成,一般情况下,最后一个分钟线获取到的快照数据应当与当日的日线行情保持一致。", "需要注意,在实盘模拟中,该函数返回的是调用当时的市场快照情况,所以在同一个handle_bar中不同时点调用可能返回的数据不同。", "如果当日截止到调用时候对应股票没有任何成交,那么snapshot中的close", "high", "low", "last几个价格水平都将以0...
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L989-L1028
[ "def", "current_snapshot", "(", "id_or_symbol", ")", ":", "env", "=", "Environment", ".", "get_instance", "(", ")", "frequency", "=", "env", ".", "config", ".", "base", ".", "frequency", "order_book_id", "=", "assure_order_book_id", "(", "id_or_symbol", ")", "...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
StockAccount.dividend_receivable
[float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分
rqalpha/mod/rqalpha_mod_sys_accounts/account_model/stock_account.py
def dividend_receivable(self): """ [float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分 """ return sum(d['quantity'] * d['dividend_per_share'] for d in six.itervalues(self._dividend_receivable))
def dividend_receivable(self): """ [float] 投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分 """ return sum(d['quantity'] * d['dividend_per_share'] for d in six.itervalues(self._dividend_receivable))
[ "[", "float", "]", "投资组合在分红现金收到账面之前的应收分红部分。具体细节在分红部分" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/account_model/stock_account.py#L247-L251
[ "def", "dividend_receivable", "(", "self", ")", ":", "return", "sum", "(", "d", "[", "'quantity'", "]", "*", "d", "[", "'dividend_per_share'", "]", "for", "d", "in", "six", ".", "itervalues", "(", "self", ".", "_dividend_receivable", ")", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
AbstractDataSource.history_bars
获取历史数据 :param instrument: 合约对象 :type instrument: :class:`~Instrument` :param int bar_count: 获取的历史数据数量 :param str frequency: 周期频率,`1d` 表示日周期, `1m` 表示分钟周期 :param str fields: 返回数据字段 ========================= =================================================== fi...
rqalpha/interface.py
def history_bars(self, instrument, bar_count, frequency, fields, dt, skip_suspended=True, include_now=False, adjust_type='pre', adjust_orig=None): """ 获取历史数据 :param instrument: 合约对象 :type instrument: :class:`~Instrument` :param int bar_count: 获取的历史数据数量 ...
def history_bars(self, instrument, bar_count, frequency, fields, dt, skip_suspended=True, include_now=False, adjust_type='pre', adjust_orig=None): """ 获取历史数据 :param instrument: 合约对象 :type instrument: :class:`~Instrument` :param int bar_count: 获取的历史数据数量 ...
[ "获取历史数据" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/interface.py#L360-L398
[ "def", "history_bars", "(", "self", ",", "instrument", ",", "bar_count", ",", "frequency", ",", "fields", ",", "dt", ",", "skip_suspended", "=", "True", ",", "include_now", "=", "False", ",", "adjust_type", "=", "'pre'", ",", "adjust_orig", "=", "None", ")...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_shares
落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `st...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_shares(id_or_ins, amount, price=None, style=None): """ 落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 ...
def order_shares(id_or_ins, amount, price=None, style=None): """ 落指定股数的买/卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 ...
[ "落指定股数的买", "/", "卖单,最常见的落单方式之一。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market", "order)。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L68-L139
[ "def", "order_shares", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "if", "amount", "==", "0", ":", "# 如果下单量为0,则认为其并没有发单,则直接返回None", "user_system_log", ".", "warn", "(", "_", "(", "u\"Order Creation Failed: O...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_lots
指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 :param float price: 下单价格,默认为None,表示 :class:`~MarketOrder`, 此参数主要用于简化 `style` 参数。 ...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_lots(id_or_ins, amount, price=None, style=None): """ 指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 :param float...
def order_lots(id_or_ins, amount, price=None, style=None): """ 指定手数发送买/卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market order)。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param int amount: 下单量, 正数代表买入,负数代表卖出。将会根据一手xx股来向下调整到一手的倍数,比如中国A股就是调整成100股的倍数。 :param float...
[ "指定手数发送买", "/", "卖单。如有需要落单类型当做一个参量传入,如果忽略掉落单类型,那么默认是市价单(market", "order)。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L162-L194
[ "def", "order_lots", "(", "id_or_ins", ",", "amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "order_book_id", "=", "assure_stock_order_book_id", "(", "id_or_ins", ")", "round_lot", "=", "int", "(", "Environment", ".", "get_instance", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_value
使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。 需要注意: 当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。 当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价值。如果金额超出了您所持有股票的价值,那么您将卖出所有股票。 :param id_or_ins: 下单标的物 :type id_or_i...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_value(id_or_ins, cash_amount, price=None, style=None): """ 使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。 需要注意: 当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。 当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价...
def order_value(id_or_ins, cash_amount, price=None, style=None): """ 使用想要花费的金钱买入/卖出股票,而不是买入/卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。 需要注意: 当您提交一个买单时,cash_amount 代表的含义是您希望买入股票消耗的金额(包含税费),最终买入的股数不仅和发单的价格有关,还和税费相关的参数设置有关。 当您提交一个卖单时,cash_amount 代表的意义是您希望卖出股票的总价...
[ "使用想要花费的金钱买入", "/", "卖出股票,而不是买入", "/", "卖出想要的股数,正数代表买入,负数代表卖出。股票的股数总是会被调整成对应的100的倍数(在A中国A股市场1手是100股)。如果资金不足,该API将不会创建发送订单。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L206-L282
[ "def", "order_value", "(", "id_or_ins", ",", "cash_amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "style", "=", "cal_style", "(", "price", ",", "style", ")", "if", "isinstance", "(", "style", ",", "LimitOrder", ")", ":", "if",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_percent
发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。 需要注意: 发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。 发送卖单时,percent 代表的是期望卖出的股票总价值占投资组合总权益的比例。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_percent(id_or_ins, percent, price=None, style=None): """ 发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。 需要注意: 发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。 发送卖单时,percent 代表的是期望卖出的股票...
def order_percent(id_or_ins, percent, price=None, style=None): """ 发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买/卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<=100%),0.5表示的是50%.需要注意,如果资金不足,该API将不会创建发送订单。 需要注意: 发送买单时,percent 代表的是期望买入股票消耗的金额(包含税费)占投资组合总权益的比例。 发送卖单时,percent 代表的是期望卖出的股票...
[ "发送一个花费价值等于目前投资组合(市场价值和目前现金的总和)一定百分比现金的买", "/", "卖单,正数代表买,负数代表卖。股票的股数总是会被调整成对应的一手的股票数的倍数(1手是100股)。百分比是一个小数,并且小于或等于1(<", "=", "100%),0", ".", "5表示的是50%", ".", "需要注意,如果资金不足,该API将不会创建发送订单。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L294-L326
[ "def", "order_percent", "(", "id_or_ins", ",", "percent", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "if", "percent", "<", "-", "1", "or", "percent", ">", "1", ":", "raise", "RQInvalidArgument", "(", "_", "(", "u\"percent should betw...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_target_value
买入/卖出并且自动调整该证券的仓位到一个目标价值。 加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。 减仓时,cash_amount 代表调整仓位的目标价至。 需要注意,如果资金不足,该API将不会创建发送订单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:class:`~Instrument`] | List[`str`] :param float cash_amount: 最终的该证券的仓位目标价值。 ...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_target_value(id_or_ins, cash_amount, price=None, style=None): """ 买入/卖出并且自动调整该证券的仓位到一个目标价值。 加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。 减仓时,cash_amount 代表调整仓位的目标价至。 需要注意,如果资金不足,该API将不会创建发送订单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:c...
def order_target_value(id_or_ins, cash_amount, price=None, style=None): """ 买入/卖出并且自动调整该证券的仓位到一个目标价值。 加仓时,cash_amount 代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。 减仓时,cash_amount 代表调整仓位的目标价至。 需要注意,如果资金不足,该API将不会创建发送订单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` | List[:c...
[ "买入", "/", "卖出并且自动调整该证券的仓位到一个目标价值。", "加仓时,cash_amount", "代表现有持仓的价值加上即将花费(包含税费)的现金的总价值。", "减仓时,cash_amount", "代表调整仓位的目标价至。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L338-L380
[ "def", "order_target_value", "(", "id_or_ins", ",", "cash_amount", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "order_book_id", "=", "assure_stock_order_book_id", "(", "id_or_ins", ")", "account", "=", "Environment", ".", "get_instance", "(",...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
order_target_percent
买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。 加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。 减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。 其实我们需要计算一个position_to_adjust (即应该调整的仓位) `position_to_adjust = target_position - current_position` 投资组合价值等于所有已有仓位的价值和剩余现金的总和。买/卖单会被下舍入一手股数(A股是100的倍数)的倍数。目标百分比应该是一个小数,并且最大值...
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def order_target_percent(id_or_ins, percent, price=None, style=None): """ 买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。 加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。 减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。 其实我们需要计算一个position_to_adjust (即应该调整的仓位) `position_to_adjust = target_position - current_posit...
def order_target_percent(id_or_ins, percent, price=None, style=None): """ 买入/卖出证券以自动调整该证券的仓位到占有一个目标价值。 加仓时,percent 代表证券已有持仓的价值加上即将花费的现金(包含税费)的总值占当前投资组合总价值的比例。 减仓时,percent 代表证券将被调整到的目标价至占当前投资组合总价值的比例。 其实我们需要计算一个position_to_adjust (即应该调整的仓位) `position_to_adjust = target_position - current_posit...
[ "买入", "/", "卖出证券以自动调整该证券的仓位到占有一个目标价值。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L392-L445
[ "def", "order_target_percent", "(", "id_or_ins", ",", "percent", ",", "price", "=", "None", ",", "style", "=", "None", ")", ":", "if", "percent", "<", "0", "or", "percent", ">", "1", ":", "raise", "RQInvalidArgument", "(", "_", "(", "u\"percent should betw...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
is_suspended
判断某只股票是否全天停牌。 :param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol :param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据 :return: count为1时 `bool`; count>1时 `pandas.DataFrame`
rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py
def is_suspended(order_book_id, count=1): """ 判断某只股票是否全天停牌。 :param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol :param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据 :return: count为1时 `bool`; count>1时 `pandas.DataFrame` """ dt = Environment.get_instance().calendar_dt.date() or...
def is_suspended(order_book_id, count=1): """ 判断某只股票是否全天停牌。 :param str order_book_id: 某只股票的代码或股票代码,可传入单只股票的order_book_id, symbol :param int count: 回溯获取的数据个数。默认为当前能够获取到的最近的数据 :return: count为1时 `bool`; count>1时 `pandas.DataFrame` """ dt = Environment.get_instance().calendar_dt.date() or...
[ "判断某只股票是否全天停牌。" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py#L457-L469
[ "def", "is_suspended", "(", "order_book_id", ",", "count", "=", "1", ")", ":", "dt", "=", "Environment", ".", "get_instance", "(", ")", ".", "calendar_dt", ".", "date", "(", ")", "order_book_id", "=", "assure_stock_order_book_id", "(", "order_book_id", ")", ...
ac40a62d4e7eca9494b4d0a14f46facf5616820c
train
update_bundle
Sync Data Bundle
rqalpha/__main__.py
def update_bundle(data_bundle_path, locale): """ Sync Data Bundle """ import rqalpha.utils.bundle_helper rqalpha.utils.bundle_helper.update_bundle(data_bundle_path, locale)
def update_bundle(data_bundle_path, locale): """ Sync Data Bundle """ import rqalpha.utils.bundle_helper rqalpha.utils.bundle_helper.update_bundle(data_bundle_path, locale)
[ "Sync", "Data", "Bundle" ]
ricequant/rqalpha
python
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/__main__.py#L77-L82
[ "def", "update_bundle", "(", "data_bundle_path", ",", "locale", ")", ":", "import", "rqalpha", ".", "utils", ".", "bundle_helper", "rqalpha", ".", "utils", ".", "bundle_helper", ".", "update_bundle", "(", "data_bundle_path", ",", "locale", ")" ]
ac40a62d4e7eca9494b4d0a14f46facf5616820c