elkd / deriv Goto Github PK
View Code? Open in Web Editor NEWPlaywright Bot to Automate Trading on Deriv. It's a cross-platform Desktop app written in Python, no deployments hustles
Home Page: https://deriv.com
License: MIT License
Playwright Bot to Automate Trading on Deriv. It's a cross-platform Desktop app written in Python, no deployments hustles
Home Page: https://deriv.com
License: MIT License
Currently, the win/loss calculation is performed by monitoring the trading price span tick changes. That is very error-prone as sometimes the purchase button's clicking event is triggered slower than the speed of price changes, thus unreliable.
But I have noticed as soon as the purchase event is fired, the user's balance is updated instantly before even the purchase contract has been confirmed. If this behavior is proved, then the win/loss can be calculated based on the balance increase or decrease (Increase == win, decrease == loss).
There is a very rare case in which, Eg the init stake is 0.35 and martingale is 0.14, the stake for the next play after the win jumps to 0.4 instead of 0.5.
Theoretically, this can happen when the bot fired the play button but deriv website didn't receive the event or blocked the play button but the bot didn't catch any exception, in this case, the bot will go on to calculate the next stake, likely declare loss if the last digit doesn't match and update the stake.
I still don't have an efficient solution to stop this, also it's hard to test as it happens so rarely.
There is a known issue with playwright JS having a Memory leak when the same context is used for a long time, depending on the size of JS heap memory available, this issue could occur after 1 hour of running the bot. See this issue
A quick fix could be trying to flush the objects by creating a new context let's say after every 30 minutes. Since state.json is already stored this shouldn't be a very big problem. The current stake, LDP, stop profit/loss also needs to be stored before destroying and recreating a new context.
When running pw sync code inside sg loop, pw complains that the blocking code was never awaited and runtime exception is thrown
Traceback (most recent call last): File "/home/el/workspace/contract/deriv/trade.py", line 59, in <module> trade_session.login(values['_EMAIL_'], values['_PWORD_']) File "/home/el/workspace/contract/deriv/session.py", line 23, in login self.page.goto("https://smarttrader.deriv.com/") File "/home/el/workspace/.venv/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 7328, in goto self._sync( File "/home/el/workspace/.venv/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 100, in _sync task = self._loop.create_task(coro) File "/usr/lib/python3.10/asyncio/base_events.py", line 431, in create_task self._check_closed() File "/usr/lib/python3.10/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed sys:1: RuntimeWarning: coroutine 'Page.goto' was never awaited
Seems related to this pw issue 178
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.