Bitcoin Forum
April 25, 2024, 09:48:27 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 2 [3] 4 5 »  All
  Print  
Author Topic: Trading Bots  (Read 12934 times)
MelMan2002
Sr. Member
****
Offline Offline

Activity: 461
Merit: 251



View Profile
April 06, 2012, 04:11:28 PM
 #41

I'm using C.
... so check your pointers. Make sure nothing is pointing to the stack and so on.

Yes, definitely a pointer issue.  The problem with set faults and pointers is that the seg fault can often occur at misleading places leading you to believe that the bug is located at a different point in the code.  And C gives little to no warning when playing with pointers improperly.

19F6veduCZcudwXuWoVosjmzziQz4EhBPS
1714038507
Hero Member
*
Offline Offline

Posts: 1714038507

View Profile Personal Message (Offline)

Ignore
1714038507
Reply with quote  #2

1714038507
Report to moderator
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714038507
Hero Member
*
Offline Offline

Posts: 1714038507

View Profile Personal Message (Offline)

Ignore
1714038507
Reply with quote  #2

1714038507
Report to moderator
1714038507
Hero Member
*
Offline Offline

Posts: 1714038507

View Profile Personal Message (Offline)

Ignore
1714038507
Reply with quote  #2

1714038507
Report to moderator
1714038507
Hero Member
*
Offline Offline

Posts: 1714038507

View Profile Personal Message (Offline)

Ignore
1714038507
Reply with quote  #2

1714038507
Report to moderator
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 06, 2012, 10:53:19 PM
 #42

OK but what is wrong with this line?

Code:
FILE * file = fopen("price.dat", "rb");

That's as perfect as a line of code can be. It makes me think the compiler is corrupting the program somehow.
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
April 07, 2012, 04:15:29 AM
 #43

OK but what is wrong with this line?

Code:
FILE * file = fopen("price.dat", "rb");

That's as perfect as a line of code can be. It makes me think the compiler is corrupting the program somehow.

Or you have a bad pointer somewhere and C won't stop you from overwriting your code stack and screwing up the instructions, leading to an error being identified in a bit of code that was fine before the program did exactly what you told it to do.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 07, 2012, 02:58:27 PM
 #44

Well I modified the code:

