0110110101110100000101011011101100000110110100010000101011111110100110001101110111101010100101010011110100000100000011111010110111001000000100001100010010001100000010111101100000000101000100001010010001001100101010001101010001110000000001110001100011100110000011111011111010011101011100000110100110011101110010011100011001010001110011111111110101000000010010010111110000000100011010101101110011001010 1011001101110100001011001101111000110000111110011001101010110101111101011010100001010000100101111100010000010101000110000011110100011101010011001111001000010011011110001111101011010110000111110011111010100111010010110100101011011011001011001010001110101100001101001100000100010011110011010110101000100011000101100011111110011000110001001010010101011011001001100010110101000110111010111101001001011101 0011101101110100100110011111011010001100000110100001001010110000101010101000111101111100100101110100001000110010111101001100110010110011101001101001000101110001110000011010111011010100000000111100010000111100010010110010110100010001011111100000000111000000011000100101010111101110101001011011010010101010100101010111101100110001011010100010011110010101100110101111010111100111101001100101101001000011 1100100010101011110110110010001100101010100011000101011101111111111101110011101101110001110001100011011110101000110000011010111100000100001000101111110001010001110011000111001101010011101110001000101100100010011010001100111001001000110100111011000110110100110011001001001100111111001010110100101110100011110100010110001110010111001010100011001000000101111101011101101011011101111001001010110001010111 1110100000010111001001111011100001100011010110011000111010101100100000001001001110011011101011010101111101110111011111001010111001010001010010101111010101000011010100100001010110000110010010011100000011001111010110101001110110001110111010111100010111001101010010000000010001000011100011000100100001000010100110110001011100111011010000111011110001100000101110001111100100110001001110110110001100001010 0111110101000000000111101111011000011110011100111101101101110110001010000011010100110101000011101010101100011101000100001101011000111000011010001011100111000011110101110101001110101001111111100101101101001100000111101000000011110111011110110000110000001010100100001000110100100101111010111111001111100011011111011110011000011100110011100100001101010110100010110011111000001101010011010000000011101110 0110011101011000011101110001111111001110000001110110110110110011001101111110101101010010110010100111100000001010110010011010111011101000001111011001000110011101011110110010101110111110011000000010101100101010100100001111110001010000110101100110110000110110100100110011100011011001010000101000000101101010100000010111100000001011010110111001001100000100001100010100110101110110110100010101111011100101 0011000101011011010000111111101100000110100101001111001110011001111010100001100101111100011100011011110101011000111111010100101010011001001100001011100100101011111111100110100011111001001010101011001001000011110010101011010001111101011001110001110110101000001100000011010111100001010111011001010111011011001001110011110011111000010000111111100001101101000000001001001100011100111100010111101101000110 1010101111111010110100100101100010010101011000010111110110011001100101010101000000111011110101110010110110011001000110101010100000111100001110110110101111101111001101100111110001000110101011100001001010101000100010010010001110101110010011001001010001101110101111101000110100001011010011101110000101001100000101011110111010110101110101110000100110010011101010111110111011001111111001010011100101000001 1111111111110110100001111100110111011111111011101000111001100101011111000001101000111110111000101100011011001001110101111000100001011101011111100111100111100111001011000100000101100011010001100101000111110010110100010100001100101010101111110110100100101000000001000101110110100000100011101111000010100001100000001101000001011010010001101111100000000011010101000011100010001001100101011010111110111011 1010001110111110000011111010011001101101000011111011010111000100001100000100110111100101001110100110100001101101100111101000100110101010010001101110110111101010111011000000101000111001101010111110110001100011000011110000000100100100000010001101111000011100100011000001111111010100010000011001110010011000011000110100000110000000010111010111111010100110111110101001111011011101000000111011001100101101 1010111010100000101110001011011111100101010111010010011000101111111000010100101111111111110010101011000000111111000100100010100101001110011110111000010011101100010010001001011110110111000010010011011101011110000011101110000010011010101111010111100101000100001010111011000111100100001010111100001000111110010111110101101110100011100010001011011010001101101000001110101011111100100001010100111110110001 0001101000110001011010001011011000001000000100101110100001100110001011010011001011100000111100101010010010011001001111100111100011110100011111000111110101010010001100011001001101110011100000000101001010000000111001011101111100101111011101001111001011000011000100010010011111000010110101111110111110000100001010101111110111000100011110001100001110110101001111100000100110011110010000001110010000101010 1100111100101001110000110001101100111111101111010001101001101101100000101000111110111101000110001111101110100000011000100010110110011111010001010110010001010001100101000010010001000000010011101011110001100011000001011010000111001011010011001010010101001010111111111111000110000111110111101110111110001101111101010000001110010000111110101000001011011110100011110001110010101101110111011101100001001101 0111110000110001101111110011101100101101110100001111010111000000010000100100101000101001100110101011001111100000110101111001101011110010001110001111000100011101011100011110000100111010100001000101000011100010100010000000110101111110100111010010000010111001000010011101110101011011110101011010001111000100101111100001001011001000101010111101000101010001101010001100110111011111110110001011110011111001 0111101000100001000010110100000001010100001010100111001010010010000001010011111111110011001011100100010100101000000111001100100110010100101111001000101100110001010000001010111111011111001011010101000011011100011011100011101111101101001111111100001101111011101010111111111100110001000010000100010001111110101000101000000010101010000010011000001011100000001110001001001100100111010110100011111001111101 0110101011101001010001010011101100111110110011001100000011011100110110110100010011001111100100011001101000000000011111001011001011000010001011110001010100111001111011110011100100000010001010111110010011000101011011000011100010011010001100001111000000111111111100101000101100100001001100110011100101001100101101111111111000100110010111100100010010011011101100101111010010011111010000110001010110011100 0001100110001110101000011100010010010101110100110000010111000111001111110110100010111101100000001000100011011011001110110111001100100010110100000100110001101110110001100011101010110010001110000101101001011000110100011000000110011100011110101001111110001011010001100101011110010101011010101100100001010101011000100100111001100001011100010100011111010011101010000011111110101110111110010001010010011000 1110110100101001001011001000001101010011101111010000011101010111001110011010100100010000111010001000010111111100010100010011111001110011111111011100111110010010011110010100001110000111011011111110001100100110010101100001011110111000011001000010110100111010000111011110001110100101111100001110011001000011010010110101101100100011100000110111100101010100110000101001111001110110000110010000011011101000 0101001111000001000100010011100001101111110010111010001010001011101010001111100000001010101000110011010100110011110110110001001101010001111100100010011100110000011001111001101111011101010000100100100001000001010001000100110000010101101010010001100011101110111010010010000111010010101101010010100110010000111110000101111101100111010011000011000100101111101000101101011000000011101010100101001000100100 0000000100110001010110000100111000101101010101100011010111111011110101111010101101000010101010111000000001100111110111111001011010100101001101101100110100011101011110111011000101111010011111010011000000111111110101110010110000001011000111010110110110110110110101100101110001001111001001111101011100010101110001010100011011100000010000000010011001111011100101010001100011010101110001001010111100111101 1111000110010000101011100001111011111010101001111001110111101100111111111000000011101000101101110010000111000001100110001000011100101100110001001010001110101110000111011011110001110010100101101011101011000111101000010001110010001100100011001101000100001011001010101000111111001011101100011000111110110010110011101100100100111001001111001000010100010010110101000001110101010111011101100110111111111101 0010011001000001100110001111101110001010110101100010011010011010010110101010010010100001111111111000100011001000111101110001101010111110011011111001001110110000100101010011010000000110011010000011110110000110111010011110011101011101100001011010100111000110010000111011001000111101101100100010000010101100000000000101101100100000100110000010001001010000010001110010001111001011111001000010110110101001 0111101101101001000110101001111101000001000101110110101110010000011101101111100011011011000000000010100011011001010001110000110110011011111000001101011010111100111010110111001011111010101101011000001011110101010100001100100110100110101010110010001011100101001110011100101011001001000011000010011011101110010100111001100111101011000100110110110001010101110111011010001011010010110111010110110101010101 1101000010100101011010010000111111011101111011010111111110000010001100111110010110011100111001100000111111110110011100100101000101000001010100111101010110110001111000111100100100011010011010011010000110010010000111100011000101101000101110000000110011100100111111110111111011100010100100101011110001110100010100100011000111000000111110011001011000011001011100000010100001001000010001111011001111100001 1001111101110100010000111101001001101000000100100011100001111101010011011001010110100001100100001100101011010010101001001110001011111110010001001011000110001100000010100000010010101011001110101101011101100101101100011010100001010011011100100011100011001001100000001111101101011011010011110101001000010001010000001111001100101101111111000110001111011000010111010111001100010000011100101110111111101011 0001111111010111010001011101010101110101000011100001101101100111110000100001000101110111100110011010101010010000100100110101001110101110001100100000001111101100110011011011110111011101000111110010011110010000100111101110001110101001110111011011010111000111111000111011101000001010110110111010111010111111111010010010000000100100110011010000101100000001011010110001111100101110011111110011111111010101 0110110001010111000110011101101101011000101000100001010001010010100011010011001000011000001100101110001110011111000101011101000010111010000000111110011111110100110001110000101100101110000100101011000110111111100001011001100100001000000101101011100000010111011001110101001000001110111100111110100010011010110000110000110111010110000001001101100111000011011011110111010111100010101001111011000000111000 0110111001000110111100010000111001010010100101101000100100100110100100010111010101011110001000000111111010010010101100110000101110010100001000110011101100111100000110001010100001010101010110101111111100111010000100101000000001011101100000111110101001101001100011000001001011010101001110010100000000100001000111101010101011100100011010100011000100000000001110010000000100011010010100001110011101011010 0101000100100010111111011100000111001001001111110100001000011100111101011010001000001011110100011000101100010000011100000001111011000001101001111010111111011000011110011011011101111111101110000001101010001111010101010101001000001010000010111011000011100111100100100111000100010110010000000101100111011101010011100100010010100001101011101010100000100001111100111111111111001001100100010000001011001101 1111000000111001001001100101111011000010011011110110101110000010010101011100110011101011111110100100101110001110101001001001110001010100010111011100011011001010110111100010111111101100000011011101010110100101110110010000100101001110001101100001101111100011110101100010001111011011110100010111001001011110100110100100010010000110111000110010000001110010011101111111000001011011001000100100100010010110 0011100101001011101110110011001100100110000000100111100000110101110100010010101101100110011110001001001000101111111100110111101100011101001111010101101101111000010100111100010010011001000001111100111000100010110111000101010011000100110111100100101100010000111111111101100111010110000100000001100101010110001110001100100100100100001100110100001111010111101001000001001000111011000101100110010010111110 0010100011011110000101101000110101101010111100011110101001011011011000011110001100100010011011011111111010110010110101011101001001010110011001101100111101101111110001110111010100111100001101111000101100000111001011110110111011010101101011001001001010011100011001001011010100100111010001001101110110011000101111111001011101100010110011110110000111000110100010101000111101100110110101001101111000010000 0110111011101001110010111101011001101001011110010001101010101111010111111000100011011010001110101111011100001010011111000001011011101011110001110010100101011010011010100100001011001001011100111100100110110000001000010100101111101100100010011110101011110010010100001011100000001011101100101101110110010110111110001111000011010111010001011000110101100100001100001000001111000011100100100000110000011000 1001111111111101010110110001100110010000010110011110011110100011100101011100000110110001100110000100000111110111001001101101000100010011011001010010110100111101101011011101001001101101011101011100000001100101110111100101001011110110010110100011110111001111011111000110001101000100001000111011000100011011000000100010100000110101001010011000110110000101011011101100101010100000001110101101000001110001 0000111001101100010100100110101010100101100111011110001101100101101001100110010011011001110111010100110000001000000111011001010111010111000111010010010010101000111101110001011001001100111100000010101100111110101000000010010110111000110000010001110011111110000110001101101100100001100000101000010100111000111110101110101101000100001000011011000010011110101010011101100110111100101100110010110101000000 1111101111101010010101110011000110010011000010111110111111100101001101010000110001100000000111010011011001110001101001011101100110101110101001100011101110000100000110101110010110100101100011000100000111000101111011010010010011101111001100010011010110001111001110011010010100100001001011111100000001000110101110100110001110111011101111111100111011111101011011000110111100101000010000110100101010111000 0111000011000011101000001011100101100011110010101110111011110101010110000111101010010011110101000011001000101111100000110111111000010101111101110001100101101011100100101100011011100111010000001011101110101011110011010010100010110101111010001100100111100111111100100110011100111100000010001101000100010011000111011101100011000001010101101111101100100111000111000001000011011101110011001001000001110111 0100101001100101100110011101001000001011110001111100101000000000010110000010110111011010011111110101100001010101011010010100010100100101011101001001010010110110000001011011000000010010111100101111000110001001110100111001100110011100001001011101001110010110010011101000110111011100100001010100111100010100000100101011111011010000111000010101110010011110100100101011001001110001011110100011111101000001 1011101111100011001111110010111110001101010001000011100011000011110111000001011011001010010010011010101001110110011001001010001111000101110000111100100111101100000100101001010010110111111111000011011001100010001000011010100000001010101111000011010001101010100011110111001001100111001000100001100110111000111001110101110101010000001001110100011101011110101110010011111000101001010101011100111001111000 0000011001011001011001101111001100110010011011101011011100111111010111110101010101011001110100011011110011010110101111011001111110110011000000001101011001011001000010110011001100010000000100111001111011000100110110111000101011010010111010001111010111000110011111110100011100111110010101011011110101011100001100011110111111101010000101110011101101010100001111111101010110001011101110101100100101110000 0011110101110000010100001011100100101110011010111101011001000110011001011100011001110100000001111000110111110001011011101111111011000010000100110100101010111110001011110111001011000100001000100111000010010100100110101111011010000011110111110010110110011101000011001111000001110101101011101111111110101110110000011110011111100010101000111110100101010000101101101110010010000100111101101000001011000000 1110110100011101010010011110110101000010111000011110110110011100100100001101001111111010000101001001100100110110100111110011100011010111010011001011111111110101000010011001000111110011010101111000000111011101101001111010011101000110100111110000010100110010010001111100111100100001001010100000001100101100011011000101111101001110011110001111010011011010100101111000011000001110010011011000010001001111 0000110010011000000000110010011100000101000111100011011000110001110001010011001111011011101110111000001101001011110100001011010010010011110101001010001000111000101111100001011011110010101101000100001101011100000111011001101010000010111010011101001100110011111001011101000110000010111001110001111110110111110011110010111110101110011011011000011110011101100110111000011011001011000010011001011011100011 0101001000101111001111000110100110001110111110100100111001011000010001000110001000101101111100101001011111111100010001000000110001000001011001100010110010011101010011000010011011110110011101001011100010011011110001111011001010111001110001011100001111010111010000110111100111110101100011101001000000011011101111010100001000000100010110011010111110010010110000101011110011110000101100111100000000110011 1011000111011100111100011100100111001011100111001101110111010010101000111101011010000100001000010001111100101111100111000111001110001111111100100111010001111000010001001011010110010010001101001001100111100101011101010011001100101000000101100001111001111000111000001000101010000101010111011101000111111010111000100001110011110011001011111100111110110111111011101101111100001100001111011110111100100110 1110010111100110100010101000101111111011101111010011110011010111110011010010101010001110000110101001110000001101001011000101011000100011011100001001110100011100100100101011000010001101010101011100001000110010110100111110101111010101001001010001000000000011000100110101010110101111010101100111010010010010100000110001100110011000011010110000101001111010011010101010001001000100111100110010110010000101 0010000010100010000110111001000011001010011100001011101111001100010111001110001110100001010101101011100110111011110111011001110110001000000100111001001101001100000111001000100010000000010101110001001101111001101110101001100110011100101101101111101110001010000000101111111101001011100100011010011011110000000111101111011111011011101100101010000110011111101001010100010010111000100011111101101111110110 1011110010001010010000100011111110111111100000111110100000100111011101100100011000101010011001010110101110011011000001010100011110001000100001100100111000100100000001000000000000100111110100101110000101000100110000110110100001100100000101101011010110110111011001011100000110110110010010000011000001111011000010100001001101000111010011011100011111001111011001100101001001010111101111110011001010111111 1101110110111110010100000011001100100100110111000101110101010001111110101001110000110010010101001111000000101011010111110111111110011101101001000101101110000110001101001110010000011010101011111101110011000110101011000101011110110110100111101010001110100101100010001111011111110010101100011011010011011001010111000000001111111001011111111001100011110000110100101110001110110111000001011111110100011101 0001011100101100001001000010011100001000111010001100000000100111001101111000011101100011100010101110001110111100100111000111010101111101000010000110100011010000101000101010010100011011100100010001001111100000110011111101000010010101010010110000000001001111110011100011010000110011101001011101011000001011001101011100010101010001010110110110001100111001010011110110111010010010001010111110111010110111 0100000010100000110011010101101110000111100101011111100010000100011110011000101110111011011101010011100111110000000011111101000000011110001001101011101110111000010100001101100100100000100010011000011101010101011010010110101000101010111110110101001000111100011000010010101111011110100011101100010100111100101100110001100100001110000001011011011001010111111010110011101110001000010001101001010001000101 1111000101110010110000101101100000111101011000111101101011110010000011000111110010100111010001010000001110011010010010110111010110101000101011110111011101111001101100101110111110100011111001110000010000101001011001010100000100110110011111011010100001101011100011101110011010111001001011110100110001011011010000101011101100000111010101101100111111010011111111010111100101101001001011001010101100001100 0001100110101000100101111110111001011110011110000101100110000100001010100101110100110110101010111111101000110001011001111111100010101000110000010100010010101100111101010010111110111100000111111000111111010010100010000100111101000000011101110111011011111011001101011111101001101110101000010100111000000001110111011010101001010011101011000010000010110010001100010101111011101100011101110001001100010011 0011011010111011010100000010001101110101010100001110100111100000010000011100001000101100011110001001110011100010101111111100101011001100101001100101000001000010011001111001100110111000110111011000100001100100110001110101101100000110011001010011000111010001111101110000000011000111001010011100101000101100010000001110000011111110011000110001101101111000000000111000111001110000101110010101001011101011 1011110101111110000111010011111000000100000101000100011010100001011100001001000001001010010100110011011110011011010001001000110011000101000100110101011100010111101110101100001111100000001111011011101010001010001110011011111100100011101101100101001000111010101100000001110100000101010000110100010110111100011010100111010001000000111010001111100001010110100110101011011011010101000100000101110100011111 1001100101111101101101111110011000001100001011111111111011001001100011010100000111100101010110000101010000101101010111100100001010001110011001110011001010001101000001110100000101111011011111101101101010011011011010000010001100111011101111110101110000011101000001110111010001100100101000001101001100010111110101011100011010000101110101010000001001110111101011101101001110100100000011101010010010000000 0001000111111100100101111100101110001010100110000100111111010111001010110010011000010000110001111011001010101110101000011001010101000010000000111110011101000001100101010001101110100001111001111011010111101110000111001111111001001100100100000111100001010100111100001100101010110001111000010000101011011011111011011001001000110011110100110000011001100111000111110010001111011001101011011101000010111110 0101100110000101000100101000011111010101011101000001011011000010010111100111010111011001101001101111110110001110101000111010111010000011000001000001010110011010000010100101111101100110010010001100011010011110101000111101110101111110011110100001010010010000111011101101100101101010010001101001111001000011011000101100010011101000111100100011110110010101001010000001011111110000100110000011000111001011 0000001111100011111001101100101111011000101010001100100100110011010100000011010110001011100000111110100100010011101110010100000111100001100010000101001111011010110110111010111101000111001100110011011001111100000111010010110101111001011010010100100001001100010011110110001101110011100101100111011000000101011001011001100011100000101100101110001010110100011110011101110100001110110011010001110100110101 0011110000110100000111101110001110101001101001000101011101100010010100110111011001110101011010101000111111000011010110001011100111110110101001001011101010101000110001111100101111000100001001111010011000110110101010101110001000101001000011110000000011110111010010000110111100000100100011110011000010001110010111101101111011100101000011000110100111100011110010011110011001000010000010100100010101110111 0000011101100011000101101100010110000101000001011010011100101010100100111000011110110101100111100111010000011010111110101001001100000111011000000110010111011111110010000000101111000001111101101001001010101110011000101101101001110110010110001100011000000111100101010001011100010100111111010101100101101000110101000111001101000100000010100010100010110000111001010001110100110011011011110100000001100111 0011101011001010010111100010100101100001000111011101111001011111111001011010010011111010010101111100011111001000111011011110010001011100001010000101001111101001010110011111100000001011001111010001110011110100101001011110100010001000111110111101101101110100000001100110101001110111000000101010001100111101011110101000110101010001001101100001010001001010011100100111110000001111100010101011000001110000 1100011110100111011110111000110010100000001010011010100000110000101101010101010101001110000001011100100110010100101101000011010100101001010100111011101010100011110010010000100001001010100011100100101100110110110001001010111001010011000000011110001100101000011011111011110110110010000011001100010001100001100011101000101001001110001001001000101101101110101101100110011000101010101010101000001000110001 0100001100101111010001110100010010011000011100010010101111110110011001100001000110011011001111000000000111000000101001010000011000100011100001100100011100101001010000111001111101001110010111100101101010011100001011100100001001100100001101110100000111110011101101000111100111000001000011011100001110110111100111100110001001101001010011101001100101101100011011011100101000111000110111111001001010101000 0101010011100101101000100110101111100100101101011100100101111101001101100110010010010001000100100000010100110010001000001101001000010011011001010110011111111000110000111101100101110101101001101110100111010110101100110111110101000001101000011100100111011001010100001001100100001001010100000011000110100110110010110101010011011001100101011101100011011010110000100011111010011000110011001110100101111110 1000000111110101000011011110111100000110010100101000001110001100000101000100000001111000010101010000001001010110001001100001101010000001111000010011101001111111000001101110111010100110000111101011100000011010011101111000110011111101111101000001110010010010001011101001110110010001011001011000111000111111111101011101111100011110010110110111110000001101110000111110111100101011100100111001000101100001 1011110011101110111100111010110010100001001100001001110101011001111011110111000001011000010111010101110000011010100000110010001010000011111111111101111110110100010010110011110110101100100101110001111010011101110101001011000100011110100001100010001100011101111110101111010010011111001101010000000111100100001110110100000111100001000100111000100101101010000000100110110011000101001011011010010000100000 1011101000101110011111100111011010000010010001110100111111010011011111101110001010101000100001001110110110000101111100000100000000101101101110101000110011110111100100110000001101100110100010110010011100110101110010100101111110111010001110111101111110001111010110101110100001100101101011111110001000100011010110110000010111010011110101011011111111000110111000101000100011010100001001001100010101111110 0100000000101000000110001010100110110101111011101011000111011000101000101100110101001011011000001101000000011110001011111001110010100111100000100011110100110100111001111101011010100010111101001010001010010111011000001010110000111101101000011110001010010100110000100101111000011111011111110001110001111101000101011111010000000111001001111100010110011010010111110001010000101011110101100110101110011101 1110111100011001001000000101001011010111111000010011010011010011100110100000111010101101101011110001001011100100000010010000001110100101011111101011101001110110000000111001011111001010100110110000110011101010100010100111001110001001110010000000000111101100011001000000011101110100001101011011101010010010100101110100100110001110101110000000110101100000101110110101111011100001001010010010010110110100 0110000111111010011001100100011011111111110110011111110110000001000101001110001000111111111110100001111011100100000110000111110110000111011001100011010010110111100101101100011110100010011000001111111010000100101101000010111101111111100011111000001110110111000011100011000011011000000001001101010010001101011110011111000010110001000101100111000010101111000110001110010100100000110110000011000010000100 1111010010101111011110110010100100110011000100001000100100000100100110111010100111000100110110001000101001000100001111001100000010110001111100011000100100000100000101001100111111010011000011011111111100010010100100011010111001111010000010000011111010100101011110110010000101111011101111011010100010100100110001100010100011100001011111010011011010111010011101000110110101000011101100000010010100011101 1101011000110110110000100101011111010000101100011011101001110011101001000011100110101101101000011000110010100100110111010110001000010100110000111111111111011100110010101101000111111011110000011111000011111011100011110111000011001001001011101100110110010001001010101011111101000111001001111111101010110001001001110001100101001000110111101000011000001110000101010011000010010111001011010100100010101110 1100101000110110110111001011111011000100101001101101000110101011011011100000111011010010110101110110111001001010100001011011101010110100011110010001010100000110111000110101110101000100101001000000001000111010111010011000101001101100010010011101011110100000100100011100001011111001001111011101101001000101101111011010010101011101100000010110111101101110110010100110101100110011001011010000010001110110 1011001001000011101111110000000011010010100010000101100100100111000111100011111110100111111000100101100110111101010100110010100010001011011111111111110001101000110001010101111110010001101010000011111011000111110011000001111010011001111110001011111101100100000100110100101101100000101101111111000010110000101100011101001000100011110011110000001100110001100011010000011001110011010011001011000111110011 0011111110110111110100000001101011000010110010101010101100111011010010111101101001010100010001001110100000111100110011010001100001001111000001001111011011101001110101101011010000111010010100111011010011011101100001011001011101000011011000101101100101111010000100001001101111000111110010001011101100011010011001101110011111010010100010011110101011111001011110001011011011111100010010010001101110111110 1011001110111100100001000100100011010111000001110001001001101011011001111111111001000011101110001001010101110000011000001010000011110101011110110001111110111110110110011001110010111001011110110100001011011110111111011111011011111100000000000101101101000001100011110111001111110101010110001010001101110101110011110011101001100000110010011001011001011011001001100100101011011001010000000011110101001110 0011000010101010111000111001101110011000100110001010010101111110110011101011001010010101110011010110111111010110011100100001100001110000100111100100000000011110011100010001001010101100100000111011111111001110001100100001101111010000101111010110111000011101110001111101000001110001011001100100000001101101111000110011100000101011110010111011110011001100000100100000111111100000001111110100111000001110 1001111101100000010011001111000110110111010100010001111110011010011111101101101001001011101100001101001101100010111000110001101011010011110010100000101000101011101011100011100000110100111100010001100011011111001110110100111101110010111011101111011101111110010111011101000101101001010001101010110011001111010100111010100100110000101100010111111100011100011000011111010000010000100010001110110010011000 0010001111000100101100110011110011011101000100000001100010110101010110110000010011001110111001100101011100110100000001111110000111110000000001000001110000101011010100100001101101100001111110110011111000011001111110001000101000000110000101011001101101110110111111101111010111000110111011111100101111110111111100101001100111110100110001011101101111110000011111000011100001110110011110100010101010001001 1100100111110000010011101001000110001011010111100011110100101101110000000010010011111110001110011100010100101011001011101000001011000000000111110101101001111100000000110001101111000010111110100000001001000000111010001000001000100000100001010110111011100110100111000110000100101011011000000011010111011000111001110000001110011001110100100001001101000001100000100111010001101000101110000001000111111011 0001101100001010000110111111010001101001111100100001101011100110100001000111111101110101101000010101100101110000000010010010011111000010100100100101001011000110100101001010001010110101101110001011000110000000011011010000001110101000010110011110010100110011111100101100000010101101000000010001011000010101010001000010101111001100100100011010101101100100110000001001110101100001001111100001000111000000 0110010001000101111110101111000110010110111001011011011111110011000100010000001111011011110001111110010101100110111100111000101000001001111100011110111010010011000101010011010001001110001110011110100010001110001010011000010011110111101101011010001001111111010111000110101111001010100100010100011000001101101101110000000010011100001111011000101011100011010010010010010111000000111101100110110011111001 0101100111001110111101001000010111111001110001111110111011011110001111100110111010010001001110010111101110001111111111010010001010010010111000000100011001000011100100111000111101110010100110010001011111101100101101100110111111101011000010100111010111011000010111101011011011100110001100010111010010000100010001100111000101001100001001110110101011100000000000100110101001010110010110011110010111001101 1000101010011101110100100111011110100110100110010011001100110110110110111110001000001100000011110010010001100011111111100001111000110010000000001100101111000111101000110111111000100111000000110100000011000111001110100100011010111100011111111101011100100001111111011101001010111100111111010110011110010110011100011100101100110111001111100000001110011110010110111100000001101110100110110001000001110010 1010111101010011011000010000101100010110010111001100100011011101001011110101101101101111010000111000000010011101001001001111101010110111000100110011000110011100010111011101010110100100000001011001010111010000011111000000011000010010000100010000011010101100001110101101010010100101010110101111110011111011110001011111101000111111000010100110000011110001110110110111010110110001101111110111000100000110 1011011101001110011000010011011000011000100000011001010010010100001101010100011110001011011000110110001101000011101011101001001110110111111011110011100100110100101111000100111011111011110111001111101011000000010001011111011111001111110110001010101001101011101011101100011110011001111001000100011100111110011110110101010110111000000001100000110111111011111010000111100010011101001110111111001100000110 0011110101111001110110010001001110010110001111101001010011010100010110010011001000000000101011111011110100101111000111001111101001010000111110110101110111110111110110011011000111001011100001100111110001001001100001011101000111010110111110000010000111110111101110010001011110100100001110010100000001110101011001111101101011110111111000010011000110001010010000000010101011000000101001110101110100001110 0000000101001000101000110001010110011101011001111111111001010000000100010100000001010000110101011011111110011111001010000011011100011110111001011011001100100001111101001001111011001011110101110011100011100111111001110010110011011100100101001111110100100011100110100001010101110110110110100111011101100101110101000011011011010011011001011101100000100010000100101010000101011000101001001010010010110010 1011110000101101000001011100110111111001000000101101011111011110000000110011100101001110101010010000101110110011011111101101100010111011101010110000100001100011111011110110010110110101110100011010101010001110111001110110110100000001100011011110000010111011010010111010000111000101001000010000100111110010100001100100010001101101100101110001010110110011100110001010000100100010001010011111010110101011 0000111010100100101010111100011011111101100011001000001011001110110100101100000001111101110010110010111000011110001001010010101111110011110001100110101000000011000110001110101001001101000000010010111010111010011001110001101011011011001111101101110001010000011000101101010101100101011000100010011110011011011001101110001101101101001001111111101111001011000111001001101111111100101101011101011001001101 1111100010001100000111011101101111011011101001100100011010000011000010100111010011011111101011100011010001101110011000100001110001001101101001101011101011001001000011111010001110010001111001101100010110101001001011000010101010011100100000100000010010001101011010010000111000110011101101000001001001110000100110001111110000010100001110000111101111000110000101101111011001101011110010011000000101111100 1011100101100001000010001010100010111111010111110111001110111111000111010100111101011011110000100110011011001101111010101000100000111010110000111110011001000001000000101001000000001100111010010001100101011110011100011100001110000110010000010011011011101010101111100001100011010100000000111111111011110100111001110011111001101110101110101101001010000111001001111110100111110101000101001110011100000010 0111110001101100000100000001000101011110100101111100111100001000111000011010111000001100011100100010000010011000111010100101100101101010101000000100101011100101011011010010111001000011000110010110111110000000000000101111100110111010011110001110000100001001110110011100110000100000100110111110001111101001111000011000100101101101001000011111000101100011101110111111110111001111110001111111100000000101 0011001100001100011101111011101110100110011001010110010100100110111110101111110000110110001111011011111110101100010111011000111100001110111011011001011110010010011000000111100110000110000001111101000110011100110000101110101000010011000001111111100101000101010000100100010100010000000000100011110000000101100100001110111100110011111011000001100110101110010011110100100100101100111111110010110100001111 0000001111010111110110011011100110111011010111010000010110001101100110110010010101100111010110110111111111000111011100010100001010111001010010011010110001100011111010011111100000111001110000000101110011110011100001110100011011011111000111010010011100100111110100010000111001110111011010110011111000000100000000110100111001111001110010010111000010001010001001111000110101011100011011111001101010100111 0010110010011001010111101100101010000101010010010000111010010001101111010000100001111100000110101011101001000101011001111110001100011110010111010000111111000110010110100011011110010111000001111010000001010010100001110110101110111110001100110100001100001101011000100101110001100100011111110111001001011000111010101111111010000011000100110110001111111010001011000110110010101000101100111010000000111001 0101001100000001100100010001011100001010011001000010101100011011101010111100011100110111101100100001100101001001100001111000111110110111110011111000101010010010010100100110100010011101111101111111110110101111101011111000110110010110111101000110001010100101000110010101000010010110110000000110110011111000010010001110100100000001110101110000000010111100011100001010011000000111110100010101101101011010 0000011011110100101000111000110011000000101000011111011001110011010010100010111000111000101101011101000100100000001100000100101010111100011000101100111111011011111101111110110111110111100101000111000001001110110000100110000000110100101101101111001111111101010110100011011111011001110101010001000010101101101111011101110110000001110011110111111010111101010111011101111111010001010001100011100110001001
cTrader Algo

