body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
@virtual
def on_tick(self, tick: TickData):
'\n Callback of new tick data update.\n '
pass | -5,404,603,894,278,310,000 | Callback of new tick data update. | vnpy/app/cta_strategy_pro/template.py | on_tick | UtorYeung/vnpy | python | @virtual
def on_tick(self, tick: TickData):
'\n \n '
pass |
@virtual
def on_bar(self, bar: BarData):
'\n Callback of new bar data update.\n '
pass | 959,336,517,627,439,700 | Callback of new bar data update. | vnpy/app/cta_strategy_pro/template.py | on_bar | UtorYeung/vnpy | python | @virtual
def on_bar(self, bar: BarData):
'\n \n '
pass |
@virtual
def on_trade(self, trade: TradeData):
'\n Callback of new trade data update.\n '
pass | -2,060,187,208,861,163,800 | Callback of new trade data update. | vnpy/app/cta_strategy_pro/template.py | on_trade | UtorYeung/vnpy | python | @virtual
def on_trade(self, trade: TradeData):
'\n \n '
pass |
@virtual
def on_order(self, order: OrderData):
'\n Callback of new order data update.\n '
pass | 685,206,543,045,577,000 | Callback of new order data update. | vnpy/app/cta_strategy_pro/template.py | on_order | UtorYeung/vnpy | python | @virtual
def on_order(self, order: OrderData):
'\n \n '
pass |
@virtual
def on_stop_order(self, stop_order: StopOrder):
'\n Callback of stop order update.\n '
pass | 7,482,887,281,911,738,000 | Callback of stop order update. | vnpy/app/cta_strategy_pro/template.py | on_stop_order | UtorYeung/vnpy | python | @virtual
def on_stop_order(self, stop_order: StopOrder):
'\n \n '
pass |
def buy(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str='', order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n Send buy order to open a long position.\n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if sel... | -9,080,480,501,627,685,000 | Send buy order to open a long position. | vnpy/app/cta_strategy_pro/template.py | buy | UtorYeung/vnpy | python | def buy(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str=, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n \n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if self.is_upper_limit(vt_symbol):
... |
def sell(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str='', order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n Send sell order to close a long position.\n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if ... | 6,360,702,185,854,788,000 | Send sell order to close a long position. | vnpy/app/cta_strategy_pro/template.py | sell | UtorYeung/vnpy | python | def sell(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str=, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n \n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if self.is_lower_limit(vt_symbol):
... |
def short(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str='', order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n Send short order to open as short position.\n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
... | 4,953,141,459,008,334,000 | Send short order to open as short position. | vnpy/app/cta_strategy_pro/template.py | short | UtorYeung/vnpy | python | def short(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str=, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n \n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if self.is_lower_limit(vt_symbol):
... |
def cover(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str='', order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n Send cover order to close a short position.\n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
... | 6,435,601,325,156,773,000 | Send cover order to close a short position. | vnpy/app/cta_strategy_pro/template.py | cover | UtorYeung/vnpy | python | def cover(self, price: float, volume: float, stop: bool=False, lock: bool=False, vt_symbol: str=, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n \n '
if (order_type in [OrderType.FAK, OrderType.FOK]):
if self.is_upper_limit(vt_symbol):
... |
def send_order(self, vt_symbol: str, direction: Direction, offset: Offset, price: float, volume: float, stop: bool=False, lock: bool=False, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n Send a new order.\n '
if (vt_symbol == ''):
vt_symbol = sel... | -7,242,398,835,969,134,000 | Send a new order. | vnpy/app/cta_strategy_pro/template.py | send_order | UtorYeung/vnpy | python | def send_order(self, vt_symbol: str, direction: Direction, offset: Offset, price: float, volume: float, stop: bool=False, lock: bool=False, order_type: OrderType=OrderType.LIMIT, order_time: datetime=None, grid: CtaGrid=None):
'\n \n '
if (vt_symbol == ):
vt_symbol = self.vt_symbol
if ... |
def cancel_order(self, vt_orderid: str):
'\n Cancel an existing order.\n '
if self.trading:
return self.cta_engine.cancel_order(self, vt_orderid)
return False | 6,330,077,215,582,117,000 | Cancel an existing order. | vnpy/app/cta_strategy_pro/template.py | cancel_order | UtorYeung/vnpy | python | def cancel_order(self, vt_orderid: str):
'\n \n '
if self.trading:
return self.cta_engine.cancel_order(self, vt_orderid)
return False |
def cancel_all(self):
'\n Cancel all orders sent by strategy.\n '
if self.trading:
self.cta_engine.cancel_all(self) | 4,049,518,702,072,619,000 | Cancel all orders sent by strategy. | vnpy/app/cta_strategy_pro/template.py | cancel_all | UtorYeung/vnpy | python | def cancel_all(self):
'\n \n '
if self.trading:
self.cta_engine.cancel_all(self) |
def is_upper_limit(self, symbol):
'是否涨停'
tick = self.tick_dict.get(symbol, None)
if ((tick is None) or (tick.limit_up is None) or (tick.limit_up == 0)):
return False
if (tick.bid_price_1 == tick.limit_up):
return True | -3,416,308,772,781,506,000 | 是否涨停 | vnpy/app/cta_strategy_pro/template.py | is_upper_limit | UtorYeung/vnpy | python | def is_upper_limit(self, symbol):
tick = self.tick_dict.get(symbol, None)
if ((tick is None) or (tick.limit_up is None) or (tick.limit_up == 0)):
return False
if (tick.bid_price_1 == tick.limit_up):
return True |
def is_lower_limit(self, symbol):
'是否跌停'
tick = self.tick_dict.get(symbol, None)
if ((tick is None) or (tick.limit_down is None) or (tick.limit_down == 0)):
return False
if (tick.ask_price_1 == tick.limit_down):
return True | 2,973,849,828,281,988,000 | 是否跌停 | vnpy/app/cta_strategy_pro/template.py | is_lower_limit | UtorYeung/vnpy | python | def is_lower_limit(self, symbol):
tick = self.tick_dict.get(symbol, None)
if ((tick is None) or (tick.limit_down is None) or (tick.limit_down == 0)):
return False
if (tick.ask_price_1 == tick.limit_down):
return True |
def write_log(self, msg: str, level: int=INFO):
'\n Write a log message.\n '
self.cta_engine.write_log(msg=msg, strategy_name=self.strategy_name, level=level) | -3,863,003,474,144,610,000 | Write a log message. | vnpy/app/cta_strategy_pro/template.py | write_log | UtorYeung/vnpy | python | def write_log(self, msg: str, level: int=INFO):
'\n \n '
self.cta_engine.write_log(msg=msg, strategy_name=self.strategy_name, level=level) |
def write_error(self, msg: str):
'write error log message'
self.write_log(msg=msg, level=ERROR) | 3,193,733,022,767,435,000 | write error log message | vnpy/app/cta_strategy_pro/template.py | write_error | UtorYeung/vnpy | python | def write_error(self, msg: str):
self.write_log(msg=msg, level=ERROR) |
def get_engine_type(self):
'\n Return whether the cta_engine is backtesting or live trading.\n '
return self.cta_engine.get_engine_type() | 7,297,224,918,648,383,000 | Return whether the cta_engine is backtesting or live trading. | vnpy/app/cta_strategy_pro/template.py | get_engine_type | UtorYeung/vnpy | python | def get_engine_type(self):
'\n \n '
return self.cta_engine.get_engine_type() |
def load_bar(self, days: int, interval: Interval=Interval.MINUTE, callback: Callable=None, interval_num: int=1):
'\n Load historical bar data for initializing strategy.\n '
if (not callback):
callback = self.on_bar
self.cta_engine.load_bar(self.vt_symbol, days, interval, callback, inte... | 294,891,323,061,072,960 | Load historical bar data for initializing strategy. | vnpy/app/cta_strategy_pro/template.py | load_bar | UtorYeung/vnpy | python | def load_bar(self, days: int, interval: Interval=Interval.MINUTE, callback: Callable=None, interval_num: int=1):
'\n \n '
if (not callback):
callback = self.on_bar
self.cta_engine.load_bar(self.vt_symbol, days, interval, callback, interval_num) |
def load_tick(self, days: int):
'\n Load historical tick data for initializing strategy.\n '
self.cta_engine.load_tick(self.vt_symbol, days, self.on_tick) | 5,586,702,844,267,469,000 | Load historical tick data for initializing strategy. | vnpy/app/cta_strategy_pro/template.py | load_tick | UtorYeung/vnpy | python | def load_tick(self, days: int):
'\n \n '
self.cta_engine.load_tick(self.vt_symbol, days, self.on_tick) |
def put_event(self):
'\n Put an strategy data event for ui update.\n '
if self.inited:
self.cta_engine.put_strategy_event(self) | 8,639,283,256,132,671,000 | Put an strategy data event for ui update. | vnpy/app/cta_strategy_pro/template.py | put_event | UtorYeung/vnpy | python | def put_event(self):
'\n \n '
if self.inited:
self.cta_engine.put_strategy_event(self) |
def send_email(self, msg):
'\n Send email to default receiver.\n '
if self.inited:
self.cta_engine.send_email(msg, self) | 6,436,060,040,956,104,000 | Send email to default receiver. | vnpy/app/cta_strategy_pro/template.py | send_email | UtorYeung/vnpy | python | def send_email(self, msg):
'\n \n '
if self.inited:
self.cta_engine.send_email(msg, self) |
def sync_data(self):
'\n Sync strategy variables value into disk storage.\n '
if self.trading:
self.cta_engine.sync_strategy_data(self) | 943,088,262,176,522,200 | Sync strategy variables value into disk storage. | vnpy/app/cta_strategy_pro/template.py | sync_data | UtorYeung/vnpy | python | def sync_data(self):
'\n \n '
if self.trading:
self.cta_engine.sync_strategy_data(self) |
@virtual
def on_tick(self, tick: TickData):
'\n Callback of new tick data update.\n '
pass | -5,404,603,894,278,310,000 | Callback of new tick data update. | vnpy/app/cta_strategy_pro/template.py | on_tick | UtorYeung/vnpy | python | @virtual
def on_tick(self, tick: TickData):
'\n \n '
pass |
@virtual
def on_bar(self, bar: BarData):
'\n Callback of new bar data update.\n '
pass | 959,336,517,627,439,700 | Callback of new bar data update. | vnpy/app/cta_strategy_pro/template.py | on_bar | UtorYeung/vnpy | python | @virtual
def on_bar(self, bar: BarData):
'\n \n '
pass |
@virtual
def on_tick(self, tick: TickData):
'\n Callback of new tick data update.\n '
self.last_tick = tick
if self.trading:
self.trade() | 319,937,858,261,153,700 | Callback of new tick data update. | vnpy/app/cta_strategy_pro/template.py | on_tick | UtorYeung/vnpy | python | @virtual
def on_tick(self, tick: TickData):
'\n \n '
self.last_tick = tick
if self.trading:
self.trade() |
@virtual
def on_bar(self, bar: BarData):
'\n Callback of new bar data update.\n '
self.last_bar = bar | 3,089,873,859,974,323,000 | Callback of new bar data update. | vnpy/app/cta_strategy_pro/template.py | on_bar | UtorYeung/vnpy | python | @virtual
def on_bar(self, bar: BarData):
'\n \n '
self.last_bar = bar |
@virtual
def on_order(self, order: OrderData):
'\n Callback of new order data update.\n '
vt_orderid = order.vt_orderid
if ((not order.is_active()) and (vt_orderid in self.vt_orderids)):
self.vt_orderids.remove(vt_orderid) | 2,346,660,776,233,848,300 | Callback of new order data update. | vnpy/app/cta_strategy_pro/template.py | on_order | UtorYeung/vnpy | python | @virtual
def on_order(self, order: OrderData):
'\n \n '
vt_orderid = order.vt_orderid
if ((not order.is_active()) and (vt_orderid in self.vt_orderids)):
self.vt_orderids.remove(vt_orderid) |
def update_setting(self, setting: dict):
'\n Update strategy parameter wtih value in setting dict.\n '
for name in self.parameters:
if (name in setting):
setattr(self, name, setting[name])
(symbol, self.exchange) = extract_vt_symbol(self.vt_symbol)
if (self.idx_symbol i... | -4,360,711,793,639,846,000 | Update strategy parameter wtih value in setting dict. | vnpy/app/cta_strategy_pro/template.py | update_setting | UtorYeung/vnpy | python | def update_setting(self, setting: dict):
'\n \n '
for name in self.parameters:
if (name in setting):
setattr(self, name, setting[name])
(symbol, self.exchange) = extract_vt_symbol(self.vt_symbol)
if (self.idx_symbol is None):
self.idx_symbol = ((get_underlying_s... |
def sync_data(self):
'同步更新数据'
if (not self.backtesting):
self.write_log(u'保存k线缓存数据')
self.save_klines_to_cache()
if (self.inited and self.trading):
self.write_log(u'保存policy数据')
self.policy.save() | -5,144,947,309,974,197,000 | 同步更新数据 | vnpy/app/cta_strategy_pro/template.py | sync_data | UtorYeung/vnpy | python | def sync_data(self):
if (not self.backtesting):
self.write_log(u'保存k线缓存数据')
self.save_klines_to_cache()
if (self.inited and self.trading):
self.write_log(u'保存policy数据')
self.policy.save() |
def save_klines_to_cache(self, kline_names: list=[]):
'\n 保存K线数据到缓存\n :param kline_names: 一般为self.klines的keys\n :return:\n '
if (len(kline_names) == 0):
kline_names = list(self.klines.keys())
save_path = self.cta_engine.get_data_path()
file_name = os.path.abspath(os.p... | 1,396,282,516,568,408,800 | 保存K线数据到缓存
:param kline_names: 一般为self.klines的keys
:return: | vnpy/app/cta_strategy_pro/template.py | save_klines_to_cache | UtorYeung/vnpy | python | def save_klines_to_cache(self, kline_names: list=[]):
'\n 保存K线数据到缓存\n :param kline_names: 一般为self.klines的keys\n :return:\n '
if (len(kline_names) == 0):
kline_names = list(self.klines.keys())
save_path = self.cta_engine.get_data_path()
file_name = os.path.abspath(os.p... |
def load_klines_from_cache(self, kline_names: list=[]):
'\n 从缓存加载K线数据\n :param kline_names:\n :return:\n '
if (len(kline_names) == 0):
kline_names = list(self.klines.keys())
save_path = self.cta_engine.get_data_path()
file_name = os.path.abspath(os.path.join(save_path... | -1,286,653,908,774,571,500 | 从缓存加载K线数据
:param kline_names:
:return: | vnpy/app/cta_strategy_pro/template.py | load_klines_from_cache | UtorYeung/vnpy | python | def load_klines_from_cache(self, kline_names: list=[]):
'\n 从缓存加载K线数据\n :param kline_names:\n :return:\n '
if (len(kline_names) == 0):
kline_names = list(self.klines.keys())
save_path = self.cta_engine.get_data_path()
file_name = os.path.abspath(os.path.join(save_path... |
def get_klines_snapshot(self):
'返回当前klines的切片数据'
try:
d = {'strategy': self.strategy_name, 'datetime': datetime.now()}
klines = {}
for kline_name in sorted(self.klines.keys()):
klines.update({kline_name: self.klines.get(kline_name).get_data()})
kline_names = list(klin... | -1,498,021,857,701,842,700 | 返回当前klines的切片数据 | vnpy/app/cta_strategy_pro/template.py | get_klines_snapshot | UtorYeung/vnpy | python | def get_klines_snapshot(self):
try:
d = {'strategy': self.strategy_name, 'datetime': datetime.now()}
klines = {}
for kline_name in sorted(self.klines.keys()):
klines.update({kline_name: self.klines.get(kline_name).get_data()})
kline_names = list(klines.keys())
... |
def init_position(self):
'\n 初始化Positin\n 使用网格的持久化,获取开仓状态的多空单,更新\n :return:\n '
self.write_log(u'init_position(),初始化持仓')
pos_symbols = set()
remove_ids = []
if (len(self.gt.up_grids) <= 0):
self.position.short_pos = 0
short_grids = self.gt.load(direction=D... | -3,441,370,031,846,856,000 | 初始化Positin
使用网格的持久化,获取开仓状态的多空单,更新
:return: | vnpy/app/cta_strategy_pro/template.py | init_position | UtorYeung/vnpy | python | def init_position(self):
'\n 初始化Positin\n 使用网格的持久化,获取开仓状态的多空单,更新\n :return:\n '
self.write_log(u'init_position(),初始化持仓')
pos_symbols = set()
remove_ids = []
if (len(self.gt.up_grids) <= 0):
self.position.short_pos = 0
short_grids = self.gt.load(direction=D... |
def get_positions(self):
"\n 获取策略当前持仓(重构,使用主力合约)\n :return: [{'vt_symbol':symbol,'direction':direction,'volume':volume]\n "
if (not self.position):
return []
pos_list = []
if (self.position.long_pos > 0):
for g in self.gt.get_opened_grids(direction=Direction.LONG):
... | -4,157,647,331,058,156,000 | 获取策略当前持仓(重构,使用主力合约)
:return: [{'vt_symbol':symbol,'direction':direction,'volume':volume] | vnpy/app/cta_strategy_pro/template.py | get_positions | UtorYeung/vnpy | python | def get_positions(self):
"\n 获取策略当前持仓(重构,使用主力合约)\n :return: [{'vt_symbol':symbol,'direction':direction,'volume':volume]\n "
if (not self.position):
return []
pos_list = []
if (self.position.long_pos > 0):
for g in self.gt.get_opened_grids(direction=Direction.LONG):
... |
def get_policy_json(self):
'获取policy的json格式数据'
if (not self.policy):
return None
data = self.policy.to_json()
return data | -7,284,977,415,092,988,000 | 获取policy的json格式数据 | vnpy/app/cta_strategy_pro/template.py | get_policy_json | UtorYeung/vnpy | python | def get_policy_json(self):
if (not self.policy):
return None
data = self.policy.to_json()
return data |
def get_grid_trade_json(self):
'获取gt组件的json格式数据'
if (not self.gt):
return None
data = self.gt.to_json()
return data | 1,568,559,070,898,897,000 | 获取gt组件的json格式数据 | vnpy/app/cta_strategy_pro/template.py | get_grid_trade_json | UtorYeung/vnpy | python | def get_grid_trade_json(self):
if (not self.gt):
return None
data = self.gt.to_json()
return data |
def tns_cancel_logic(self, dt, force=False):
'撤单逻辑'
if (len(self.active_orders) < 1):
self.entrust = 0
return
for vt_orderid in list(self.active_orders.keys()):
order_info = self.active_orders.get(vt_orderid)
order_grid = order_info.get('grid', None)
if (order_info.ge... | -7,555,482,025,060,726,000 | 撤单逻辑 | vnpy/app/cta_strategy_pro/template.py | tns_cancel_logic | UtorYeung/vnpy | python | def tns_cancel_logic(self, dt, force=False):
if (len(self.active_orders) < 1):
self.entrust = 0
return
for vt_orderid in list(self.active_orders.keys()):
order_info = self.active_orders.get(vt_orderid)
order_grid = order_info.get('grid', None)
if (order_info.get('sta... |
def tns_switch_long_pos(self, open_new=True):
'\n 切换合约,从持仓的非主力合约,切换至主力合约\n :param open_new: 是否开仓主力合约\n :return:\n '
if (self.entrust != 0):
return
if (self.position.long_pos == 0):
return
if (self.cur_mi_price == 0):
return
none_mi_grid = None
... | -7,377,124,469,565,173,000 | 切换合约,从持仓的非主力合约,切换至主力合约
:param open_new: 是否开仓主力合约
:return: | vnpy/app/cta_strategy_pro/template.py | tns_switch_long_pos | UtorYeung/vnpy | python | def tns_switch_long_pos(self, open_new=True):
'\n 切换合约,从持仓的非主力合约,切换至主力合约\n :param open_new: 是否开仓主力合约\n :return:\n '
if (self.entrust != 0):
return
if (self.position.long_pos == 0):
return
if (self.cur_mi_price == 0):
return
none_mi_grid = None
... |
def tns_switch_short_pos(self, open_new=True):
'\n 切换合约,从持仓的非主力合约,切换至主力合约\n :param open_new: 是否开仓新得主力合约\n :return:\n '
if (self.entrust != 0):
return
if (self.position.short_pos == 0):
return
if (self.cur_mi_price == 0):
return
none_mi_grid = None
... | -2,319,968,849,727,294,500 | 切换合约,从持仓的非主力合约,切换至主力合约
:param open_new: 是否开仓新得主力合约
:return: | vnpy/app/cta_strategy_pro/template.py | tns_switch_short_pos | UtorYeung/vnpy | python | def tns_switch_short_pos(self, open_new=True):
'\n 切换合约,从持仓的非主力合约,切换至主力合约\n :param open_new: 是否开仓新得主力合约\n :return:\n '
if (self.entrust != 0):
return
if (self.position.short_pos == 0):
return
if (self.cur_mi_price == 0):
return
none_mi_grid = None
... |
def display_grids(self):
'更新网格显示信息'
if (not self.inited):
return
up_grids_info = self.gt.to_str(direction=Direction.SHORT)
if (len(self.gt.up_grids) > 0):
self.write_log(up_grids_info)
dn_grids_info = self.gt.to_str(direction=Direction.LONG)
if (len(self.gt.dn_grids) > 0):
... | -7,978,628,409,817,070,000 | 更新网格显示信息 | vnpy/app/cta_strategy_pro/template.py | display_grids | UtorYeung/vnpy | python | def display_grids(self):
if (not self.inited):
return
up_grids_info = self.gt.to_str(direction=Direction.SHORT)
if (len(self.gt.up_grids) > 0):
self.write_log(up_grids_info)
dn_grids_info = self.gt.to_str(direction=Direction.LONG)
if (len(self.gt.dn_grids) > 0):
self.wri... |
def display_tns(self):
'显示事务的过程记录=》 log'
if (not self.inited):
return
self.write_log(u'{} 当前指数{}价格:{},当前主力{}价格:{}'.format(self.cur_datetime, self.idx_symbol, self.cur_99_price, self.vt_symbol, self.cur_mi_price))
if hasattr(self, 'policy'):
policy = getattr(self, 'policy')
op = g... | -1,050,589,898,606,807,700 | 显示事务的过程记录=》 log | vnpy/app/cta_strategy_pro/template.py | display_tns | UtorYeung/vnpy | python | def display_tns(self):
if (not self.inited):
return
self.write_log(u'{} 当前指数{}价格:{},当前主力{}价格:{}'.format(self.cur_datetime, self.idx_symbol, self.cur_99_price, self.vt_symbol, self.cur_mi_price))
if hasattr(self, 'policy'):
policy = getattr(self, 'policy')
op = getattr(policy, 't... |
def save_dist(self, dist_data):
'\n 保存策略逻辑过程记录=》 csv文件按\n :param dist_data:\n :return:\n '
if self.backtesting:
save_path = self.cta_engine.get_logs_path()
else:
save_path = self.cta_engine.get_data_path()
try:
if (self.position and ('long_pos' not in ... | 6,534,891,654,396,555,000 | 保存策略逻辑过程记录=》 csv文件按
:param dist_data:
:return: | vnpy/app/cta_strategy_pro/template.py | save_dist | UtorYeung/vnpy | python | def save_dist(self, dist_data):
'\n 保存策略逻辑过程记录=》 csv文件按\n :param dist_data:\n :return:\n '
if self.backtesting:
save_path = self.cta_engine.get_logs_path()
else:
save_path = self.cta_engine.get_data_path()
try:
if (self.position and ('long_pos' not in ... |
def save_tns(self, tns_data):
'\n 保存多空事务记录=》csv文件,便于后续分析\n :param tns_data: {"datetime":xxx, "direction":"long"或者"short", "price":xxx}\n :return:\n '
if self.backtesting:
save_path = self.cta_engine.get_logs_path()
else:
save_path = self.cta_engine.get_data_path()... | 3,043,168,499,550,988,000 | 保存多空事务记录=》csv文件,便于后续分析
:param tns_data: {"datetime":xxx, "direction":"long"或者"short", "price":xxx}
:return: | vnpy/app/cta_strategy_pro/template.py | save_tns | UtorYeung/vnpy | python | def save_tns(self, tns_data):
'\n 保存多空事务记录=》csv文件,便于后续分析\n :param tns_data: {"datetime":xxx, "direction":"long"或者"short", "price":xxx}\n :return:\n '
if self.backtesting:
save_path = self.cta_engine.get_logs_path()
else:
save_path = self.cta_engine.get_data_path()... |
def send_wechat(self, msg: str):
'实盘时才发送微信'
if self.backtesting:
return
self.cta_engine.send_wechat(msg=msg, strategy=self) | 4,796,113,719,315,409,000 | 实盘时才发送微信 | vnpy/app/cta_strategy_pro/template.py | send_wechat | UtorYeung/vnpy | python | def send_wechat(self, msg: str):
if self.backtesting:
return
self.cta_engine.send_wechat(msg=msg, strategy=self) |
def update_setting(self, setting: dict):
'更新配置参数'
super().update_setting(setting)
if (not self.backtesting):
if self.activate_fak:
self.order_type = OrderType.FAK | 8,905,263,113,275,753,000 | 更新配置参数 | vnpy/app/cta_strategy_pro/template.py | update_setting | UtorYeung/vnpy | python | def update_setting(self, setting: dict):
super().update_setting(setting)
if (not self.backtesting):
if self.activate_fak:
self.order_type = OrderType.FAK |
def load_policy(self):
'加载policy'
if self.policy:
self.write_log(u'load_policy(),初始化Policy')
self.policy.load()
self.write_log(u'Policy:{}'.format(self.policy.to_json())) | -1,173,244,053,206,510,600 | 加载policy | vnpy/app/cta_strategy_pro/template.py | load_policy | UtorYeung/vnpy | python | def load_policy(self):
if self.policy:
self.write_log(u'load_policy(),初始化Policy')
self.policy.load()
self.write_log(u'Policy:{}'.format(self.policy.to_json())) |
def on_start(self):
'启动策略(必须由用户继承实现)'
self.write_log(u'启动')
self.trading = True
self.put_event() | -5,815,070,311,948,098,000 | 启动策略(必须由用户继承实现) | vnpy/app/cta_strategy_pro/template.py | on_start | UtorYeung/vnpy | python | def on_start(self):
self.write_log(u'启动')
self.trading = True
self.put_event() |
def on_stop(self):
'停止策略(必须由用户继承实现)'
self.active_orders.clear()
self.pos = 0
self.entrust = 0
self.write_log(u'停止')
self.put_event() | -7,447,439,848,410,118,000 | 停止策略(必须由用户继承实现) | vnpy/app/cta_strategy_pro/template.py | on_stop | UtorYeung/vnpy | python | def on_stop(self):
self.active_orders.clear()
self.pos = 0
self.entrust = 0
self.write_log(u'停止')
self.put_event() |
def on_trade(self, trade: TradeData):
'\n 交易更新\n 支持股指期货的对锁单或者解锁\n :param trade:\n :return:\n '
self.write_log(u'{},交易更新 =>{},\n 当前持仓:{} '.format(self.cur_datetime, trade.__dict__, self.position.pos))
dist_record = dict()
if self.backtesting:
dist_record['dateti... | -1,073,388,828,579,977,900 | 交易更新
支持股指期货的对锁单或者解锁
:param trade:
:return: | vnpy/app/cta_strategy_pro/template.py | on_trade | UtorYeung/vnpy | python | def on_trade(self, trade: TradeData):
'\n 交易更新\n 支持股指期货的对锁单或者解锁\n :param trade:\n :return:\n '
self.write_log(u'{},交易更新 =>{},\n 当前持仓:{} '.format(self.cur_datetime, trade.__dict__, self.position.pos))
dist_record = dict()
if self.backtesting:
dist_record['dateti... |
def fix_order(self, order: OrderData):
'修正order被拆单得情况'
order_info = self.active_orders.get(order.vt_orderid, None)
if order_info:
volume = order_info.get('volume')
if (volume != order.volume):
self.write_log(f'修正order被拆单得情况,调整{order.vt_orderid} volume:{volume}=>{order.volume}')
... | -1,537,104,623,017,642,000 | 修正order被拆单得情况 | vnpy/app/cta_strategy_pro/template.py | fix_order | UtorYeung/vnpy | python | def fix_order(self, order: OrderData):
order_info = self.active_orders.get(order.vt_orderid, None)
if order_info:
volume = order_info.get('volume')
if (volume != order.volume):
self.write_log(f',调整{order.vt_orderid} volume:{volume}=>{order.volume}')
order_info.update... |
def on_order(self, order: OrderData):
'报单更新'
self.write_log(u'{}报单更新 => {}'.format(self.cur_datetime, order.__dict__))
self.fix_order(order)
if (order.vt_orderid in self.active_orders):
active_order = self.active_orders[order.vt_orderid]
if ((order.volume == order.traded) and (order.stat... | -6,724,270,649,476,190,000 | 报单更新 | vnpy/app/cta_strategy_pro/template.py | on_order | UtorYeung/vnpy | python | def on_order(self, order: OrderData):
self.write_log(u'{} => {}'.format(self.cur_datetime, order.__dict__))
self.fix_order(order)
if (order.vt_orderid in self.active_orders):
active_order = self.active_orders[order.vt_orderid]
if ((order.volume == order.traded) and (order.status in [Sta... |
def on_order_all_traded(self, order: OrderData):
'\n 订单全部成交\n :param order:\n :return:\n '
self.write_log(u'报单更新 => 委托单全部完成:{}'.format(order.__dict__))
active_order = self.active_orders[order.vt_orderid]
grid = active_order.get('grid', None)
if (grid is not None):
... | 7,630,674,831,798,039,000 | 订单全部成交
:param order:
:return: | vnpy/app/cta_strategy_pro/template.py | on_order_all_traded | UtorYeung/vnpy | python | def on_order_all_traded(self, order: OrderData):
'\n 订单全部成交\n :param order:\n :return:\n '
self.write_log(u'报单更新 => 委托单全部完成:{}'.format(order.__dict__))
active_order = self.active_orders[order.vt_orderid]
grid = active_order.get('grid', None)
if (grid is not None):
... |
def on_order_open_canceled(self, order: OrderData):
'\n 委托开仓单撤销\n 如果是FAK模式,重新修改价格,再提交\n FAK用于实盘,需要增加涨跌停判断\n :param order:\n :return:\n '
self.write_log(u'报单更新 => 委托开仓 => 撤销:{}'.format(order.__dict__))
if (not self.trading):
if (not self.backtesting):
... | -5,928,078,699,495,564,000 | 委托开仓单撤销
如果是FAK模式,重新修改价格,再提交
FAK用于实盘,需要增加涨跌停判断
:param order:
:return: | vnpy/app/cta_strategy_pro/template.py | on_order_open_canceled | UtorYeung/vnpy | python | def on_order_open_canceled(self, order: OrderData):
'\n 委托开仓单撤销\n 如果是FAK模式,重新修改价格,再提交\n FAK用于实盘,需要增加涨跌停判断\n :param order:\n :return:\n '
self.write_log(u'报单更新 => 委托开仓 => 撤销:{}'.format(order.__dict__))
if (not self.trading):
if (not self.backtesting):
... |
def on_order_close_canceled(self, order: OrderData):
'委托平仓单撤销'
self.write_log(u'报单更新 => 委托平仓 => 撤销:{}'.format(order.__dict__))
if (order.vt_orderid not in self.active_orders):
self.write_error(u'{}不在未完成的委托单中:{}。'.format(order.vt_orderid, self.active_orders))
return
if (not self.trading):... | 2,936,763,617,247,122,400 | 委托平仓单撤销 | vnpy/app/cta_strategy_pro/template.py | on_order_close_canceled | UtorYeung/vnpy | python | def on_order_close_canceled(self, order: OrderData):
self.write_log(u'报单更新 => 委托平仓 => 撤销:{}'.format(order.__dict__))
if (order.vt_orderid not in self.active_orders):
self.write_error(u'{}不在未完成的委托单中:{}。'.format(order.vt_orderid, self.active_orders))
return
if (not self.trading):
... |
def on_stop_order(self, stop_order: StopOrder):
'\n 停止单更新\n 需要自己重载,处理各类触发、撤单等情况\n '
self.write_log(f'停止单触发:{stop_order.__dict__}') | 3,201,659,518,581,367,000 | 停止单更新
需要自己重载,处理各类触发、撤单等情况 | vnpy/app/cta_strategy_pro/template.py | on_stop_order | UtorYeung/vnpy | python | def on_stop_order(self, stop_order: StopOrder):
'\n 停止单更新\n 需要自己重载,处理各类触发、撤单等情况\n '
self.write_log(f'停止单触发:{stop_order.__dict__}') |
def cancel_all_orders(self):
'\n 重载撤销所有正在进行得委托\n :return:\n '
self.write_log(u'撤销所有正在进行得委托')
self.tns_cancel_logic(dt=datetime.now(), force=True, reopen=False) | 5,625,485,002,846,538,000 | 重载撤销所有正在进行得委托
:return: | vnpy/app/cta_strategy_pro/template.py | cancel_all_orders | UtorYeung/vnpy | python | def cancel_all_orders(self):
'\n 重载撤销所有正在进行得委托\n :return:\n '
self.write_log(u'撤销所有正在进行得委托')
self.tns_cancel_logic(dt=datetime.now(), force=True, reopen=False) |
def tns_cancel_logic(self, dt, force=False, reopen=False):
'撤单逻辑'
if (len(self.active_orders) < 1):
self.entrust = 0
return
canceled_ids = []
for vt_orderid in list(self.active_orders.keys()):
order_info = self.active_orders[vt_orderid]
order_vt_symbol = order_info.get('v... | 5,498,034,421,116,743,000 | 撤单逻辑 | vnpy/app/cta_strategy_pro/template.py | tns_cancel_logic | UtorYeung/vnpy | python | def tns_cancel_logic(self, dt, force=False, reopen=False):
if (len(self.active_orders) < 1):
self.entrust = 0
return
canceled_ids = []
for vt_orderid in list(self.active_orders.keys()):
order_info = self.active_orders[vt_orderid]
order_vt_symbol = order_info.get('vt_symb... |
def tns_close_long_pos(self, grid):
'\n 事务平多单仓位\n 1.来源自止损止盈平仓\n 逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.\n :param 平仓网格\n :return:\n '
self.write_log(u'执行事务平多仓位:{}'.format(grid.to_json()))
sell_symbol = grid.snapshot.get('mi_symbol', self.vt_symbol)
grid_pos = self... | -4,714,678,350,882,631,000 | 事务平多单仓位
1.来源自止损止盈平仓
逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.
:param 平仓网格
:return: | vnpy/app/cta_strategy_pro/template.py | tns_close_long_pos | UtorYeung/vnpy | python | def tns_close_long_pos(self, grid):
'\n 事务平多单仓位\n 1.来源自止损止盈平仓\n 逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.\n :param 平仓网格\n :return:\n '
self.write_log(u'执行事务平多仓位:{}'.format(grid.to_json()))
sell_symbol = grid.snapshot.get('mi_symbol', self.vt_symbol)
grid_pos = self... |
def tns_close_short_pos(self, grid):
'\n 事务平空单仓位\n 1.来源自止损止盈平仓\n 2.来源自换仓\n 逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.\n :param 平仓网格\n :return:\n '
self.write_log(u'执行事务平空仓位:{}'.format(grid.to_json()))
cover_symbol = grid.snapshot.get('mi_symbol', self.vt_symbol)
... | -5,664,663,188,158,522,000 | 事务平空单仓位
1.来源自止损止盈平仓
2.来源自换仓
逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.
:param 平仓网格
:return: | vnpy/app/cta_strategy_pro/template.py | tns_close_short_pos | UtorYeung/vnpy | python | def tns_close_short_pos(self, grid):
'\n 事务平空单仓位\n 1.来源自止损止盈平仓\n 2.来源自换仓\n 逻辑: 如果当前账号昨仓满足平仓数量,直接平仓,如果不满足,则创建锁仓网格.\n :param 平仓网格\n :return:\n '
self.write_log(u'执行事务平空仓位:{}'.format(grid.to_json()))
cover_symbol = grid.snapshot.get('mi_symbol', self.vt_symbol)
... |
def tns_open_from_lock(self, open_symbol, open_volume, grid_type, open_direction):
'\n 从锁仓单中,获取已开的网格(对手仓设置为止损)\n 1, 检查多空锁仓单中,是否有满足数量得昨仓,\n 2, 定位到需求网格,\n :param open_symbol: 开仓合约(主力合约)\n :param open_volume:\n :param grid_type 更新网格的类型\n :param open_direction: 开仓方向\n ... | 4,465,916,099,554,728,000 | 从锁仓单中,获取已开的网格(对手仓设置为止损)
1, 检查多空锁仓单中,是否有满足数量得昨仓,
2, 定位到需求网格,
:param open_symbol: 开仓合约(主力合约)
:param open_volume:
:param grid_type 更新网格的类型
:param open_direction: 开仓方向
:return: None, 保留的格 | vnpy/app/cta_strategy_pro/template.py | tns_open_from_lock | UtorYeung/vnpy | python | def tns_open_from_lock(self, open_symbol, open_volume, grid_type, open_direction):
'\n 从锁仓单中,获取已开的网格(对手仓设置为止损)\n 1, 检查多空锁仓单中,是否有满足数量得昨仓,\n 2, 定位到需求网格,\n :param open_symbol: 开仓合约(主力合约)\n :param open_volume:\n :param grid_type 更新网格的类型\n :param open_direction: 开仓方向\n ... |
def tns_close_locked_grids(self, grid_type):
'\n 事务对所有对锁网格进行平仓\n :return:\n '
if (self.entrust != 0):
return
if (not self.activate_today_lock):
return
locked_long_grids = self.gt.get_opened_grids_within_types(direction=Direction.LONG, types=[LOCK_GRID])
if (len(l... | -4,562,718,120,327,982,000 | 事务对所有对锁网格进行平仓
:return: | vnpy/app/cta_strategy_pro/template.py | tns_close_locked_grids | UtorYeung/vnpy | python | def tns_close_locked_grids(self, grid_type):
'\n 事务对所有对锁网格进行平仓\n :return:\n '
if (self.entrust != 0):
return
if (not self.activate_today_lock):
return
locked_long_grids = self.gt.get_opened_grids_within_types(direction=Direction.LONG, types=[LOCK_GRID])
if (len(l... |
def grid_check_stop(self):
'\n 网格逐一止损/止盈检查 (根据指数价格进行止损止盈)\n :return:\n '
if (self.entrust != 0):
return
if (not self.trading):
if (not self.backtesting):
self.write_error(u'当前不允许交易')
return
long_grids = self.gt.get_opened_grids_without_types(direc... | -1,047,088,386,559,161,900 | 网格逐一止损/止盈检查 (根据指数价格进行止损止盈)
:return: | vnpy/app/cta_strategy_pro/template.py | grid_check_stop | UtorYeung/vnpy | python | def grid_check_stop(self):
'\n 网格逐一止损/止盈检查 (根据指数价格进行止损止盈)\n :return:\n '
if (self.entrust != 0):
return
if (not self.trading):
if (not self.backtesting):
self.write_error(u'当前不允许交易')
return
long_grids = self.gt.get_opened_grids_without_types(direc... |
def logando_notification(tipo, mensagem):
"\n Generates the log message/Gera a mensagem de log.\n\n :param tipo: Sets the log type/Seta o tipo de log.\n :param mensagem: Sets the message of log/Seta a mensagem do log.\n :return: Returns the complete log's body/Retorna o corpo completo do log.\n "
... | 2,179,398,016,320,366,000 | Generates the log message/Gera a mensagem de log.
:param tipo: Sets the log type/Seta o tipo de log.
:param mensagem: Sets the message of log/Seta a mensagem do log.
:return: Returns the complete log's body/Retorna o corpo completo do log. | Linux/etc/notification/telegram.py | logando_notification | 4jinetes/Oblivion | python | def logando_notification(tipo, mensagem):
"\n Generates the log message/Gera a mensagem de log.\n\n :param tipo: Sets the log type/Seta o tipo de log.\n :param mensagem: Sets the message of log/Seta a mensagem do log.\n :return: Returns the complete log's body/Retorna o corpo completo do log.\n "
... |
def notificar_telegram(status_nosafe=False, data_nosafe=None):
'\n Generates the notification to Telegram account/Gera a notificação para a conta do Telegram.\n '
usuarios = []
with open(f'{path_tl_final}/etc/notification/users.txt', 'r') as lista:
separar = lista.readlines()
if status_nos... | -4,091,007,493,826,592,000 | Generates the notification to Telegram account/Gera a notificação para a conta do Telegram. | Linux/etc/notification/telegram.py | notificar_telegram | 4jinetes/Oblivion | python | def notificar_telegram(status_nosafe=False, data_nosafe=None):
'\n \n '
usuarios = []
with open(f'{path_tl_final}/etc/notification/users.txt', 'r') as lista:
separar = lista.readlines()
if status_nosafe:
mensagem = str(data_nosafe)
else:
with open(f'{path_tl_final}/etc/... |
def send_message(chat_id, text=None, parse_mode='Markdown', token=None):
'\n Sends message in bold mode/Enviar mensagem em negrito.\n\n :param chat_id: ID of Telegram account/ID da conta Telgram.\n :param text: Message/Mensagem.\n :param parse_mode: Ignore.\n :param token: ID Telegram bot/ID do bot T... | 5,812,060,372,968,654,000 | Sends message in bold mode/Enviar mensagem em negrito.
:param chat_id: ID of Telegram account/ID da conta Telgram.
:param text: Message/Mensagem.
:param parse_mode: Ignore.
:param token: ID Telegram bot/ID do bot Telegram. | Linux/etc/notification/telegram.py | send_message | 4jinetes/Oblivion | python | def send_message(chat_id, text=None, parse_mode='Markdown', token=None):
'\n Sends message in bold mode/Enviar mensagem em negrito.\n\n :param chat_id: ID of Telegram account/ID da conta Telgram.\n :param text: Message/Mensagem.\n :param parse_mode: Ignore.\n :param token: ID Telegram bot/ID do bot T... |
async def _on_input(self, command, seat):
'Switch input functionality\n\n Calls on and off depending on command state\n :param command: Command from game engine\n :type command: dict\n :param seat: Robot seat\n :type seat: int\n '
if ('state' not in command):
lo... | -7,261,439,614,335,508,000 | Switch input functionality
Calls on and off depending on command state
:param command: Command from game engine
:type command: dict
:param seat: Robot seat
:type seat: int | surrortg/inputs/switch.py | _on_input | SurrogateInc/surrortg-sdk | python | async def _on_input(self, command, seat):
'Switch input functionality\n\n Calls on and off depending on command state\n :param command: Command from game engine\n :type command: dict\n :param seat: Robot seat\n :type seat: int\n '
if ('state' not in command):
lo... |
@abstractmethod
async def on(self, seat):
'Switch turned on functionality\n\n :param seat: Robot seat\n :type seat: int\n '
pass | -6,835,234,047,209,246,000 | Switch turned on functionality
:param seat: Robot seat
:type seat: int | surrortg/inputs/switch.py | on | SurrogateInc/surrortg-sdk | python | @abstractmethod
async def on(self, seat):
'Switch turned on functionality\n\n :param seat: Robot seat\n :type seat: int\n '
pass |
@abstractmethod
async def off(self, seat):
'Switch turned off functionality\n\n :param seat: Robot seat\n :type seat: int\n '
pass | -2,710,125,614,147,228,700 | Switch turned off functionality
:param seat: Robot seat
:type seat: int | surrortg/inputs/switch.py | off | SurrogateInc/surrortg-sdk | python | @abstractmethod
async def off(self, seat):
'Switch turned off functionality\n\n :param seat: Robot seat\n :type seat: int\n '
pass |
async def reset(self, seat):
'Switch reset functionality\n\n Defaults to calling off()\n\n :param seat: Robot seat\n :type seat: int\n '
(await self.off(seat)) | -6,922,977,932,009,814,000 | Switch reset functionality
Defaults to calling off()
:param seat: Robot seat
:type seat: int | surrortg/inputs/switch.py | reset | SurrogateInc/surrortg-sdk | python | async def reset(self, seat):
'Switch reset functionality\n\n Defaults to calling off()\n\n :param seat: Robot seat\n :type seat: int\n '
(await self.off(seat)) |
def get_name(self):
'Returns the name of the input\n\n :return: name of the input\n :rtype: str\n '
return 'button' | 3,793,174,537,542,569,500 | Returns the name of the input
:return: name of the input
:rtype: str | surrortg/inputs/switch.py | get_name | SurrogateInc/surrortg-sdk | python | def get_name(self):
'Returns the name of the input\n\n :return: name of the input\n :rtype: str\n '
return 'button' |
def get_default_keybinds(self):
'Returns a single keybind or a list of keybinds.\n\n Switches are bound to the space key by default.\n\n To override the defaults, override this method in your switch\n subclass and return different keybinds.\n '
return [] | -132,505,091,344,185,620 | Returns a single keybind or a list of keybinds.
Switches are bound to the space key by default.
To override the defaults, override this method in your switch
subclass and return different keybinds. | surrortg/inputs/switch.py | get_default_keybinds | SurrogateInc/surrortg-sdk | python | def get_default_keybinds(self):
'Returns a single keybind or a list of keybinds.\n\n Switches are bound to the space key by default.\n\n To override the defaults, override this method in your switch\n subclass and return different keybinds.\n '
return [] |
@classmethod
def _cnn_net(cls):
'\n Create the CNN net topology.\n :return keras.Sequential(): CNN topology.\n '
qrs_detector = keras.Sequential()
qrs_detector.add(keras.layers.Conv1D(96, 49, activation=tf.nn.relu, input_shape=(300, 1), strides=1, name='conv1'))
qrs_detector.add(ker... | 4,818,998,698,767,064,000 | Create the CNN net topology.
:return keras.Sequential(): CNN topology. | python/qrs/qrs_net.py | _cnn_net | ufopcsilab/ECGClassification | python | @classmethod
def _cnn_net(cls):
'\n Create the CNN net topology.\n :return keras.Sequential(): CNN topology.\n '
qrs_detector = keras.Sequential()
qrs_detector.add(keras.layers.Conv1D(96, 49, activation=tf.nn.relu, input_shape=(300, 1), strides=1, name='conv1'))
qrs_detector.add(ker... |
@classmethod
def build(cls, net_type):
'\n Build the CNN topology.\n :param str net_type: the network type, CNN or LSTM.\n :return keras.Sequential(): CNN topology.\n '
if (net_type == 'cnn'):
qrs_detector = cls._cnn_net()
else:
raise NotImplementedError('Only the... | -4,566,898,852,637,497,300 | Build the CNN topology.
:param str net_type: the network type, CNN or LSTM.
:return keras.Sequential(): CNN topology. | python/qrs/qrs_net.py | build | ufopcsilab/ECGClassification | python | @classmethod
def build(cls, net_type):
'\n Build the CNN topology.\n :param str net_type: the network type, CNN or LSTM.\n :return keras.Sequential(): CNN topology.\n '
if (net_type == 'cnn'):
qrs_detector = cls._cnn_net()
else:
raise NotImplementedError('Only the... |
@classmethod
def _prepare_data(cls, data_x, input_shape, data_y, number_of_classes, normalize):
'\n Prepare the data for the training, turning it into a numpy array.\n :param list data_x: data that will be used to train.\n :param tuple input_shape: the input shape that the data must have to be ... | -6,894,264,797,384,032,000 | Prepare the data for the training, turning it into a numpy array.
:param list data_x: data that will be used to train.
:param tuple input_shape: the input shape that the data must have to be used as training data.
:param list data_y: the labels related to the data used to train.
:param int number_of_classes: number of ... | python/qrs/qrs_net.py | _prepare_data | ufopcsilab/ECGClassification | python | @classmethod
def _prepare_data(cls, data_x, input_shape, data_y, number_of_classes, normalize):
'\n Prepare the data for the training, turning it into a numpy array.\n :param list data_x: data that will be used to train.\n :param tuple input_shape: the input shape that the data must have to be ... |
@classmethod
def train(cls, model, train_x, train_y, validation_x, validation_y, number_of_classes, input_shape=(300, 1), epochs=10, lr=0.0001, batch_size=4, optimizer=None, loss=None, metrics=None, normalize=False, show_net_info=True):
'\n Function used to train the model.\n :param keras.Sequential m... | -7,580,206,974,420,679,000 | Function used to train the model.
:param keras.Sequential model: model to be trained.
:param list train_x: data that will be used to train.
:param list train_y: the labels related to the data used to train.
:param list validation_x: data that will be used to validate the model trained.
:param list validation_y: the lab... | python/qrs/qrs_net.py | train | ufopcsilab/ECGClassification | python | @classmethod
def train(cls, model, train_x, train_y, validation_x, validation_y, number_of_classes, input_shape=(300, 1), epochs=10, lr=0.0001, batch_size=4, optimizer=None, loss=None, metrics=None, normalize=False, show_net_info=True):
'\n Function used to train the model.\n :param keras.Sequential m... |
def _convert_dataset_to_ground_truth(self, dataset_bboxes):
'\n @param `dataset_bboxes`: [[b_x, b_y, b_w, b_h, class_id], ...]\n\n @return `groud_truth_one`:\n [Dim(yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo)\n '
return _convert_dataset_to_ground_truth(dataset_bboxes, self._... | 5,234,496,081,387,635,000 | @param `dataset_bboxes`: [[b_x, b_y, b_w, b_h, class_id], ...]
@return `groud_truth_one`:
[Dim(yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo) | py_src/yolov4/tf/dataset/keras_sequence.py | _convert_dataset_to_ground_truth | fcakyon/tensorflow-yolov4 | python | def _convert_dataset_to_ground_truth(self, dataset_bboxes):
'\n @param `dataset_bboxes`: [[b_x, b_y, b_w, b_h, class_id], ...]\n\n @return `groud_truth_one`:\n [Dim(yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo)\n '
return _convert_dataset_to_ground_truth(dataset_bboxes, self._... |
def _convert_dataset_to_image_and_bboxes(self, dataset):
'\n @param dataset: [image_path, [[x, y, w, h, class_id], ...]]\n\n @return image, bboxes\n image: 0.0 ~ 1.0, Dim(1, height, width, channels)\n '
try:
image = cv2.imread(dataset[0])
image = cv2.cvtColor(imag... | -5,174,543,971,841,476,000 | @param dataset: [image_path, [[x, y, w, h, class_id], ...]]
@return image, bboxes
image: 0.0 ~ 1.0, Dim(1, height, width, channels) | py_src/yolov4/tf/dataset/keras_sequence.py | _convert_dataset_to_image_and_bboxes | fcakyon/tensorflow-yolov4 | python | def _convert_dataset_to_image_and_bboxes(self, dataset):
'\n @param dataset: [image_path, [[x, y, w, h, class_id], ...]]\n\n @return image, bboxes\n image: 0.0 ~ 1.0, Dim(1, height, width, channels)\n '
try:
image = cv2.imread(dataset[0])
image = cv2.cvtColor(imag... |
def __getitem__(self, index):
'\n @return\n `images`: Dim(batch, height, width, channels)\n `groud_truth_one`:\n [Dim(batch, yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo)\n '
batch_x = []
batch_y = [[] for _ in range(len(self._metayolos))]
start_inde... | -8,114,848,881,290,818,000 | @return
`images`: Dim(batch, height, width, channels)
`groud_truth_one`:
[Dim(batch, yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo) | py_src/yolov4/tf/dataset/keras_sequence.py | __getitem__ | fcakyon/tensorflow-yolov4 | python | def __getitem__(self, index):
'\n @return\n `images`: Dim(batch, height, width, channels)\n `groud_truth_one`:\n [Dim(batch, yolo.h, yolo.w, yolo.c + len(mask))] * len(yolo)\n '
batch_x = []
batch_y = [[] for _ in range(len(self._metayolos))]
start_inde... |
def setup_logging(name, dir=''):
'\n Setup the logging device to log into a uniquely created directory.\n\n Args:\n name: Name of the directory for the log-files.\n dir: Optional sub-directory within log\n '
global log_name
log_name = name
global log_dir
log_dir = os.path.join... | -7,427,697,294,495,630,000 | Setup the logging device to log into a uniquely created directory.
Args:
name: Name of the directory for the log-files.
dir: Optional sub-directory within log | lib/config.py | setup_logging | SudeepSarkar/equilibrium-propagation | python | def setup_logging(name, dir=):
'\n Setup the logging device to log into a uniquely created directory.\n\n Args:\n name: Name of the directory for the log-files.\n dir: Optional sub-directory within log\n '
global log_name
log_name = name
global log_dir
log_dir = os.path.join('... |
def __init__(self, lf, lr, mass, Iz, Cf, Cr, Bf=None, Br=None, Df=None, Dr=None, Cm1=None, Cm2=None, Cr0=None, Cr2=None, input_acc=False, **kwargs):
'\tspecify model params here\n\t\t'
self.lf = lf
self.lr = lr
self.dr = (lr / (lf + lr))
self.mass = mass
self.Iz = Iz
self.Cf = Cf
self.Cr... | -3,487,673,847,780,308,500 | specify model params here | bayes_race/models/dynamic.py | __init__ | KlrShaK/bayesrace | python | def __init__(self, lf, lr, mass, Iz, Cf, Cr, Bf=None, Br=None, Df=None, Dr=None, Cm1=None, Cm2=None, Cr0=None, Cr2=None, input_acc=False, **kwargs):
'\t\n\t\t'
self.lf = lf
self.lr = lr
self.dr = (lr / (lf + lr))
self.mass = mass
self.Iz = Iz
self.Cf = Cf
self.Cr = Cr
self.Bf = Bf
... |
def sim_continuous(self, x0, u, t):
'\tsimulates the nonlinear continuous model with given input vector\n\t\t\tby numerical integration using 6th order Runge Kutta method\n\t\t\tx0 is the initial state of size 6x1\n\t\t\tu is the input vector of size 2xn\n\t\t\tt is the time vector of size 1x(n+1)\n\t\t'
n_step... | 8,414,995,335,463,568,000 | simulates the nonlinear continuous model with given input vector
by numerical integration using 6th order Runge Kutta method
x0 is the initial state of size 6x1
u is the input vector of size 2xn
t is the time vector of size 1x(n+1) | bayes_race/models/dynamic.py | sim_continuous | KlrShaK/bayesrace | python | def sim_continuous(self, x0, u, t):
'\tsimulates the nonlinear continuous model with given input vector\n\t\t\tby numerical integration using 6th order Runge Kutta method\n\t\t\tx0 is the initial state of size 6x1\n\t\t\tu is the input vector of size 2xn\n\t\t\tt is the time vector of size 1x(n+1)\n\t\t'
n_step... |
def _diffequation(self, t, x, u):
'\twrite dynamics as first order ODE: dxdt = f(x(t))\n\t\t\tx is a 6x1 vector: [x, y, psi, vx, vy, omega]^T\n\t\t\tu is a 2x1 vector: [acc/pwm, steer]^T\n\t\t'
steer = u[1]
psi = x[2]
vx = x[3]
vy = x[4]
omega = x[5]
(Ffy, Frx, Fry) = self.calc_forces(x, u)
... | -43,071,347,659,589,810 | write dynamics as first order ODE: dxdt = f(x(t))
x is a 6x1 vector: [x, y, psi, vx, vy, omega]^T
u is a 2x1 vector: [acc/pwm, steer]^T | bayes_race/models/dynamic.py | _diffequation | KlrShaK/bayesrace | python | def _diffequation(self, t, x, u):
'\twrite dynamics as first order ODE: dxdt = f(x(t))\n\t\t\tx is a 6x1 vector: [x, y, psi, vx, vy, omega]^T\n\t\t\tu is a 2x1 vector: [acc/pwm, steer]^T\n\t\t'
steer = u[1]
psi = x[2]
vx = x[3]
vy = x[4]
omega = x[5]
(Ffy, Frx, Fry) = self.calc_forces(x, u)
... |
def casadi(self, x, u, dxdt):
'\twrite dynamics as first order ODE: dxdt = f(x(t))\n\t\t\tx is a 6x1 vector: [x, y, psi, vx, vy, omega]^T\n\t\t\tu is a 2x1 vector: [acc/pwm, steer]^T\n\t\t\tdxdt is a casadi.SX variable\n\t\t'
pwm = u[0]
steer = u[1]
psi = x[2]
vx = x[3]
vy = x[4]
omega = x[5... | 2,081,638,097,302,288,000 | write dynamics as first order ODE: dxdt = f(x(t))
x is a 6x1 vector: [x, y, psi, vx, vy, omega]^T
u is a 2x1 vector: [acc/pwm, steer]^T
dxdt is a casadi.SX variable | bayes_race/models/dynamic.py | casadi | KlrShaK/bayesrace | python | def casadi(self, x, u, dxdt):
'\twrite dynamics as first order ODE: dxdt = f(x(t))\n\t\t\tx is a 6x1 vector: [x, y, psi, vx, vy, omega]^T\n\t\t\tu is a 2x1 vector: [acc/pwm, steer]^T\n\t\t\tdxdt is a casadi.SX variable\n\t\t'
pwm = u[0]
steer = u[1]
psi = x[2]
vx = x[3]
vy = x[4]
omega = x[5... |
def sim_discrete(self, x0, u, Ts):
'\tsimulates a continuously linearized discrete model\n\t\t\tu is the input vector of size 2xn\n\t\t\tTs is the sampling time\n\t\t'
n_steps = u.shape[1]
x = np.zeros([6, (n_steps + 1)])
dxdt = np.zeros([6, (n_steps + 1)])
dxdt[:, 0] = self._diffequation(None, x0, ... | -4,940,027,757,049,915,000 | simulates a continuously linearized discrete model
u is the input vector of size 2xn
Ts is the sampling time | bayes_race/models/dynamic.py | sim_discrete | KlrShaK/bayesrace | python | def sim_discrete(self, x0, u, Ts):
'\tsimulates a continuously linearized discrete model\n\t\t\tu is the input vector of size 2xn\n\t\t\tTs is the sampling time\n\t\t'
n_steps = u.shape[1]
x = np.zeros([6, (n_steps + 1)])
dxdt = np.zeros([6, (n_steps + 1)])
dxdt[:, 0] = self._diffequation(None, x0, ... |
def linearize(self, x0, u0):
'\tlinearize at a given x0, u0\n\t\t\tfor a given continuous system dxdt = f(x(t))\n\t\t\tcalculate A = ∂f/∂x, B = ∂f/∂u, g = f evaluated at x0, u0\n\t\t\tA is 6x6, B is 6x2, g is 6x1\n\t\t'
steer = u0[1]
psi = x0[2]
vx = x0[3]
vy = x0[4]
omega = x0[5]
vmin = 0.0... | 954,568,740,370,182,300 | linearize at a given x0, u0
for a given continuous system dxdt = f(x(t))
calculate A = ∂f/∂x, B = ∂f/∂u, g = f evaluated at x0, u0
A is 6x6, B is 6x2, g is 6x1 | bayes_race/models/dynamic.py | linearize | KlrShaK/bayesrace | python | def linearize(self, x0, u0):
'\tlinearize at a given x0, u0\n\t\t\tfor a given continuous system dxdt = f(x(t))\n\t\t\tcalculate A = ∂f/∂x, B = ∂f/∂u, g = f evaluated at x0, u0\n\t\t\tA is 6x6, B is 6x2, g is 6x1\n\t\t'
steer = u0[1]
psi = x0[2]
vx = x0[3]
vy = x0[4]
omega = x0[5]
vmin = 0.0... |
def custom_callback(self, value):
' A custom callback for dealing with tool output.\n '
if ('%' in value):
try:
str_array = value.split(' ')
label = value.replace(str_array[(len(str_array) - 1)], '').strip()
progress = float(str_array[(len(str_array) - 1)].repl... | -7,362,732,948,371,499,000 | A custom callback for dealing with tool output. | wb_runner.py | custom_callback | luzpaz/whitebox-tools | python | def custom_callback(self, value):
' \n '
if ('%' in value):
try:
str_array = value.split(' ')
label = value.replace(str_array[(len(str_array) - 1)], ).strip()
progress = float(str_array[(len(str_array) - 1)].replace('%', ).strip())
self.progress_var... |
def test_rollback(self, local_connection):
'test a basic rollback'
users = self.tables.users
connection = local_connection
transaction = connection.begin()
connection.execute(users.insert(), user_id=1, user_name='user1')
connection.execute(users.insert(), user_id=2, user_name='user2')
connec... | 228,207,505,830,494,270 | test a basic rollback | test/engine/test_transaction.py | test_rollback | 418sec/sqlalchemy | python | def test_rollback(self, local_connection):
users = self.tables.users
connection = local_connection
transaction = connection.begin()
connection.execute(users.insert(), user_id=1, user_name='user1')
connection.execute(users.insert(), user_id=2, user_name='user2')
connection.execute(users.inse... |
def test_rollback_deadlock(self):
'test that returning connections to the pool clears any object\n locks.'
conn1 = testing.db.connect()
conn2 = testing.db.connect()
users = Table('deadlock_users', metadata, Column('user_id', INT, primary_key=True), Column('user_name', VARCHAR(20)), test_needs_aci... | -1,619,799,357,194,359,600 | test that returning connections to the pool clears any object
locks. | test/engine/test_transaction.py | test_rollback_deadlock | 418sec/sqlalchemy | python | def test_rollback_deadlock(self):
'test that returning connections to the pool clears any object\n locks.'
conn1 = testing.db.connect()
conn2 = testing.db.connect()
users = Table('deadlock_users', metadata, Column('user_id', INT, primary_key=True), Column('user_name', VARCHAR(20)), test_needs_aci... |
def _nextPurge(self, source: BackupSource, backups, findNext=False):
'\n Given a list of backups, decides if one should be purged.\n '
if ((not source.enabled()) or (len(backups) == 0)):
return None
if ((source.maxCount() == 0) and (not self.config.get(Setting.DELETE_AFTER_UPLOAD))):
... | -8,841,430,968,765,923,000 | Given a list of backups, decides if one should be purged. | hassio-google-drive-backup/backup/model/model.py | _nextPurge | voxipbx/hassio-addons | python | def _nextPurge(self, source: BackupSource, backups, findNext=False):
'\n \n '
if ((not source.enabled()) or (len(backups) == 0)):
return None
if ((source.maxCount() == 0) and (not self.config.get(Setting.DELETE_AFTER_UPLOAD))):
return None
scheme = self._buildDeleteScheme(s... |
def __init__(self, position, discrete=False):
'\n Initializes a observation in light dark domain.\n\n Args:\n position (tuple): position of the robot.\n '
self._discrete = discrete
if (len(position) != 2):
raise ValueError('Observation position must be a vector of len... | -1,508,324,807,324,518,400 | Initializes a observation in light dark domain.
Args:
position (tuple): position of the robot. | pomdp_problems/light_dark/domain/observation.py | __init__ | Deathn0t/pomdp-py | python | def __init__(self, position, discrete=False):
'\n Initializes a observation in light dark domain.\n\n Args:\n position (tuple): position of the robot.\n '
self._discrete = discrete
if (len(position) != 2):
raise ValueError('Observation position must be a vector of len... |
def make_marketing_pref_receiver(sender, instance, created, *args, **kwargs):
'\n User model\n '
if created:
MarketingPreference.objects.get_or_create(user=instance) | -4,182,596,920,956,513,000 | User model | eCommerce-master/src/marketing/models.py | make_marketing_pref_receiver | felipebrigo/Python-Projects | python | def make_marketing_pref_receiver(sender, instance, created, *args, **kwargs):
'\n \n '
if created:
MarketingPreference.objects.get_or_create(user=instance) |
def _find_x12(x12path=None, prefer_x13=True):
'\n If x12path is not given, then either x13as[.exe] or x12a[.exe] must\n be found on the PATH. Otherwise, the environmental variable X12PATH or\n X13PATH must be defined. If prefer_x13 is True, only X13PATH is searched\n for. If it is false, only X12PATH is... | 5,155,090,809,194,233,000 | If x12path is not given, then either x13as[.exe] or x12a[.exe] must
be found on the PATH. Otherwise, the environmental variable X12PATH or
X13PATH must be defined. If prefer_x13 is True, only X13PATH is searched
for. If it is false, only X12PATH is searched for. | statsmodels/tsa/x13.py | _find_x12 | diego-mazon/statsmodels | python | def _find_x12(x12path=None, prefer_x13=True):
'\n If x12path is not given, then either x13as[.exe] or x12a[.exe] must\n be found on the PATH. Otherwise, the environmental variable X12PATH or\n X13PATH must be defined. If prefer_x13 is True, only X13PATH is searched\n for. If it is false, only X12PATH is... |
def _clean_order(order):
'\n Takes something like (1 1 0)(0 1 1) and returns a arma order, sarma\n order tuple. Also accepts (1 1 0) and return arma order and (0, 0, 0)\n '
order = re.findall('\\([0-9 ]*?\\)', order)
def clean(x):
return tuple(map(int, re.sub('[()]', '', x).split(' ')))
... | -271,275,661,211,769,340 | Takes something like (1 1 0)(0 1 1) and returns a arma order, sarma
order tuple. Also accepts (1 1 0) and return arma order and (0, 0, 0) | statsmodels/tsa/x13.py | _clean_order | diego-mazon/statsmodels | python | def _clean_order(order):
'\n Takes something like (1 1 0)(0 1 1) and returns a arma order, sarma\n order tuple. Also accepts (1 1 0) and return arma order and (0, 0, 0)\n '
order = re.findall('\\([0-9 ]*?\\)', order)
def clean(x):
return tuple(map(int, re.sub('[()]', , x).split(' ')))
... |
def _convert_out_to_series(x, dates, name):
'\n Convert x to a DataFrame where x is a string in the format given by\n x-13arima-seats output.\n '
from io import StringIO
from pandas import read_csv
out = read_csv(StringIO(x), skiprows=2, header=None, sep='\t', engine='python')
return out.se... | 8,948,449,459,947,929,000 | Convert x to a DataFrame where x is a string in the format given by
x-13arima-seats output. | statsmodels/tsa/x13.py | _convert_out_to_series | diego-mazon/statsmodels | python | def _convert_out_to_series(x, dates, name):
'\n Convert x to a DataFrame where x is a string in the format given by\n x-13arima-seats output.\n '
from io import StringIO
from pandas import read_csv
out = read_csv(StringIO(x), skiprows=2, header=None, sep='\t', engine='python')
return out.se... |
def x13_arima_analysis(endog, maxorder=(2, 1), maxdiff=(2, 1), diff=None, exog=None, log=None, outlier=True, trading=False, forecast_years=None, retspec=False, speconly=False, start=None, freq=None, print_stdout=False, x12path=None, prefer_x13=True):
'\n Perform x13-arima analysis for monthly or quarterly data.\... | 6,818,303,355,341,706,000 | Perform x13-arima analysis for monthly or quarterly data.
Parameters
----------
endog : array_like, pandas.Series
The series to model. It is best to use a pandas object with a
DatetimeIndex or PeriodIndex. However, you can pass an array-like
object. If your object does not have a dates index then ``start``... | statsmodels/tsa/x13.py | x13_arima_analysis | diego-mazon/statsmodels | python | def x13_arima_analysis(endog, maxorder=(2, 1), maxdiff=(2, 1), diff=None, exog=None, log=None, outlier=True, trading=False, forecast_years=None, retspec=False, speconly=False, start=None, freq=None, print_stdout=False, x12path=None, prefer_x13=True):
'\n Perform x13-arima analysis for monthly or quarterly data.\... |
def x13_arima_select_order(endog, maxorder=(2, 1), maxdiff=(2, 1), diff=None, exog=None, log=None, outlier=True, trading=False, forecast_years=None, start=None, freq=None, print_stdout=False, x12path=None, prefer_x13=True):
'\n Perform automatic seasonal ARIMA order identification using x12/x13 ARIMA.\n\n Par... | -2,889,664,093,120,679,000 | Perform automatic seasonal ARIMA order identification using x12/x13 ARIMA.
Parameters
----------
endog : array_like, pandas.Series
The series to model. It is best to use a pandas object with a
DatetimeIndex or PeriodIndex. However, you can pass an array-like
object. If your object does not have a dates ind... | statsmodels/tsa/x13.py | x13_arima_select_order | diego-mazon/statsmodels | python | def x13_arima_select_order(endog, maxorder=(2, 1), maxdiff=(2, 1), diff=None, exog=None, log=None, outlier=True, trading=False, forecast_years=None, start=None, freq=None, print_stdout=False, x12path=None, prefer_x13=True):
'\n Perform automatic seasonal ARIMA order identification using x12/x13 ARIMA.\n\n Par... |
def send_email(to: AddressesType, subject: str, html_content: str, files: Optional[AddressesType]=None, cc: Optional[AddressesType]=None, bcc: Optional[AddressesType]=None, sandbox_mode: bool=False, **kwargs) -> None:
'\n Send an email with html content using `Sendgrid <https://sendgrid.com/>`__.\n\n .. note:... | -1,098,207,822,008,200,100 | Send an email with html content using `Sendgrid <https://sendgrid.com/>`__.
.. note::
For more information, see :ref:`email-configuration-sendgrid` | airflow/providers/sendgrid/utils/emailer.py | send_email | AI-ML-Projects/airflow | python | def send_email(to: AddressesType, subject: str, html_content: str, files: Optional[AddressesType]=None, cc: Optional[AddressesType]=None, bcc: Optional[AddressesType]=None, sandbox_mode: bool=False, **kwargs) -> None:
'\n Send an email with html content using `Sendgrid <https://sendgrid.com/>`__.\n\n .. note:... |
def corpus_reader(path):
'Lê as extensões dos arquivos .xml no caminho especificado como path e\n retorna uma tupla com duas listas.Uma lista contém os paths para os arquivos\n .xml e a outra contém os arquivos Document gerados para aquele arquilo .xml\n '
prog = re.compile('(\\.xml)$')
doc_list = ... | 7,513,357,988,800,923,000 | Lê as extensões dos arquivos .xml no caminho especificado como path e
retorna uma tupla com duas listas.Uma lista contém os paths para os arquivos
.xml e a outra contém os arquivos Document gerados para aquele arquilo .xml | complexidade_textual.py | corpus_reader | lflage/complexidade_textual | python | def corpus_reader(path):
'Lê as extensões dos arquivos .xml no caminho especificado como path e\n retorna uma tupla com duas listas.Uma lista contém os paths para os arquivos\n .xml e a outra contém os arquivos Document gerados para aquele arquilo .xml\n '
prog = re.compile('(\\.xml)$')
doc_list = ... |
def corpus_yeeter(path):
'Similar ao corpus_reader. Recebe um caminho para a pasta contendo o\n corpus e cria um generator. Cada iteração retorna uma tupla contendo um\n caminho para o arquivo .xml e o objeto Document criado a partir do mesmo\n '
prog = re.compile('(\\.xml)$')
for (dirpath, dirnam... | 5,500,897,651,855,036,000 | Similar ao corpus_reader. Recebe um caminho para a pasta contendo o
corpus e cria um generator. Cada iteração retorna uma tupla contendo um
caminho para o arquivo .xml e o objeto Document criado a partir do mesmo | complexidade_textual.py | corpus_yeeter | lflage/complexidade_textual | python | def corpus_yeeter(path):
'Similar ao corpus_reader. Recebe um caminho para a pasta contendo o\n corpus e cria um generator. Cada iteração retorna uma tupla contendo um\n caminho para o arquivo .xml e o objeto Document criado a partir do mesmo\n '
prog = re.compile('(\\.xml)$')
for (dirpath, dirnam... |
def all_fps(path_to_dir):
'Recebe o caminho para o diretório e retorna uma lista com os caminhos\n absolutos para os arquivos que estão nele\n '
fps = []
for (dirpath, dirnames, filenames) in os.walk(path_to_dir):
for filename in filenames:
fps.append(os.path.normpath(os.path.join(... | -5,625,930,603,436,072,000 | Recebe o caminho para o diretório e retorna uma lista com os caminhos
absolutos para os arquivos que estão nele | complexidade_textual.py | all_fps | lflage/complexidade_textual | python | def all_fps(path_to_dir):
'Recebe o caminho para o diretório e retorna uma lista com os caminhos\n absolutos para os arquivos que estão nele\n '
fps = []
for (dirpath, dirnames, filenames) in os.walk(path_to_dir):
for filename in filenames:
fps.append(os.path.normpath(os.path.join(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.