Quote
int main (int argc, const char * argv[]) {
   float usd,btc,bid,ask,order_price,possible_price;
   printf("HALLO\n");
   DateData * prices = load_prices();

It never prints HALLO and it now crashes o the printf line...
Kettenmonster
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


bool eval(bool b){return b ? b==true : b==false;}


View Profile
April 07, 2012, 04:05:50 PM
 #45

No, it crashes on intializing a lib.
Remove all optimizations (compiler + linker) include debug infos and step by step remove one lib after the other.

The paining (sic!) is done with the QPainter class inside the paintEvent() method.
(source: my internet)
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 07, 2012, 04:57:32 PM
 #46

I removed all optimisation and now the line during the crash is shown at entering the main function...

I removed all curllib and the same problem occurs...

I removed all of the OpenCL and the same problem occurs... What? Is Xcode broken...

I replaced the entire program with:

Code:
#include <stdlib.h>
#include <stdio.h>

int main(){
printf(":O");
return EXIT_SUCCESS;
}

It works... Time to scratch my head...
ohforf
Sr. Member
****
Offline Offline

Activity: 327
Merit: 250


we are legion


View Profile
April 07, 2012, 06:30:05 PM
 #47

A IDE / Compiler can be broken. Its possible.
Try Compiling on a clean, fresh System. - or at least reinstall xcode.
Also check environment variables.. these are very important for most Compilers.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
▀██████ EAT SLEEP DECENTRALIZE ██████▀
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Kettenmonster
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


bool eval(bool b){return b ? b==true : b==false;}


View Profile
April 07, 2012, 06:35:06 PM
 #48

Fine so far.
Now find the lib or the combination causing trouble and feed that to agony aunt google.

btw. if your first line of code would have been:
Code:
long satoshi = 0;
It would have crashed there, so could be RAII isn´t too bad for pure C either.

The paining (sic!) is done with the QPainter class inside the paintEvent() method.
(source: my internet)
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 08, 2012, 04:31:34 PM
 #49

Well I just tried compiling and running outside of Xcode and I get the same thing...

Code:
Matthew-Mitchell:Parrallel BitCoin Trading Algorithm matt$ gcc -g cmain.c -o test -lcurl -framework OpenCL -std=c99 -arch i386
Matthew-Mitchell:Parrallel BitCoin Trading Algorithm matt$ gdb testGNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done

(gdb) run
Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test
Reading symbols for shared libraries .+++.................................................................. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0xbea7d7cc
0x00003e9a in main (argc=0, argv=0x1000) at cmain.c:572
572 int main (int argc, const char * argv[]) {
(gdb)

Sad Also when running directly in the command line, it returns instantly.
Kettenmonster
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


bool eval(bool b){return b ? b==true : b==false;}


View Profile
April 08, 2012, 08:25:21 PM
 #50

Code:
Reason: KERN_PROTECTION_FAILURE at address: 0xbea7d7cc
wtf is located at 0xbea7d7cc?
Is it stack or heap? Did you init it? When did you release that address?
Is it always this specific address? ... if yes, why? Where did it come from?

The paining (sic!) is done with the QPainter class inside the paintEvent() method.
(source: my internet)
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 09, 2012, 12:08:01 AM
 #51

At this point in the program nothing is initialised since it's at the main function entry. I ran gdb again and it shows 0xbea7d7cc again. No idea where it came from. What I'll try to do is make and share a minimalist version of the program that replicates the problem...
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 09, 2012, 01:22:55 AM
 #52

I fiddled with the code and slowly removed parts until I got a super small program that crashes:

Quote
#include <errno.h>

int main () {
   if (!errno) {
      int bar[2096159];
   }
   return 0;
}

This gives:

Code:
(null):Parrallel BitCoin Trading Algorithm matt$ gcc -g test.c -o test
(null):Parrallel BitCoin Trading Algorithm matt$ gdb test
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) run
Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test
Reading symbols for shared libraries +. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f3ffff8
0x00007fff5fc1404c in __dyld__ZNK26ImageLoaderMachOCompressed18findExportedSymbolEPKcPPK11ImageLoader ()
(gdb)

But if the array is one smaller:

Code:
#include <errno.h>

int main () {
if (!errno) {
int bar[2096158];
}
return 0;
}

Then this happens:

Code:
(null):Parrallel BitCoin Trading Algorithm matt$ gcc -g test.c -o test
(null):Parrallel BitCoin Trading Algorithm matt$ gdb test
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) run
Starting program: /Users/matt/Programming/Bit Coin algorithm/Parrallel BitCoin Trading Algorithm/test
Reading symbols for shared libraries +. done

Program exited normally.
(gdb)

Stack trace:

Code:
(gdb) bt
#0  0x00007fff5fc1404c in __dyld__ZNK26ImageLoaderMachOCompressed18findExportedSymbolEPKcPPK11ImageLoader ()
#1  0x00007fff5fc0f141 in __dyld__ZNK16ImageLoaderMachO18findExportedSymbolEPKcbPPK11ImageLoader ()
#2  0x00007fff5fc12b34 in __dyld__ZN26ImageLoaderMachOCompressed15resolveTwolevelERKN11ImageLoader11LinkContextEPKS0_bPKcPS5_ ()
#3  0x00007fff5fc12dd0 in __dyld__ZN26ImageLoaderMachOCompressed7resolveERKN11ImageLoader11LinkContextEPKchiPPKS0_PNS_10LastLookupE ()
#4  0x00007fff5fc1699e in __dyld__ZN26ImageLoaderMachOCompressed20doBindFastLazySymbolEjRKN11ImageLoader11LinkContextE ()
#5  0x00007fff5fc0478f in __dyld__ZN4dyld18fastBindLazySymbolEPP11ImageLoaderm ()
#6  0x00007fff8812800a in dyld_stub_binder ()
#7  0x0000000100001030 in pvars ()
#8  0x0000000100000ef4 in start ()

Well I'm stumped...
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 09, 2012, 01:50:08 AM
 #53

Stack overflow... Now I'll know to be weary of static variables. I'll try replacing large static arrays with allocated memory and hopefully it will work... I thought the stack size would grow to meet larger variables... It would be nice if there was some error or warning when this happens.
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
April 09, 2012, 01:56:17 AM
 #54