【cAlgo】含み損益状況をリアルタイムに取得する【Tips】

2/10/2021

4年以上前の記事です。内容が古くなっている可能性があります。

Positionの状態をリアルタイムで把握したい

保有中ポジションの情報はPositionsプロパティから取得できます。例えば全ポジションの総含み損益が知りたければ

private double GetTotalUnrealized() {
    double sum = 0;
    foreach(var pos in Positions){
        sum += pos.NetProfit;
    }
    return sum;
}

こんな風なメソッドを作って呼んであげればいいわけです。しかし、総含み損益なんて刻一刻と変わっていくものです。

そこで今回のテーマは、リアルタイムで総損益を使用するにはどのタイミングでこれを呼んで取得すればいいのか、ということです。

 

3つの方法

3つ方法を紹介しますが、手軽→正確(よりリアルタイム)の順で紹介してますので用途に合わせてお使いください。

 

1.OnTickやCalculateで取得する

当たり前の方法ですね。これであれば値動きがあるたびに損益計算がされるので、プログラム稼働中の通貨ペアのポジションだけであればこれでOKです。

protected override void Calculate() {
    var unrealized = GetTotalUnrealized();
    // 表示させる等、なんか処理
}

問題は他の通貨ペアのポジションの損益も正しく取得したい場合です。稼働中通貨ペアで値動きがない限り、他通貨ペアのポジション損益は更新されません

