Galts-Gulch / avarice

Multi-Indicator Python3 OKCoin CN & Intl Trading Bot/Infrastructure
Other
91 stars 29 forks source link

Fails to update the price #24

Open jonaslund opened 9 years ago

jonaslund commented 9 years ago

When running in simulation mode, after a couple of candles, avarice gets stuck on the same amount, seems like a caching issue?

Candle: 90 | Price: 1418.85 cny | Time: 13:28:54 | Date: 2015/04/25
Candle: 91 | Price: 1418.67 cny | Time: 13:43:54 | Date: 2015/04/25
Candle: 92 | Price: 1418.67 cny | Time: 13:58:54 | Date: 2015/04/25
Candle: 93 | Price: 1418.67 cny | Time: 14:13:54 | Date: 2015/04/25
Candle: 94 | Price: 1418.67 cny | Time: 14:28:54 | Date: 2015/04/25
Candle: 95 | Price: 1418.67 cny | Time: 14:43:54 | Date: 2015/04/25
Candle: 96 | Price: 1418.67 cny | Time: 14:58:54 | Date: 2015/04/25
Candle: 97 | Price: 1418.67 cny | Time: 15:13:54 | Date: 2015/04/25
Candle: 98 | Price: 1418.67 cny | Time: 15:28:54 | Date: 2015/04/25
Candle: 99 | Price: 1418.67 cny | Time: 15:43:54 | Date: 2015/04/25
Candle: 100 | Price: 1418.67 cny | Time: 15:58:54 | Date: 2015/04/25
Candle: 101 | Price: 1418.67 cny | Time: 16:13:54 | Date: 2015/04/25
Candle: 102 | Price: 1418.67 cny | Time: 16:28:54 | Date: 2015/04/25

When restarted, it correctly gets the current price.

RealJohnGalt commented 9 years ago

Hi Jonas, This is probably an issue with the websocket connection. I've committed a workaround in the staging branch. Because the "Configuring" documentation isn't updated for this WIP branch, please do the following to configure if you'd like to test:

I believe this is a duplicate of #23.

Before this branch is to be merged into master for a new release, I need to do the following:

jonaslund commented 9 years ago

The staging branch started working just fine, and the web config is top notch, but after a while this happend

Candle: 11 | Price: 1391.0 cny | Time: 04:35:43 | Date: 2015/04/29
Candle: 12 | Price: 1393.35 cny | Time: 04:45:43 | Date: 2015/04/29
Candle: 13 | Price: 1392.02 cny | Time: 04:55:43 | Date: 2015/04/29
Candle: 14 | Price: 1392.76 cny | Time: 05:05:43 | Date: 2015/04/29
Candle: 15 | Price: 1395.09 cny | Time: 05:15:43 | Date: 2015/04/29
Candle: 16 | Price: 1394.35 cny | Time: 05:25:43 | Date: 2015/04/29
Candle: 17 | Price: 1395.41 cny | Time: 05:35:43 | Date: 2015/04/29
Task exception was never retrieved
future: <Task finished coro=<run() done, defined at /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py:229> exception=ConnectionResetError(54, 'Connection reset by peer')>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/tasks.py", line 234, in _step
    result = coro.throw(exc)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py", line 235, in run
    msg = yield from self.read_message()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py", line 257, in read_message
    frame = yield from self.read_data_frame(max_size=self.max_size)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py", line 312, in read_data_frame
    frame = yield from self.read_frame(max_size)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py", line 342, in read_frame
    frame = yield from read_frame(self.reader.readexactly, is_masked, max_size=max_size)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/framing.py", line 67, in read_frame
    data = yield from reader(2)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/streams.py", line 479, in readexactly
    block = yield from self.read(n)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/streams.py", line 452, in read
    yield from self._wait_for_data('read')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/streams.py", line 393, in _wait_for_data
    yield from self._waiter
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/futures.py", line 386, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/tasks.py", line 287, in _wakeup
    value = future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/futures.py", line 275, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/selector_events.py", line 897, in _read_ready
    data = self._sock.recv(self.max_size)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ssl.py", line 736, in recv
    return self.read(buflen)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ssl.py", line 625, in read
    v = self._sslobj.read(len or 1024)