Stack overflow... Now I'll know to be weary of static variables. I'll try replacing large static arrays with allocated memory and hopefully it will work... I thought the stack size would grow to meet larger variables... It would be nice if there was some error or warning when this happens.

That's it... don't make static variables over a few hundered bytes.  Just don't.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
Kettenmonster
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


bool eval(bool b){return b ? b==true : b==false;}


View Profile
April 09, 2012, 12:04:28 PM
 #55

Maybe be you should take a closer look at your data structures.

What do you think a trade looks like?
Do you need to store the trades? For what purpose?

Is the decision to buy different from a decision to sell? If yes what is the difference?
Is this to be modelled as a struct or function? (could be both)

Is your bot meant to run on a single exchange or will it serve several different exchanges?
Thus you have to model the synopsis for the(se) exchange(s).

Then look at the libs you use. What is openCL good for? Do you really need it?
It prevents you from using function pointers. Which could be handy when dealing with different exchanges and modelling the decision as a function.

The paining (sic!) is done with the QPainter class inside the paintEvent() method.
(source: my internet)
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
April 09, 2012, 04:48:01 PM
 #56

Yep, allocation with malloc works fine.

Except now I have OpenCL errors, will fix those...

Quote
Then look at the libs you use. What is openCL good for? Do you really need it?

Testing many combinations on an algorithm at once.
mem
Hero Member
*****
Offline Offline

Activity: 644
Merit: 501


Herp Derp PTY LTD


View Profile
April 11, 2012, 03:13:26 AM
 #57

Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?

TL;DR Noob coder needs help building trading bot.

I have already written one, its called bitperl.pl but atm is a private only release.

On a good day it earns 0.7% of capital.

notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
April 11, 2012, 03:14:55 AM
 #58

Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?

TL;DR Noob coder needs help building trading bot.

I have already written one, its called bitperl.pl but atm is a private only release.

On a good day it earns 0.7% of capital.

What about a bad day?

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
mem
Hero Member
*****
Offline Offline

Activity: 644
Merit: 501


Herp Derp PTY LTD


View Profile
April 11, 2012, 03:17:05 AM
Last edit: April 11, 2012, 03:34:49 AM by mem
 #59

Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?

TL;DR Noob coder needs help building trading bot.

I have already written one, its called bitperl.pl but atm is a private only release.

On a good day it earns 0.7% of capital.

What about a bad day?

The worst Ive seen is it flat line waiting to sell coins for 4 days (back when he had  a good sized slump to 4.60). Once  the price came back  to normal it resumed its micro trading.

Currently supports:

  • Simulations
  • Uploads charts output of: profit ph, profit total, buy, sell, target, target break even. Example:
  • Logs historical Data. (for simulations)
  • The most basic buy low sell high algorithm (more coming).
  • Forcing a sell/buy remotely.
  • tweets changes and transactions: https://twitter.com/#!/bitperl
  • Factors MTGOX transaction charges

Todo:

  • Nicer web UI
  • modular trading algo's

Good luck with your trading bot Smiley

My advice is thread or daemonize everything to avoid any lag between transactions and mtgox live price.
I used to have everything pushed into a single loop - was easy to follow but a simple tweet was enough to miss a good price.

notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
April 11, 2012, 03:21:30 AM
 #60

Maybe this is the wrong section, but I think you guys can help me here. I want to make a trading bot that will execute trades based on parameters I set according to technical indicators. Thing is, I have almost zero experience with coding. I don't just want to use someone else's code though, I want to build this from scratch, using custom and unique indicators. Is there any resource that I could use that would teach me how to go about creating and implementing this bot?

TL;DR Noob coder needs help building trading bot.

I have already written one, its called bitperl.pl but atm is a private only release.

On a good day it earns 0.7% of capital.

What about a bad day?

The worst Ive seen is it flat line waiting to sell coins for 4 days (back when he had  a good sized slump to 4.60). Once  the price came back  to normal it resumed its micro trading.

I see... careful with that type of strategy.  If it moves too far and you don't have a stop you'll miss the big moves.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
Pages: « 1 2 [3] 4 5 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!