とはいえほとんどの通貨ペアでは数秒に1回くらいは更新されることになると思うので、おおざっぱでいいならこれで十分かもしれません。

 

2.TimerStartを仕掛けてOnTimerで取得する

たぶんそこそこちゃんとやりたいときの一番手軽な方法。cAlgoでのTimerはこんな感じで簡単に使えます。

protected override void Initialize() {
    var interval = new TimeSpan(0, 0, 0, 0, 30);
    Timer.Start(interval); // 30ms間隔でOnTimerを実行させる
}
protected override void OnTimer() {
    var unrealized = GetTotalUnrealized();
    // 表示させる等、なんか処理
}

これだけでTimer.Stopで止めるかプログラム自体を止めるまで、30ms間隔でOnTimer内の処理が実行されるようになります。

例では30ms間隔での実行にしてますが、やりたいことに合わせて変更してください。重たい処理をさせたいならもっと間隔あけた方がいいかもしれません。

逆にとにかく頻繁に処理を行わせたいならさらに短くしてもかまいません。ただしタイマーの精度は15ms程度です。これ以下の値を設定しても、約15ms間隔での実行になります。

 

3.各通貨ペアの値動きに合わせて取得する

ポジションの通貨ペアに値動きがあり次第、損益を更新する。これぞリアルタイムといった感じですね。30ms間隔で行うよりも処理に無駄がありません。ただ上記の方法に比べると少しだけ面倒です。