ConnectionResetError: [Errno 54] Connection reset by peer
Task was destroyed but it is pending!
task: <Task pending coro=<run() done, defined at /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py:229> wait_for=<Future pending cb=[Task._wakeup()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<run() done, defined at /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/websockets/protocol.py:229> wait_for=<Future pending cb=[Task._wakeup()]>>
Task was destroyed but it is pending!

Any idea of what's going on?

jonaslund commented 9 years ago

And when restarted

Candle: 6 | Price: 1381.69 cny | Time: 10:58:48 | Date: 2015/04/29
Candle: 7 | Price: 1383.11 cny | Time: 11:08:48 | Date: 2015/04/29
Candle: 8 | Price: 1383.59 cny | Time: 11:46:20 | Date: 2015/04/29
Candle: 9 | Price: 1383.59 cny | Time: 11:56:20 | Date: 2015/04/29
Candle: 10 | Price: 1383.59 cny | Time: 12:06:20 | Date: 2015/04/29
Candle: 11 | Price: 1383.59 cny | Time: 12:16:20 | Date: 2015/04/29
Candle: 12 | Price: 1383.59 cny | Time: 12:26:20 | Date: 2015/04/29

Perhaps setting the candle update interval shorter reduces the risk of it getting stuck?

RealJohnGalt commented 9 years ago

There's a possible race condition included in that solution. I'm working on finally doing it the "right and simple way" in topic-ticker with ticker timestamps. Very shortly we'll hit the 5.0 testing phase with these changes included.

jonaslund commented 9 years ago

How 'very shortly' is shortly?

RealJohnGalt commented 9 years ago

I apologize for the late response, I've had email notifications off. The changes have been merged in the "staging" branch, and I'm looking to update documentation and tag a testing release of the staging branch this week.

ghost commented 9 years ago

Still running into the issue of price not updating with the latest staging branch.

Candle: 9232 | Price: 1661.33 cny | Time: 03:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -5.794877050147534 MACD Hist: 0.7282721507663625 DMI: Not beyond ADX threshold Candle: 9233 | Price: 1660.43 cny | Time: 03:40:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -5.27594369408871 MACD Hist: 0.9977644054601491 DMI: Not beyond ADX threshold Candle: 9234 | Price: 1660.43 cny | Time: 03:55:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -4.742884753885846 MACD Hist: 1.2246586765304102 DMI: Not beyond ADX threshold Candle: 9235 | Price: 1660.43 cny | Time: 04:10:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -4.222935004623423 MACD Hist: 1.3956867406342663 DMI: Not beyond ADX threshold Candle: 9236 | Price: 1660.43 cny | Time: 04:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -3.7322337293760484 MACD Hist: 1.5091104127053132 DMI: Not beyond ADX threshold Candle: 9237 | Price: 1660.43 cny | Time: 04:40:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -3.2794683065972094 MACD Hist: 1.569500668387322 DMI: Not beyond ADX threshold Candle: 9238 | Price: 1660.43 cny | Time: 04:55:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -2.8684091372795137 MACD Hist: 1.5844478701640146 DMI: Not beyond ADX threshold Candle: 9239 | Price: 1660.43 cny | Time: 05:10:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -2.4996623341348823 MACD Hist: 1.5625557386469167 DMI: Not beyond ADX threshold Candle: 9240 | Price: 1660.43 cny | Time: 05:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -2.1718719512246025 MACD Hist: 1.5122768972457572 DMI: Not beyond ADX threshold Candle: 9241 | Price: 1660.43 cny | Time: 05:40:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -1.8825361269437053 MACD Hist: 1.4412901772213234 DMI: Not beyond ADX threshold Candle: 9242 | Price: 1660.43 cny | Time: 05:55:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -1.6285535354679723 MACD Hist: 1.3562182149576452 DMI: Not beyond ADX threshold Candle: 9243 | Price: 1660.43 cny | Time: 06:10:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -1.406582416790343 MACD Hist: 1.2625514669082198 DMI: Not beyond ADX threshold Candle: 9244 | Price: 1660.43 cny | Time: 06:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -1.2132702046696977 MACD Hist: 1.1646909432230919 DMI: Not beyond ADX threshold Candle: 9245 | Price: 1660.43 cny | Time: 06:40:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -1.0453945562419449 MACD Hist: 1.0660532733206756 DMI: Not beyond ADX threshold Candle: 9246 | Price: 1660.43 cny | Time: 06:55:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.8999443814393544 MACD Hist: 0.9692027584986129 DMI: Not beyond ADX threshold Candle: 9247 | Price: 1660.43 cny | Time: 07:10:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.7741608302771965 MACD Hist: 0.8759890477286167 DMI: Not beyond ADX threshold Candle: 9248 | Price: 1660.43 cny | Time: 07:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.6655520915951456 MACD Hist: 0.787678229128534 DMI: Not beyond ADX threshold Candle: 9249 | Price: 1660.43 cny | Time: 07:40:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.571891553969408 MACD Hist: 0.7050710134034173 DMI: Not beyond ADX threshold Candle: 9250 | Price: 1660.43 cny | Time: 07:55:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.49120585526111427 MACD Hist: 0.6286053696893688 DMI: Not beyond ADX threshold Candle: 9251 | Price: 1660.43 cny | Time: 08:10:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.4217572293066496 MACD Hist: 0.5584431965150667 DMI: Not beyond ADX threshold Candle: 9252 | Price: 1660.43 cny | Time: 08:25:20 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.362023081607731 MACD Hist: 0.4945418753711882 DMI: Not beyond ADX threshold Candle: 9253 | Price: 1660.43 cny | Time: 08:40:21 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.31067470213452 MACD Hist: 0.43671220387551934 DMI: Not beyond ADX threshold Candle: 9254 | Price: 1660.43 cny | Time: 08:55:21 | Date: 2015/07/07 MACD : We are in an Uptrend | Diff: -0.26655631869653007 MACD Hist: 0.3846644698508074 DMI: Not beyond ADX threshold

RealJohnGalt commented 9 years ago

Thank you @Hapexamendios. It would help if you could enable API debug in the future.

ghost commented 9 years ago

Will do, I'll enable API debugging and will report back when the issue is encountered again.

RealJohnGalt commented 8 years ago

What I'm hoping to see is the following:

[API] Duplicate ticker timestamp; attempting reconnection

I may have messed something up, or missed a few things here though. Thank you again for helping out.