关于多头或空头内容导航:
- 1、多头或空头
- 2、多头或空头以及清算所头寸
- 3、多头或空头盘
1、多头或空头
def get_trend(self, df):
# 判断多空
if df.iloc[-1, 3] > df.iloc[-1, 4]:
return '多头'
else:
return '空头'
# 获取指定时间段的K线
def get_kline(self, symbol, period, size=None):
# 获取K线
kline = self.ws.get_kline(symbol=symbol, period=period, size=size)
# 转换为DataFrame
df = pd.DataFrame(kline)
# 设置列名
df.columns = ['open_time', 'open', 'high', 'low', 'close', 'volume', 'close_time', 'quote_av', 'trades', 'tb_base_av', 'tb_quote_av', 'ignore']
# 去掉多余的列
df = df.drop('ignore', axis=1)
# 将open_time, close_time转换为时间格式
df['open_time'] = pd.to_datetime(df['open_time'], unit='ms')
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms')
# 设置索引,open_time
df = df.set_index('open_time')
# 返回
return df
# 获取指定时间段的分时
def get_ticker(self, symbol):
# 获取分时
ticker = self.ws.get_ticker(symbol=symbol)
# 转换为DataFrame
df = pd.DataFrame(ticker)
# 设置列名
df.columns = ['open', 'close', 'high', 'low', 'amount', 'count', 'vol', 'open_time', 'close_time']
# 将open_time, close_time转换为时间格式
df['open_time'] = pd.to_datetime(df['open_time'], unit='ms')
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms')
# 设置索引,open_time
df = df.set_index('open_time')
# 返回
return df
# 获取指定时间段的深度
def get_depth(self, symbol, type):
# 获取深度
depth = self.ws.get_depth(symbol=symbol, type=type)
# 转换为DataFrame
df = pd.DataFrame(depth['tick']['bids'], columns=['price', 'amount'])
# 设置索引,price
df = df.set_index('price')
# 返回
return df
# 获取指定时间段的成交记录
def get_trade(self, symbol):
# 获取成交记录
trade = self.ws.get_trade(symbol=symbol)
# 转换为DataFrame
df = pd.DataFrame(trade)
# 设置列名
df.columns = ['id', 'price', 'amount', 'direction', 'ts']
# 将ts转换为时间格式
df['ts'] = pd.to_datetime(df['ts'], unit='ms')
# 设置索引,ts
df = df.set_index('ts')
# 返回
return df
# 获取指定时间段的指标
def get_indicator(self, df, n):
# 计算指标
df['ma' + str(n)] = df['close'].rolling(window=n).mean()
# 返回
return df
# 获取指定时间段的指标
def get_indicator_macd(self, df, n_fast, n_slow):
# 计算指标
df['ema' + str(n_fast)] = df['close'].ewm(span=n_fast).mean()
df['ema' + str(n_slow)] = df['close'].ewm(span=n_slow).mean()
df['diff'] = df['ema' + str(n_fast)] - df['ema' + str(n_slow)]
df['dea'] = df['diff'].ewm(span=9).mean()
df['macd'] = 2 * (df['diff'] - df['dea'])
# 返回
return df
# 获取指定时间段的指标
def get_indicator_kdj(self, df, n):
# 计算指标
low_list = df['low'].rolling(window=n).min()
low_list.fillna(value=df['low'].expanding().min(), inplace=True)
high_list = df['high'].rolling(window=n).max()
high_list.fillna(value=df['high'].expanding().max(), inplace=True)
rsv = (df['close'] - low_list) / (high_list - low_list) * 100
df['k'] = rsv.ewm(com=2).mean()
df['d'] = df['k'].ewm(com=2).mean()
df['j'] = 3 * df['k'] - 2 * df['d']
# 返回
return df
# 获取指定时间段的指标
def get_indicator_boll(self, df, n):
# 计算指标
df['ma' + str(n)] = df['close'].rolling(window=n).mean()
df['md' + str(n)] = df['close'].rolling(window=n).std()
df['boll_up'] = df['ma' + str(n)] + 2 * df['md' + str(n)]
df['boll_down'] = df['ma' + str(n)] - 2 * df['md' + str(n)]
# 返回
return df
# 获取指定时间段的指标
def get_indicator_rsi(self, df, n):
# 计算指标
df['diff'] = df['close'].diff()
df['diff'].fillna(value=0, inplace=True)
df['up'] = df['diff']
df['up'][df['up'] < 0] = 0
df['down'] = df['diff']
df['down'][df['down'] > 0] = 0
df['rs'] = df['up'].rolling(window=n).mean() / df['down'].abs().rolling(window=n).mean()
df['rsi' + str(n)] = 100 - (100 / (1 + df['rs']))
# 返回
return df
# 获取指定时间段的指标
2、多头或空头以及清算所头寸
C
目前在上海清算所登记托管结算的债券产品包括超短融、信用风险缓释合约(CRM)和非公开定向融资工具(即私募债)。其全额结算方式包括:现券交易、质押式回购、买断式回购、债券远期和债券借贷。
3、多头或空头盘
多头指的是买涨的投资者,,空投指的是看跌,卖出的投资者!使用现金买入股票的是多头,卖出股票套取现金的是空头
1·多头(指买股票或期货的人):指投资者对股市看好,预计股价将会看涨,于是趁低价时买进股票,待股票上涨至某一价位时再卖出,以获取差额收益。
2·空头(指卖股票或期货的人):是投资者和股票商认为现时股价虽然较高,但对股市前景看坏,预计股价将会下跌,于是把股票卖出,待股价跌至某一价位时再买进,以获取差额收益。
满意希望采纳。
选个手表到这里>>http://shop112427061.taobao.com/?spm=a230r.7195193.1997079397.2.051Dva
你好,A股的多头代表看涨,空头代表看跌。 一般空头多头适用于期货,股票中的专业术语叫做涨(多头),做跌(空头)。