コピペする場合はファイル冒頭にこれを書き加えておいてください。

using System.Collections.Generic;
using System.Linq;

以下はメインのIndicatorサブクラス内のコードです。(cBotの場合はInitialize()をOnStart()に書き換えて)

private List<Symbol> _symbols;

protected override void Initialize() {
    _symbols = new List<Symbol>();

    // すべてのポジションのSymbolでTickイベントに処理を加える
    foreach (var p in Positions) TryAddSymbol(p.SymbolName);

    //新たなSymbolのPositionが増えたら_symbol追加
    Positions.Opened += args => TryAddSymbol(args.Position.SymbolName);

    //不要なSymbolを解放
    Positions.Closed += args => {
        var symbolName = args.Position.SymbolName;
        if (Positions.Select(pos => pos.SymbolName).Contains(symbolName)) return;
        var symbol = _symbols.Find(s => s.Name == symbolName);
        if (symbol != null) {
            symbol.Tick -= OnSymbolTick;
            _symbols.Remove(symbol);
        }
    };
            
}
//-----------------------------------------------------
// _symbolsになければ追加してTickイベントに処理を加える
private bool TryAddSymbol(string symbolName) {
    if (!_symbols.Select(s => s.Name).Contains(symbolName)) {
        var symbol = Symbols.GetSymbol(symbolName);
        if (symbol == null) throw new ArgumentException();
        symbol.Tick += OnSymbolTick;
        _symbols.Add(symbol);
        return true;
    } else return false;
}

