Skip to content

Commit f70687e

Browse files
committed
up-to-date
1 parent c022ae6 commit f70687e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fraction.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,24 @@ def loop(self, ticker, ohlcv, strategy, **other):
3737
if not coffee_break:
3838

3939
# 遅延評価
40-
dist = ohlcv.distribution_delay[-5:]
40+
dist = ohlcv.distribution_delay[-11:]
4141
delay = sorted(dist)[int(len(dist)/2)]
4242

4343
if delay<2:
44-
# 51円値幅で指値バラマキ
4544
mid = (ohlcv.close[-1]+ohlcv.high[-1]+ohlcv.low[-1])/3
4645
spr = stdev(ohlcv.close)
4746
lot = 0.01
4847
rng = 51
4948
buy = ((mid-spr/2)//rng)*rng
5049
sell = ((mid+spr/2)//rng+1)*rng
5150

52-
if self.api_limit==0:
51+
# 同じ価格に指値を入れない
52+
buy_prices = set([p['price'] for p in strategy.positions if p['side']=='buy'])
53+
sell_prices = set([p['price'] for p in strategy.positions if p['side']=='sell'])
54+
if buy not in buy_prices:
5355
strategy.order(f'{buy}', 'buy', qty=lot, limit=buy, minute_to_expire=1)
56+
if sell not in sell_prices:
5457
strategy.order(f'{sell}', 'sell', qty=lot, limit=sell, minute_to_expire=1)
55-
self.api_limit = 6
5658

5759
# 利確・損切り
5860
profit = rng

0 commit comments

Comments
 (0)