//---------------------------
// リアルタイムで行いたい処理
private void OnSymbolTick(SymbolTickEventArgs args) {
    var unrealized = GetTotalUnrealized();
    // 表示させる等、なんか処理
}

コードがわかりにくかったら申し訳ありません。コメントに書いてある通りの処理をしてるんだな、と思っていただければいいです。

ポジションの各シンボルを取得して、それぞれのシンボルの値動き(Tick)イベントに合わせて総損益を更新しています。

Positionsに変更があったときの処理も忘れないでください。Openedで新しい通貨ペアのポジションが追加されたら新たなシンボルを取得します。Closedの処理はなくても動きますが、無駄なメモリ使うのは嫌なので、不要になったシンボルは解放してます。

もしかしたら、手動エントリーしたすべてのポジションの合計損益がいくら以上になったら即時決済する!みたいなcBot作るならこの方法がいいかもしれませんね。たかだか数十msの違いで結果が変わるかどうか知りませんが、少なくとも精神的には安心感あります。

 

なんかリアルタイム処理したいときにどうぞ

今回はポジションの損益を例に出しましたが、他にも相場状況に合わせてリアルタイム表示させたいとき、例えば一覧表形式でスプレッドを表示させたりだとか、通貨ペアごとにトレンド方向を一覧表示したりとか、なにかしらリアルタイムで行いたい処理がある場合はこれらの方法が使えると思います。

ご参考までに。


まだコメントはありません

新しいコメント

コメントは承認後に公開されます。承認まで次のコメントは投稿できません。

cTrader's Life

© 2025 ajinori